Skip to content

Instantly share code, notes, and snippets.

View maveonair's full-sized avatar
👨‍💻

Fabian Mettler maveonair

👨‍💻
View GitHub Profile
@maveonair
maveonair / latency.txt
Created June 5, 2012 14:48 — forked from jboner/latency.txt
Latency numbers every programmer should know
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 4K randomly from SSD 150,000 ns 0.15 ms
Read 1 MB sequentially from memory 250,000 ns 0.25 ms
Round trip within same datacenter 500,000 ns 0.5 ms
#!/bin/sh
set -u
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
APP_ROOT=/home/deploy/public_html/rm/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENV=production
@maveonair
maveonair / Get pattern of a DateFormat Object
Created October 8, 2012 12:58
Get pattern of a DateFormat Object
final SimpleDateFormat formatter = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US);
final String pattern = formatter.toLocalizedPattern();
#!/bin/ksh
function proxy(){
export http_proxy="http://localhost:8080/"
export https_proxy="http://localhost:8080/"
export ftp_proxy="http://localhost:8080/"
export no_proxy="localhost,127.0.0.1,localaddress"
echo -e "\nProxy environment variable set."
}
function proxyoff(){
@maveonair
maveonair / encrypt_decrypt_tar_files.txt
Created December 30, 2012 13:16
En/decrypt tar files with openssl
encrypt:
tar -cj directory | openssl des3 -salt > encrypted.tarfile
decrypt:
cat encrypted.tarfile | openssl des3 -d -salt |tar -xvj
@maveonair
maveonair / gist:4960882
Created February 15, 2013 15:01
Add a new text line after a specified pattern with awk
awk '{ if ( match($0, "^pattern") ) { printf "%s\n%s\n", $0, "new TEXT" } else { print } }' input_file.text
@maveonair
maveonair / list_listening_ports.sh
Created February 19, 2013 16:27
Get listening ports
lsof -i | grep LISTEN
@maveonair
maveonair / bonjour_airvideo.rb
Last active December 14, 2015 00:19
Get bonjour information about AirVideo servers
require 'dnssd'
require 'timeout'
begin
timeout 3 do
DNSSD.browse! '_airvideoserver._tcp.', 'local' do |r|
puts "Found HTTP service: #{r.name}"
resolver = DNSSD::Service.new
resolver.resolve(r) do |resolved|
@maveonair
maveonair / mini-sudoku.prolog
Last active December 15, 2015 04:59
Solving a mini Sudoku in Prolog
num(1).
num(2).
num(3).
triple(X,Y,Z) :- X=\=Y,X=\=Z,Y=\=Z.
allnumbers(X,Y,Z) :- num(X),num(Y),num(Z).
ct(X,Y,Z) :- allnumbers(X,Y,Z), triple(X,Y,Z).
sudoko(A,B,C,D,E,F,G,H,I) :- ct(A,B,C),ct(D,E,F),ct(G,H,I),ct(A,D,G),ct(B,E,H),ct(C,F,I).
@maveonair
maveonair / crontab_for_zerigo_dynamic_dns_update
Created April 22, 2013 16:53
Zerigo Dynamic DNS Updates with Cron
33 * * * * wget 'http://update.zerigo.com/dynamic?host=example.zerigo.com&[email protected]&password=f7f9c95662ebc538' -O /dev/null