Skip to content

Instantly share code, notes, and snippets.

from itertools import izip_longest
import re
import zlib
prefix = u"\u200a"
mapping = dict((unichr(0x2002 + x), str(x)) for x in range(8))
known = dict(mapping)
known[prefix] = "prefix"
def _encode_spaces(byteinp, useprefix):
// copy and paste from jquery.js (scroll down to see my code)
/*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(
@lahwran
lahwran / LICENSE-MIT.txt
Last active August 29, 2015 14:02
Little thing for doing d3 the angular way - declaratively. "declarative data driven documents"! (I'm not the first to make something like this)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
# first get the numeral 1
_ = (()==())
__ = _ + _
_ = __ - _
# now build our list of characters
# "False"
__ = `()==[]`
# + "True"
import random
import tempfile
import json
import sys
import os
from twisted.words.protocols import irc
from twisted.internet import reactor, protocol
# sentinels
@lahwran
lahwran / gist:ad4a080ec69c4b607fa7
Last active August 29, 2015 14:00
another markov thingy. bonus: randomized gendered pronouns, for imaginary humanness.
from collections import defaultdict
import random
import time
description = random.choice(["Him", "Her"])
start = object()
end = object()
def generate(chain):
result = [start]
03-13 05:37.28pm <lahwran> ideally the only axioms you'd need would be internal to yourself
03-13 05:37.38pm <lahwran> and the rest would follow from that
03-13 05:39.05pm <lahwran> so, I want to live a long life and enjoy it. loss of a consciousness is the "it could be me" danger, plus something else that I'm not sure yet how to translate into internal-perspective that amounts to "loss of a consciousness is horrifying"
03-13 05:39.19pm <lahwran> though maybe that *is* "it could be me" plus empathy
03-13 05:39.42pm <Otheruser> lahwran: Then, why would you save the wife?
03-13 05:39.47pm <lahwran> live a long life and enjoy it, more humans around me means more enjoyment; loss of any of them is a loss of a huge amount of very valuable data
03-13 05:40.58pm <lahwran> Otheruser: because I could have been in her place
03-13 05:41.11pm <lahwran> and because it would be a huge interaction loss
03-13 05:41.35pm <lahwran> she'll no longer be around to improve the world by being fun/awesome/whatever positive a
"E128", # E128 is "under-indented"
"E127", # E127 is "visual indent mismatch"
"E126", # E126 is "over-indented"
"E124", # Closing bracket does not match visual indentation
"E202", # Whitespace before ) - used for Good Reason in test_time
"E241", # Too much whitespace after : or ,
"E702", # Multiple statements on one line (get over yourself, I know when
# to use this, and it's rarely)
"E121", # stfu about continued comment on previous line in this file
"E201", # whitespace after ( in function call - used for vertical time
def find_intersection(p0, p1, p2, p3):
"""
copied from stackoverflow, reformatted; slightly tweaked to include ends of lines
(see "#tweaked" comments)
note that the changes were made somewhat blindly, guessing at what might work, and the
only reason I have any confidence that they were the right changes are the tests I wrote
"""
#print "start"
s10_x = p1[0] - p0[0]
#!/usr/bin/env python
import itertools
import random
random = random.SystemRandom()
grid = """