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
View SketchSystems.spec
Logged-out
Login
success -> Project List
failure -> Login
Logged-in*
search -> Search Results
logout -> Login
Project List
@jdp
jdp / golf.sh
Last active Apr 29, 2016
Solution to Daily Programmer 264
View golf.sh
awk 'NF {print $NF}' | tr a-z A-Z | tr -d .,\"\; |
xargs -n 1 -I % grep '^% ' cmudict-0.7b |
perl -lne 'if (/.*\b((AA|AE|AH|AO|AW|AY|EH|ER|EY|IH|IY|OW|OY|UH|UW).*)/) {print $1}' |
tr -d 0-9 | awk 'BEGIN{i=1} !seen[$0] {seen[$0]=i++} {print seen[$0]}' | tr 1-9 a-j | tr -d '\n'
@jdp
jdp / example
Last active Mar 11, 2016
Generate a population following a distribution
View example
$ mkpop -i pokemon 100 zipf | sort | uniq -c | sort -rn
68 hoopa
12 diancie
7 zygarde
3 yveltal
2 xerneas
1 volcanion
1 trevenant
1 pumpkaboo
1 noivern
@jdp
jdp / crunch.py
Created Feb 17, 2016
Toy URL shortener with Flask, Redis, and BaseConverter
View crunch.py
from baseconv import BaseConverter
from flask import Flask, abort, make_response, redirect, request, url_for
from flask.ext.redis import FlaskRedis
app = Flask(__name__)
store = FlaskRedis(app)
converter = BaseConverter('23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')
@app.route('/<shortcode>')
@jdp
jdp / redux-storage-engine-file.js
Created Feb 16, 2016
Atomic file storage engine for redux-storage
View redux-storage-engine-file.js
import fs from 'fs';
import tmp from 'tmp';
export default (filename) => ({
load() {
return new Promise((resolve, reject) => {
fs.readFile(filename, (err, contents) => {
if (err) {
if (err.code === 'ENOENT') {
resolve({})
@jdp
jdp / server.py
Created Feb 10, 2016
Serve directory listing kinda like a GitHub project page
View server.py
#!/usr/bin/env python
import cgi
import os
import mistune
from SimpleHTTPServer import SimpleHTTPRequestHandler
from SocketServer import TCPServer
from cStringIO import StringIO
@jdp
jdp / spotlight.py
Created Feb 4, 2016
Run Spotlight queries from console in Python
View spotlight.py
#!/usr/bin/env python
# encoding: utf-8
from AppKit import *
from Foundation import *
from Cocoa import *
from PyObjCTools import AppHelper
@jdp
jdp / cap.sh
Last active Jan 29, 2016
Upload screenshot to imagebin and copy URL to clipboard. OS X only
View cap.sh
#!/usr/bin/env bash
set -e
declare fn
function cleanup {
rm "$fn"
}
trap cleanup EXIT
fn="$(mktemp -t cap).png"
@jdp
jdp / deps.awk
Last active Jan 28, 2016
Some Assembly Required
View deps.awk
#!/usr/bin/env awk -f
/^[a-z]+ -> [a-z]+$/ { print $3, $1 }
/^[a-z]+ (AND|OR) [a-z]+ -> [a-z]+$/ { print $5, $3; print $5, $1 }
/^[0-9]+ (AND|OR) [a-z]+ -> [a-z]+$/ { print $5, $3 }
/^[a-z]+ (LSHIFT|RSHIFT) [0-9]+ -> [a-z]+$/ { print $5, $1 }
/^NOT [a-z]+ -> [a-z]+$/ { print $4, $2 }
@jdp
jdp / jsonform.py
Last active Aug 29, 2015
quick and dirty implementation of HTML JSON form draft
View jsonform.py
# -*- coding: utf-8 -*-
import json
undefined = object()
class JSONFormEncoder(json.JSONEncoder):
def default(self, obj):
if obj == undefined:
return None
You can’t perform that action at this time.