Skip to content

Instantly share code, notes, and snippets.

View mlbright's full-sized avatar

Martin-Louis Bright mlbright

  • Toronto
  • 01:02 (UTC -04:00)
View GitHub Profile
#!/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"
#!/usr/bin/python
# Slow Facebull solution ...
import sys, os
import operator
import re
def strongly_connected_components(graph):
result = []
stack = []
@mlbright
mlbright / echo.c
Created November 1, 2009 03:28 — forked from paulsmith/echo.c
/**
* A simple preforking echo server in C.
*
* Building:
*
* $ gcc -Wall -o echo echo.c
*
* Usage:
*
* $ ./echo
#!/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)
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):
#!/usr/bin/python
# --------------------------------------------------------------------------------- #
import sys, os
from graph import load, pathCost, findHamiltonianCycles as fhc
# --------------------------------------------------------------------------------- #
def machineList(path,names):
machines = []
#!/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):
#!/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)
#!/usr/bin/python
# ---------------------------------------------------------------------------- #
import sys
import os
import errno
import stat
import shutil
def _on_access_error(func, path, excinfo):
@mlbright
mlbright / distkeys.py
Created February 23, 2011 16:25
deploy/distribute ssh public key to multiple hosts using Fabric
"""
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.