Skip to content

Instantly share code, notes, and snippets.

View tcr-ableton's full-sized avatar

Theo Crevon tcr-ableton

View GitHub Profile
@gubatron
gubatron / dht-walkthrough.md
Last active October 24, 2023 01:02
DHT walkthrough notes

DHT Walkthrough Notes

I've put together these notes as I read about DHT's in depth and then learned how the libtorrent implementation based on the Kademlia paper actually works.

What problem does this solve?

400,000,000,000 (400 billion stars), that's a 4 followed by 11 zeros. The number of atoms in the universe is estimated to be around 10^82. A DHT with keys of 160 bits, can have 2^160 possible numbers, which is around 10^48

@pallih
pallih / gist:8434784
Created January 15, 2014 11:42
Bash function to randomize MAC address and hostname on OS X. Could live in ~/.bash_profile
function mask(){
# Changes MAC address to a random one and sets the hostname to a random word
# Tested on OS X 10.9 (Macbook Pro)
# Based on http://blog.kejsarmakten.se/all/software/2013/08/30/spoof-mac-on-osx.html
# and http://osxdaily.com/2010/09/06/change-your-mac-hostname-via-terminal/
# Note: neither are permanent (a reboot resets both)
# For a permanent change to hostname: sudo scutil –-set HostName NEWHOST
# Consider using SpoofMAC: https://github.com/feross/SpoofMAC
NEWMAC=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
echo "Changing MAC " $(ifconfig en0 | grep ether)
@mmacedo
mmacedo / source.fish
Last active August 9, 2017 04:49
Source bash/zsh/ksh files
function _exec_with
set -l shell $argv[1]
set -l file $argv[2]
set -l code $argv[3]
set -l source
switch "$shell"
case bash zsh ksh
set source .
case '*'
@why-not
why-not / gist:4582705
Last active February 1, 2024 00:44
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""making a dataframe"""
df = pd.DataFrame([[1, 2], [3, 4]], columns=list('AB'))
"""quick way to create an interesting data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
"""convert a dictionary into a DataFrame"""
"""make the keys into columns"""
df = pd.DataFrame(dic, index=[0])