Instantly share code, notes, and snippets.

View jarg.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import os
import sys
class InvalidJSONError(ValueError):
def __init__(self, key, *args, **kwargs):
self.key = key
View gophmt.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import sys
import textwrap
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
View shorten.sh
#!/usr/bin/env bash
set -e
B56ALPHABET="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789"
if [[ "$REQUEST_METHOD" = "GET" ]]; then
URL=$(redis-cli get ${PATH_INFO:1})
if [[ -z "$URL" ]]; then
echo "Status: 404 Not Found"
echo "Content-Type: text/plain"
View Makefile
JS = $(wildcard scripts/*.js)
all: game.js game.js.map game.css rules.html
game.js: $(JS)
game.js.map: $(JS)
%.js %.js.map:
closure-compiler --js $(JS) --js_output_file $*.js --create_source_map $*.js.map --source_map_format V3
View relsql.php
<?php
$emp = Relation('emp');
$dept = Relation('dept');
/*
* SELECT *
* FROM emp
* WHERE rownum <= 5;
*/
select($emp, $emp->field('rownum')->lte(5))
View miner.py
#!/usr/bin/env python
import calendar
import datetime
import hashlib
import multiprocessing
import os
import re
import signal
import subprocess
import sys
View negotiation.py
import mimeparse
class ContentNegotiationMixin(object):
def not_acceptable(self, request):
return HttpResponse(status=406)
def get_acceptable(self, request):
return dict(self.accepts)
View csvq.py
#!/usr/bin/env python
import os
import sqlite3
from csvkit import table, CSVKitWriter
from csvkit.cli import CSVKitUtility
from csvkit.sql import make_create_table_statement, make_table
View urp.py
#!/usr/bin/env python
import argparse
import itertools
import os
import sys
import urllib
import urlparse
ERR_NO_SUCH_QUERY = 2
View rdb2proto.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import calendar
import sys
import rdbtools
def emit_protocol(*args):