Skip to content

Instantly share code, notes, and snippets.

View maveonair's full-sized avatar
👨‍💻

Fabian Mettler maveonair

👨‍💻
View GitHub Profile
@maveonair
maveonair / ssh_tunnel_with_two_hops.sh
Created April 24, 2013 13:49
SSH tunnel from localhost to host1 and from host1 to host2:
ssh -L 9999:localhost:9999 host1 ssh -L 9999:localhost:1234 -N host2
@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&user=login@example.com&password=f7f9c95662ebc538' -O /dev/null
@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 / 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 / list_listening_ports.sh
Created February 19, 2013 16:27
Get listening ports
lsof -i | grep LISTEN
@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 / 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
#!/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 / 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/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