Skip to content

Instantly share code, notes, and snippets.

Justin Poliey jdp

Block or report user

Report or block jdp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jdp
jdp / jarg.py
Last active Aug 29, 2015
JSON shorthand for your CLI
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
@jdp
jdp / gophmt.py
Last active Aug 29, 2015
Write gophermap files easily and naturally
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
@jdp
jdp / shorten.sh
Last active Aug 29, 2015
A URL shortening service in bash
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"
@jdp
jdp / Makefile
Last active Sep 24, 2015
makefile/procfile ultimate front end combo
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
@jdp
jdp / relsql.php
Created Mar 20, 2014
sketch of a DSL for generating SQL in PHP
View relsql.php
<?php
$emp = Relation('emp');
$dept = Relation('dept');
/*
* SELECT *
* FROM emp
* WHERE rownum <= 5;
*/
select($emp, $emp->field('rownum')->lte(5))
@jdp
jdp / miner.py
Created Mar 7, 2014
gitcoin miner
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
@jdp
jdp / negotiation.py
Created Mar 4, 2014
content negotiation mixin for django class based views
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)
@jdp
jdp / csvq.py
Created Jan 15, 2014
turn csv files into sqlite tables and query them
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
@jdp
jdp / urp.py
Created Dec 20, 2013
quick command line tool for parsing, inspecting, and mutating URL's
View urp.py
#!/usr/bin/env python
import argparse
import itertools
import os
import sys
import urllib
import urlparse
ERR_NO_SUCH_QUERY = 2
@jdp
jdp / rdb2proto.py
Created Oct 10, 2013
dump redis protocol from rdb file
View rdb2proto.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import calendar
import sys
import rdbtools
def emit_protocol(*args):
You can’t perform that action at this time.