This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import errno | |
import socket | |
import select | |
class EventLoop(object): | |
def __init__(self): | |
self.callbacks = [] | |
self.sources = [] | |
self.handlers = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deaccent unicode strings. | |
# | |
# unicodedata.normalize('NFKD', unicodestring): do a compatibility | |
# decomposition of the unicode string | |
# | |
# unicodedata.category(somecharacter): Find the unicode category | |
# for a character. Category 'Mn' contains all combining accents | |
import unicodedata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
( foo="bar"; echo "Within first shell (pid: $BASHPID): \$foo=$foo" ) | |
( unset foo; echo "Within second shell (pid $BASHPID): \$foo=$foo" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adding a semi-dynamic field to Django ModelAdmin | |
# | |
# Motivation behind this is to see if django.conf.settings contains a | |
# setting of some type. I know this could be done with a factory too. | |
# | |
# django.forms.Form allows adding extra fields to forms initialization | |
# time by modifying self.fields dict in __init__. However, ModelAdmin | |
# only looks at the *class* of the form, not the instance created from | |
# it, to determine the fields it should draw in the admin interface. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile for LaTeX files | |
# Original Makefile from http://www.math.psu.edu/elkin/math/497a/Makefile | |
# Please check http://www.acoustics.hut.fi/u/mairas/UltimateLatexMakefile | |
# for new versions. | |
# Copyright (c) 2005,2006 (in order of appearance): | |
# Matti Airas <Matti.Airas@hut.fi> | |
# Rainer Jung |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def form_preference_list(image, edge, others): | |
def g(): | |
for other_edge in others: | |
yield (other_edge, image.row_dist(edge, other_edge)) | |
return [x[0] for x in sorted(g(), key=operator.itemgetter(1))] | |
def stable_matching(image, lefts, rights): | |
free_left = set(lefts) | |
right_edges = set(rights) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sget () { | |
sala -r $1 | cut -f 2 -d ':' | \ | |
tr -d '[:space:]'|xclip -selection clipboard; | |
} | |
# Set sala completion for sget | |
complete -o nospace -F _sala sget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multitmux() { | |
read first; | |
tmux -q new-session -d -s $1 "ssh -t $first"; | |
tmux set-option quiet on | |
tmux -q set-option -t $1 mouse-select-pane on | |
tmux -q set-window -g -t $1 synchronize-panes on | |
while read host; do | |
tmux -q split-window -p 25 -v -t $1 "ssh -t $host" 2>/dev/null; | |
if [ "$?" == "1" ]; then | |
# If pane is too small, change layout and retry opening |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import os | |
import sys | |
import sparkey | |
import tempfile | |
import timeit | |
from random import randint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host * | |
ControlMaster auto | |
ControlPath ~/.ssh/master-%r@%h:%p | |
ForwardAgent yes | |
ForwardX11 no | |
Host tunnel | |
Hostname nönönö | |
DynamicForward localhost:1080 | |
ProxyCommand none |