This file contains hidden or 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 | |
class TimeExceededError(Exception):pass | |
def run_cmd(cmd, timeout = 0): | |
import signal | |
def alarmHandler(signum, frame): | |
raise TimeExceededError, "Took too long to execute" | |
signal.signal(signal.SIGALRM, alarmHandler) | |
signal.alarm(1) |
This file contains hidden or 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 yaml | |
from jabberbot import JabberBot | |
from beanstalkc import Connection as BSC | |
def connect_beanstalk(host = "127.0.0.1", port = "11300", tube = None): | |
try: | |
c = BSC() | |
except: | |
return None |
This file contains hidden or 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 python2.6 | |
# Converts an arbitrary file to MIDI. Obviously. | |
# Note the output files can be.. long (a 25KiB file becomes about 10 hours), | |
# and may cause players to lockup while opening (the aforementioned 10 hour | |
# file took Quicktime Player 7 about 5-10 seconds to open) | |
import smidi | |
def fileToMidi(input_fname, output_fname): |
This file contains hidden or 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 os | |
import re | |
import platform | |
def makeValidFilename(value, normalize_unicode = False, windows_safe = False, custom_blacklist = None): | |
""" | |
Takes a string and makes it into a valid filename. | |
normalize_unicode replaces accented characters with ASCII equivalent, and | |
removes characters that cannot be converted sensibly to ASCII. |
This file contains hidden or 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 python2.6 | |
"""Twitter's "advanced" search can't seem to find a users tweet from more | |
than a few days ago, so I wrote this simple function to do so. | |
Not good code, not very efficient, only finds the most recent occurrence of | |
the word.. but it worked for what I needed | |
""" | |
import urllib | |
import simplejson as json |
This file contains hidden or 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 python2.6 | |
"""Simple script to names TV episode by first aired date. | |
Files must be organised as follows: | |
./ShowName/20091130-anything.ext | |
For example: | |
./Scrubs/20050118.avi |
This file contains hidden or 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
"""Calculates how long a password might take to brute force | |
""" | |
def chunks(l, n): | |
for i in xrange(0, len(l), n): | |
yield l[i:i+n] | |
def human_readable_number(n): | |
return ",".join(list(chunks(str(n)[::-1],3)))[::-1] |
This file contains hidden or 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 python2.6 | |
"""Simple script to names TV episode by episode name. | |
Files must be named as follows: | |
./ShowName - Episode Name.ext | |
For example: | |
./Scrubs - My First Day.avi |
This file contains hidden or 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 python2.6 | |
"""Processes fxphd.com class ZIP files, by copying the archive to a specified | |
location, then extracting this into a specified path. | |
Directory structure is: | |
/example/fxphd/10jan_term/ | |
archives/ | |
preview_classes/ |
This file contains hidden or 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
"""Nuke/Python script that displays the selected node in the DAG | |
using a lot of node postage-stamps.. Not *exactly* useful.. | |
http://img46.imageshack.us/img46/923/nukenodalimgviewer.png | |
""" | |
import nuke | |
def getRGB(node, x, y): | |
return [node.sample(chan, x, y) for chan in ['red', 'green', 'blue']] |
OlderNewer