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
#!/usr/bin/python | |
# backup svn, rsync backups to a remote location | |
import subprocess | |
import sys, time, os, datetime | |
import ConfigParser | |
touch = "/tmp/svn-remote-backup.touch" | |
source = "/svn/backups/" # Note trailing slash | |
target = "test@example:/storage/svn/backups" |
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
#!/usr/bin/python | |
# Slow Facebull solution ... | |
import sys, os | |
import operator | |
import re | |
def strongly_connected_components(graph): | |
result = [] | |
stack = [] |
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
/** | |
* A simple preforking echo server in C. | |
* | |
* Building: | |
* | |
* $ gcc -Wall -o echo echo.c | |
* | |
* Usage: | |
* | |
* $ ./echo |
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
#!/usr/bin/env python | |
import sys | |
filename = sys.argv[1] | |
input = open(filename) | |
n, m = ( int(x) for x in input.readline().strip().split() ]) | |
print "%d %d" % (n,m) |
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 dijkstra import shortestPath, prevPath, Dijkstra | |
shortest = shortestPath | |
dijk = Dijkstra | |
prevpath = prevPath | |
def cross(a,b): | |
return set([ (x,y) for x in a for y in b if x != y ]) | |
def getEdges(graph): |
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
#!/usr/bin/python | |
# --------------------------------------------------------------------------------- # | |
import sys, os | |
from graph import load, pathCost, findHamiltonianCycles as fhc | |
# --------------------------------------------------------------------------------- # | |
def machineList(path,names): | |
machines = [] |
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
#!/usr/bin/python | |
# Brute force solution to the Facebull problem | |
import cProfile | |
import sys, os, re, operator | |
import dijkstra | |
from graph import cross | |
def verify(kset, combos): | |
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
#!/usr/bin/env python | |
# anagram checker | |
from collections import defaultdict | |
d = defaultdict(set) | |
for i in open('/usr/share/dict/words'): | |
i = i.strip().lower() | |
if len(i) == 9: | |
d[tuple(sorted(i))].add(i) |
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
#!/usr/bin/python | |
# ---------------------------------------------------------------------------- # | |
import sys | |
import os | |
import errno | |
import stat | |
import shutil | |
def _on_access_error(func, path, excinfo): |
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
""" | |
usage: | |
fab -f distkeys.py set_hosts:/path/to/hosts_file add_key:/path/to/key | |
Use --password and --user options as necessary | |
Inspired by shell script at http://github.com/mlbright/mybin/raw/master/distkeys.sh | |
Fabric recipe to distribute your ssh key to large number of hosts. |