Skip to content

Instantly share code, notes, and snippets.

View gtzilla's full-sized avatar
🎯
Focusing

gregory tomlinson gtzilla

🎯
Focusing
View GitHub Profile
@alexalemi
alexalemi / twittercompress.py
Created August 31, 2011 03:24
Twitter Compression
""" A script to attempt the compression of written english
to the chinese character set """
import os
from collections import OrderedDict
from math import log
import itertools
from collections import Counter
# FIXME This is a **terrible** hack. This logic should really be
# in the model. It's very difficult to put it there because we
# can only perform index updates here, in the API layer, because
# of the way we mix sync/async code. You should be shaking your
# head in disgust the entire time you read this code and be
# thinking, "What kind of fucking muppet would even think this is
# a good idea?! ZOMG!!"
@gtzilla
gtzilla / regex_compile_test2.js
Created October 26, 2011 07:49
Regex Test, consistent fail on every other when matching - or !
var raw_str_regex = "-([a-zA-Z0-9_]+)$";
var regex = new RegExp(raw_str_regex, "gm");
var lst = [
"this is -not",
"this is -not",
"this is -not",
"this is -not",
"this is -not",
"this is -not"
"""Monads in Python, as close as I can get them to
Haskell
"""
class Monad(object):
def return_(self, value):
raise NotImplementedError()
def __ge__(self, mf):
raise NotImplementedError()
@apg
apg / p.py
Created April 11, 2011 20:56
def charorquoted(strn):
c = anychar(strn)
if c[0] == '"':
return None
elif c[0] == '\\':
c2 = anychar(c[1])
if c2[0] in ('\\', '"'):
return (c[0] + c2[0], c2[1])
else:
return c
@jsocol
jsocol / php-serve.py
Created February 14, 2011 17:32
A local dev server for PHP.
#!/usr/bin/env python
"""
Add php-serve.py to your PATH, then, from whatever directory is the root
of your PHP application, just run:
$ php-serve.py
You can optionally specify a port number as an argument. By default,
port 8000 is used:
@jsocol
jsocol / functools.js
Created February 12, 2011 08:00
partial and curry
var partial = exports.partial = function partial(fn) {
var args = arguments,
func = fn;
[].shift.apply(args);
return function() {
var _args = [].slice.call(args, 0);
[].push.apply(_args, arguments);
return func.apply(func, _args);
};
};
@gtzilla
gtzilla / Bash Profile venv delay load
Created January 31, 2011 16:48
Delay sourcing virtualenvwrapper.sh until first call to workon
## delay sourcing venv to workon call
## replace "source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper.sh"
## with below block
function load_env {
if [ type -p workon &> /dev/null ]; then
# nothing, source is loaded
workon "$@"
else
unalias workon
source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper.sh
;;;;;;;;;
;; erc ;;
;;;;;;;;;
; http://www.emacswiki.org/emacs/ErcHighlightNicknames
(and
(require 'erc-highlight-nicknames)
(add-to-list 'erc-modules 'highlight-nicknames)
(erc-update-modules))
;;; map ctrl-a to beginning of line
@justinabrahms
justinabrahms / pyc0n.js
Created December 3, 2010 03:38
bot to handle votes for pycon selection.
// pycon talk selection irc bot.
var irc = require('../../node-irc/lib/irc.js');
var sys = require('sys');
var imb0t = function () {
return {
pattern_list: [],
client: undefined,
position: -1, // starts at -1 so we can increment it on the first ,next to make it 0, which properly indexes