Skip to content

Instantly share code, notes, and snippets.

View bergman's full-sized avatar

Joakim Bergman bergman

View GitHub Profile
@bergman
bergman / ssh-rc
Created October 6, 2014 08:56
tmux ssh-agent forwarding
# this file goes in ~/.ssh/rc
if [ -S "$SSH_AUTH_SOCK" ]; then
# This gets executed by sshd on every client login, symlinking the forwarded
# agent socket into a predictable location to be picked up by tmux.
ln -sf "$SSH_AUTH_SOCK" "$HOME/.ssh/ssh_auth_sock"
fi
@bergman
bergman / region_lookup.py
Created August 5, 2015 11:10
region code to region name
# curl -O "http://www.maxmind.com/download/geoip/misc/region_codes.csv"
import csv
region_lookup = {}
with open("region_codes.csv", "rb") as f:
reader = csv.reader(f, delimiter=",")
for i, row in enumerate(reader):
region_lookup[(row[0], row[1])] = row[2]
@bergman
bergman / regex för tagg i textmate
Created January 10, 2010 13:43
regex för tagg i textmate
</?font.*?>
perl -pi -w -e 's/search/replace/g;' *.txt
@bergman
bergman / mp3 streaming in mpd
Created March 15, 2010 07:24
mp3 streaming in mpd
# install some package maintenance scripts (needed to build the .deb)
sudo aptitude install devscripts pbuilder
# get the source
apt-get source mpd
cd mpd-0.15.4
# change DEB_CONFIGURE_USER_FLAGS to include --enable-lame-encoder
vim debian/rules
# build dependencies
sudo /usr/lib/pbuilder/pbuilder-satisfydepends
# lame isn't a listed dependency so install it manually
Köra Time Machine i Ubuntu
echo deb http://ftp.de.debian.org/debian sid main >> /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9AA38DCD55BE302B
aptitude install libgcrypt
aptitude install netatalk
@bergman
bergman / gist:518984
Created August 11, 2010 13:37
Manual binding of events for html5 video in GWT
class MyVideoPlayer {
private void onPlay() {
// do something
}
private native void bindEvents() /*-{
var instance = this;
var v = this.@MyVideoPlayer::getVideoElement()();
v.addEventListener("click", function() { instance.@MyVideoPlayer::onClick()(); });
v.addEventListener("touchstart", function() { instance.@MyVideoPlayer::onClick()(); });
@bergman
bergman / Player.java
Created August 19, 2010 11:30
A quick example of how to set up events for a video element that is already in the DOM and thus not created from within GWT.
package MyVideoPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import com.google.code.gwt.html5.media.client.VideoElement;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Element;
@bergman
bergman / largetype.zsh
Created October 26, 2011 19:52
Use Quicksilver}’s ’Large type’ command from zsh
largetype() { osascript 2>/dev/null <<EOF
tell application "Quicksilver"
show large type "$*"
end tell
EOF
}
@bergman
bergman / gist:2407394
Created April 17, 2012 16:42 — forked from georgel/gist:2199359
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...