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
<?php | |
function isOntarioPostalCode($string){ | |
return preg_match("%[PKLNM]\d[ABCEGHJKLMNPRSTVWXYZ]( )?\d[ABCEGHJKLMNPRSTVWXYZ]\d%i"), $string); | |
} | |
?> |
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 href="http://foursquare.com" rel="nofollow">foursquare</a> | |
<a href="http://instagram.com" rel="nofollow">Instagram</a> |
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
# Jobmine Data Parser v0.1 | |
# Peter Sobot, January 15, 2012 | |
# | |
# Takes in a Jobmine search result dump (i.e.: "ps.xls" which is actually HTML) | |
# puts it all into a DB for easy self-searching and fun | |
# | |
# Assumed table system: | |
# | |
# CREATE TABLE `jobs` ( |
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 Queue | |
import threading | |
import sys | |
__author__ = 'psobot' | |
class ExceptionThread(threading.Thread): | |
def __init__(self, *args, **kwargs): | |
threading.Thread.__init__(self, *args, **kwargs) | |
self.__status_queue = Queue.Queue() |
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 Queue import Queue | |
import subprocess | |
import threading | |
import traceback | |
import logging | |
import time | |
log = logging.getLogger(__name__) | |
""" |
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
# Hacky random image thumbnailer. | |
# by Peter Sobot, April 21, 2012 | |
# Based heavily on code by Michael Macias | |
# (https://gist.github.com/a54cd41137b678935c91) | |
require 'rmagick' | |
images = Dir.glob(ARGV[0] ? ARGV[0] | |
: '-default-input-paths-') | |
output_dir = (ARGV[1] ? ARGV[1] |
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
proxy_cache_path /tmp/recipe_cache levels=1:2 keys_zone=RECIPE:64m inactive=3600m max_size=360m; | |
# Yada yada yada... | |
server { | |
# Yada yada yada, more in here... | |
location ^~ /recipes { | |
rewrite ^/recipes\??(.*) /recipes?key={your_private_api_key_here}&$1 break; |
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
""" | |
multiprocesscallback.py, by Peter Sobot (psobot.com), May 13, 2012 | |
Handles callback functions in classes that have member functions that | |
are executed in a different process. A crazy experiment in Python | |
magic that breaks a lot of rules. | |
Do not use in production, for any reason. (Although I do.) | |
If your class takes in a callback, like so: |
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
class RoundingDict(dict): | |
def __getitem__(self, key): | |
if key in self: | |
return dict.__getitem__(self, key) | |
try: | |
values = [abs(x - key) for x in self.keys()] | |
return self.values()[values.index(min(values))] | |
except (TypeError, ValueError): | |
raise KeyError(key) |
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
""" | |
Detect exactly which bytes have changed in a file. | |
Useful for binary reverse engineering: | |
- Start script | |
- Save file from program, changing one attribute | |
- See which byte(s) have changed | |
""" | |
import os | |
import traceback |
OlderNewer