Skip to content

Instantly share code, notes, and snippets.

@bernardopacheco
bernardopacheco / 00_README.md
Last active May 8, 2024 03:17
Unity Event Manager event-driven architecture.

Unity Event Manager

This Gist represents an event-driven architecture that helps to structure my games in Unity. It uses events to trigger and communicate between decoupled parts of a game.

Usage

In the first game scene, create an empty Game Object named EventManager and attach the EventManager.cs script to it. This script is set to DontDestroyOnLoad, i.e., it won't be destroyed when reloading scene.

The Producer.cs and Consumer.cs classes show how an event is published and consumed. In this example, when a coin is collected, an addCoins event is published with the collected amount. A Consumer receives the amount of coins collected and update its own coins amount.

@mda590
mda590 / stress_test.py
Created June 8, 2018 14:07
Python script useful for stress testing systems
"""
Produces load on all available CPU cores.
Requires system environment var STRESS_MINS to be set.
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
import time
import os
@Dev-Dipesh
Dev-Dipesh / image.md
Last active May 8, 2024 03:16
Javascript loops can be quite confusing. Knowing the write loop to use can make a big difference in performance.

A4 Image file if you would like to print it ♥ JS Loops Cheatsheet

@Haythamasalama
Haythamasalama / createTopicsTelegram.js
Created August 18, 2023 17:44
Automated Telegram Topic Generation using JavaScript
const subjects = [
{
name: "Quizzes",
icon_custom_emoji_id: "5433614043006903194",
text: "Quizzes Topic",
},
// etc
];
const telegramToken = "";
const chatId = "";
@dannote
dannote / final-cut-pro-trial-reset.swift
Last active May 8, 2024 03:08
Final Cut Pro X trial reset
#!/usr/bin/swift
import Foundation
let path = URL(fileURLWithPath: NSString(string: "~/Library/Application Support/.ffuserdata").expandingTildeInPath)
let data = try! NSData(contentsOf: path) as Data
let dictionary = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as! NSDictionary
let mutableDictionary = dictionary.mutableCopy() as! NSMutableDictionary
for (key, value) in mutableDictionary {
@RikshaDriver
RikshaDriver / 0-compile-r8152-qnap.md
Last active May 8, 2024 03:08
Compiling Realtek 8152, 8156 and 8157 ( RTL8152 ) drivers for QNAP NAS

Compiling Realtek RTL 8152, 8156 and 8157 drivers for QNAP NAS

Many QNAP NAS devices only come with 1Gbe network interfaces. These devices can easily benefit from a simple network upgrade by connecting the ubiquitious 2.5Gbe USB NICs from Realtek. Unfortunately, some of the older QNAP NAS systems do not support the newer r8156 based 2.5Gbe NICs or r8157 based 5Gbe NICs as they run an older 4.x linux kernel and the r8152 source files included with the older linux kernel are based off an older codebase that predates the 8156/8157 series.

With some elbow grease however, we can build support for the 2.5 & 5 Gbe adapters and easily upgrade functionality.

rt_2 5gbe_qnap

@sloanlance
sloanlance / clone-private-github-repo-in-google-colab.ipynb
Last active May 8, 2024 03:07
clone-private-github-repo-in-google-colab.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Lisprez
Lisprez / epoll.go
Created March 29, 2019 06:47 — forked from tevino/epoll.go
Golang example for using epoll
package main
import (
"fmt"
"net"
"os"
"syscall"
)
const (
@jboner
jboner / latency.txt
Last active May 8, 2024 03:00
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

Mount Volumes into Proxmox VMs with Virtio-fs

Part of collection: Hyper-converged Homelab with Proxmox

Virtio-fs is a shared file system that lets virtual machines access a directory tree on the host. Unlike existing approaches, it is designed to offer local file system semantics and performance. The new virtiofsd-rs Rust daemon Proxmox 8 uses, is receiving the most attention for new feature development.

Performance is very good (while testing, almost the same as on the Proxmox host)

VM Migration is not possible yet, but it's being worked on!