Skip to content

Instantly share code, notes, and snippets.

View gtzilla's full-sized avatar
🎯
Focusing

gregory tomlinson gtzilla

🎯
Focusing
View GitHub Profile
@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:
@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
"""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()
@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"
# 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!!"
@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
@gtzilla
gtzilla / helpers.js
Last active May 2, 2016 12:04
JavaScript closure state manager for a single argument, with support for default state initialization value. A JavaScript private variables method.
;(function(window) {
'use strict';
/**
filename: helpers.js
author: gregory tomlinson
license: MIT
Be a "utility" helper method
file that is namespaced to 'helpers'
#!/usr/bin/env python
### Requires latest boto (cuz I checked in code to boto a moment ago)
import uuid
from boto.mturk.connection import MTurkConnection
from boto.mturk.question import Question, QuestionForm, QuestionContent
from boto.mturk.question import AnswerSpecification, FreeTextAnswer
from boto.mturk.question import Overview
#from boto.mturk.qualification import Qualifications # these exist!
@paulosuzart
paulosuzart / tornado_basic_auth.py
Created November 2, 2010 19:52
Sample (working) for basic http auth on tornado
def authenticated(auth):
def decore(f):
def _request_auth(handler):
handler.set_header('WWW-Authenticate', 'Basic realm=tmr')
handler.set_status(401)
handler.finish()
return False
@gtzilla
gtzilla / Configuring Daemontools for Ubuntu 10
Created September 3, 2010 08:17
setup daemontools on ubuntu
#!/bin/sh
## you'll have to do a couple extra steps to get this running
## there are probably other ways to handle svncanboot, but this is from the linux forum
set -e
if
touch /etc/_testr_file
then