Skip to content

Instantly share code, notes, and snippets.

@wting
wting / die_hard.py
Last active April 7, 2017 00:16 — forked from nathants/die-hard.py
from hypothesis import given, settings
from hypothesis.strategies import lists, sampled_from
def new_state():
return {'big': 0, 'small': 0}
def invariants(state):
return (0 <= state['small'] <= 3 and
0 <= state['big'] <= 5)
@wting
wting / punk.py
Last active April 12, 2017 21:01 — forked from briandeheus/punk.py
Don't be a punk, punk
import binascii
import struct
class Punk(object):
"""Full blog post about hiding data within PNG files here:
http://blog.brian.jp/python/png/2016/07/07/file-fun-with-pyhon.html
Example use case:
@wting
wting / gfm.rb
Created January 9, 2013 00:11 — forked from mojombo/gfm.rb
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
@wting
wting / uri.js
Created May 7, 2012 19:31 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@wting
wting / tree.md
Created April 25, 2012 23:36 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!