Skip to content

Instantly share code, notes, and snippets.

View psobot's full-sized avatar

Peter Sobot psobot

View GitHub Profile
@psobot
psobot / Makefile
Last active August 29, 2015 13:57 — forked from jlfwong/Makefile
.PHONY: run
run: test
./$<
test: test.o runtime.o
gcc -arch i386 $^ -o $@
%.o: %.asm
nasm -f macho $< -o $@
@psobot
psobot / keybase.md
Created March 29, 2014 23:57
keybase prove github

Keybase proof

I hereby claim:

  • I am psobot on github.
  • I am psobot (https://keybase.io/psobot) on keybase.
  • I have a public key whose fingerprint is B8C4 380D 42A7 C58C 9528 93AD 66BD 052C A0BF 6065

To claim this, I am signing this object:

@psobot
psobot / ontarioPostalCode.php
Created February 1, 2011 21:41
Detects the validity of an Ontario postal code.
<?php
function isOntarioPostalCode($string){
return preg_match("%[PKLNM]\d[ABCEGHJKLMNPRSTVWXYZ]( )?\d[ABCEGHJKLMNPRSTVWXYZ]\d%i"), $string);
}
?>
@psobot
psobot / jobmine_parse.rb
Created January 16, 2012 01:43
Jobmine MySQL Dumper
# 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` (
@psobot
psobot / exceptionthread.py
Created April 14, 2012 19:05
Exception-Raising Thread
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()
@psobot
psobot / example.nginx.conf
Created May 9, 2012 03:35
API proxying with nginx
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;
@psobot
psobot / roundingdict.py
Created June 1, 2012 04:11
Rounded Dictionary Access in Python
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)
@psobot
psobot / beatbox.py
Created August 10, 2012 15:25
The Beatbox Machine
"""
"The Beatbox Machine" by Peter Sobot and Borna Almasi
Designed and written in 4 hours on Sept. 25, 2011 at Music Hack Day Montréal
Dependencies:
EchoNest.Remix
Wubmachine.Remixer (https://github.com/psobot/wub-machine)
this file should end up in <wub-root>/remixers/beatbox.py
Honestly, this is just a code-dump to Github. (And the code only sorta-kinda-works, with hardcoded values.)
@psobot
psobot / ronf.sb
Created August 25, 2012 21:33
Read-only network-free command sandbox
;; Read-only, network-free sandbox
;; Mac OS X 10.7+
;; Restricts file writes and network access for any command run like:
;; sandbox-exec -f ronf.sb <command>
;; Useful for untrusted programs that should only do computation.
(version 1)
(allow default)
(deny file-write*)
(deny network*)
@psobot
psobot / assignment.tex
Created September 19, 2012 14:46
Homework Assignment LaTeX Template
\documentclass[10pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\setcounter{secnumdepth}{0}
\usepackage{fancyhdr, lastpage}
\pagestyle{fancy}