Skip to content

Instantly share code, notes, and snippets.

View telamonian's full-sized avatar

Max Klein telamonian

View GitHub Profile
@jboner
jboner / latency.txt
Last active June 25, 2024 12:58
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
@werediver
werediver / singleton.py
Created December 28, 2012 09:51
A thread safe implementation of singleton pattern in Python. Based on tornado.ioloop.IOLoop.instance() approach.
import threading
# Based on tornado.ioloop.IOLoop.instance() approach.
# See https://github.com/facebook/tornado
class SingletonMixin(object):
__singleton_lock = threading.Lock()
__singleton_instance = None
@classmethod
@hiko9lock
hiko9lock / TouchCamera.cs
Last active April 1, 2023 08:43
[Unity 3D] Testing camera pan,zoom, orbit for iOS. Setting camera target after you have attached this camera script to camera object.
using UnityEngine;
using System.Collections;
public class TouchCamera : MonoBehaviour {
public Transform target;
Vector3 f0Dir= Vector3.zero;
float zoomDistance= 5;
float theta= 0.0F;
float fai= 0.0F;
float dx= 0.0F;
@oktayacikalin
oktayacikalin / mount.py
Created October 20, 2013 07:14
How to mount a local volume using gvfs (gio) in Python 3 - quick and dirty.
#!/usr/bin/env python3
# Quick and dirty implementation of mounting a local volume using Gio.
# For people who were scratching their heads like me.
# Code below based on infos from:
# http://stackoverflow.com/questions/5709454/gio-check-if-volume-is-mounted
# http://stackoverflow.com/questions/1991206/accessing-samba-shares-with-gio-in-python/2051628#2051628
@arulrajnet
arulrajnet / ChromeAppDownloader.py
Last active February 15, 2024 01:06
Python Script to download the Chrome Extensions (CRX) file directly from the google chrome web store.
# -*- coding: utf-8 -*-
"""
Python Script to download the Chrome Extensions (CRX) file directly from the google chrome web store.
Referred from http://chrome-extension-downloader.com/how-does-it-work.php
"""
from __future__ import division
import argparse
import requests
@mislav
mislav / spotify-remote-patch.sh
Last active May 4, 2023 11:09
Patch installer for OS X `rcd` daemon to make headset remote buttons start/stop Spotify instead of iTunes. The pause/resume functionality still doesn't work unless iTunes is running in the background, for some inexplicable reason.
#!/bin/bash
# Run once to patch `rcd` daemon after creating a backup.
# Run again to restore the backup and revert back to original functionality.
set -eu
if [ "$USER" != "root" ]; then
exec sudo "$0" "$@"
fi
rcd="/System/Library/CoreServices/rcd.app/Contents/MacOS/rcd"
@IceCreamYou
IceCreamYou / force-scrollbars-visible.css
Last active March 6, 2024 01:00
Mac OS X hides scrollbars by default. This is annoying for UI design because it means users might not realize that certain areas are scrollable. This public domain Gist forces the scrollbar to always be visible with native behavior in Webkit-based browsers (Chrome and Opera) on Macs.
.force-show-scrollbars ::-webkit-scrollbar-track:vertical {
border-left: 1px solid #E7E7E7;
box-shadow: 1px 0 1px 0 #F6F6F6 inset, -1px 0 1px 0 #F6F6F6 inset;
}
.force-show-scrollbars ::-webkit-scrollbar-track:horizontal {
border-top: 1px solid #E7E7E7;
box-shadow: 0 1px 1px 0 #F6F6F6 inset, 0 -1px 1px 0 #F6F6F6 inset;
}
@Borod4r
Borod4r / UnityShaders.xml
Last active October 25, 2021 13:26
Basic syntax highlight for Unity ShaderLab code in Project Rider
<!--
Basic syntax highlight for Unity ShaderLab code in Project Rider.
v1.0
Download this file and put it into your "filetypes" folder.
Windows Vista, 7, 8, 10:
<SYSTEM DRIVE>\Users\<USER ACCOUNT NAME>\.Rider10\config\filetypes
Mac OS X:
@alfredkrohmer
alfredkrohmer / xbox-one-wireless-protocol.md
Created November 23, 2016 21:52
XBox One Wireless Controller Protocol

Physical layer

The dongle itself is sending out data using 802.11a (5 GHz WiFi) with OFDM and 6 Mbit/s data rate:

Radiotap Header v0, Length 38
    Header revision: 0
    Header pad: 0
    Header length: 38
    Present flags
@thvitt
thvitt / register-jupyter-env
Last active March 31, 2023 16:26
Register a jupyter kernel for the current pyenv.
#!/bin/sh
if [ "$PYENV_VERSION" -ne "" ]
then
name=`pyenv version-name`
python=`pyenv which python`
else
name=`basename "$VIRTUAL_ENV"`
python="$VIRTUALENV/bin/python"
fi