Skip to content

Instantly share code, notes, and snippets.

@rtomayko
rtomayko / ssh-persistent-control-master.md
Created Jun 7, 2017
10x SSH connection speedup w/ persistent control masters
View ssh-persistent-control-master.md

SSH Persistent Control Master Config

Add to ~/.ssh/config:

Host *
  # Enable persistent connection multiplexing
  ControlMaster auto
  ControlPath ~/.ssh/-%r@%h:%p
  ControlPersist 600
@rtomayko
rtomayko / gem-apply
Created Feb 13, 2015
Apply a patch to a bundle installed gem (not for the faint of heart)
View gem-apply
#!/bin/sh
#/ Usage: gem-apply <gem> <patchfile
#/ Apply a patch to a locally installed gem.
#/
#/ Example:
#/ % curl https://github.com/jekyll/jekyll/pull/3452.patch | gem-apply jekyll
#/ patching file lib/jekyll/commands/serve.rb
#/ Hunk #1 succeeded at 39 (offset -1 lines).
#/ Hunk #2 succeeded at 125 (offset -6 lines).
#/ patching file lib/jekyll/commands/serve.rb
@rtomayko
rtomayko / testlib.sh
Last active Nov 15, 2018
Simple shell command language test library.
View testlib.sh
#!/bin/sh
# Usage: . testlib.sh
# Simple shell command language test library.
#
# Tests must follow the basic form:
#
# begin_test "the thing"
# (
# set -e
# echo "hello"
@rtomayko
rtomayko / latency.txt
Created Jun 1, 2012 — forked from jhclark/latency.txt
Latency numbers every programmer should know
View latency.txt
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 1 MB sequentially from memory 250,000 ns 0.25 ms
Round trip within same datacenter 500,000 ns 0.5 ms
Read 1 MB sequentially from SSD 1,000,000 ns 1 ms 4X memory
@rtomayko
rtomayko / gist:2601550
Created May 5, 2012
Open beautiful git-scm.com manual pages w/ git help -w
View gist:2601550
# The new git-scm.com site includes man pages designed for pleasant viewing in a web browser:
#
# http://git-scm.com/docs
#
# The commands below can be used to configure git to open these pages when
# using `git help -w <command>' from the command line. Just enter the config
# commands in your shell to modify your ~/.gitconfig file.
# Create a new browser command and configure help -w to use it.
git config --global browser.gitscm.cmd "/bin/sh -c 'open http://git-scm.com/docs/\$(basename \$1 .html)' --"
@rtomayko
rtomayko / MikeClock.java
Created Apr 7, 2012
Digital Clock Java applet from 1996 written by none other than @mperham
View MikeClock.java
/*
* Digital Clock Java applet 06/27/96
* by Mike Perham mperham@cs.cornell.edu
*
* Blinks the colon every second; refreshes time
* every minute. Futuristic LED display. Generally nifty.
*
* Array digit[] holds a bitmask of which LEDs each number
* lights up: digit[1] = 6 because it lights up the 2nd
* and 3rd LEDs.
View gist:1202895
You'll need:
- Old Fashioned glasses, two of
- Sugar cubes, two of
- Peychaud's Aromatic Cocktail Bitters, one bottle of
- Ice, enough to fill both glasses
- Water, one oz of
- Rye whisky, two oz of
- St. George Absinthe Verte, 0.333oz of
- Lemon, one twist of
@rtomayko
rtomayko / optparse-template.rb
Last active Jan 19, 2020
Ruby optparse template
View optparse-template.rb
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@rtomayko
rtomayko / gist:942910
Created Apr 26, 2011 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
View gist:942910
$ git branch -r --merged |
grep origin |
grep -v -e '>' -e master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
View happy birthday, defunkt
.__ ___. .__ __ .__ .___
| |__ _____ ______ ______ ___.__. \_ |__ |__|_______ _/ |_ | |__ __| _/_____ ___.__.
| | \ \__ \ \____ \ \____ \< | | | __ \ | |\_ __ \\ __\| | \ / __ | \__ \ < | |
| Y \ / __ \_| |_> >| |_> >\___ | | \_\ \| | | | \/ | | | Y \/ /_/ | / __ \_\___ |
|___| /(____ /| __/ | __/ / ____| |___ /|__| |__| |__| |___| /\____ | (____ // ____|
\/ \/ |__| |__| \/ \/ \/ \/ \/ \/
_____ ___ ___ ___ ___ ___
/ /::\ / /\ / /\ /__/\ /__/\ /__/| ___
/ /:/\:\ / /:/_ / /:/_ \ \:\ \ \:\ | |:| / /\
/ /:/ \:\ / /:/ /\ / /:/ /\ \ \:\ \ \:\ | |:| / /:/
You can’t perform that action at this time.