Skip to content

Instantly share code, notes, and snippets.

from mpmath import mp, sqrt, atan2
mp.dps = 250
luv_good = mp.mpf("36.14585083971970000000000000000000"), mp.mpf("0.00000000000179982851973451000000"), mp.mpf("0.00000000000059994283991150500000")
luv_bad = mp.mpf("36.14585083971970000000000000000000"), mp.mpf("0.00000000000178678628408426000000"), mp.mpf("0.00000000000062602731121200500000")
lch_good = mp.mpf("36.14585083971970000000000000000000"), mp.mpf("0.00000000000189718584003013000000"), mp.mpf("18.43494882292200000000000000000000")
lch_bad = mp.mpf("36.14585083971970000000000000000000"), mp.mpf("0.00000000000189328165347235000000"), mp.mpf("19.30867293488920000000000000000000")
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 = """
watch The Serpent's Lair (4)
meh, backstory In the Line of Duty
meh, annoying Prisoners
meh The Gamekeeper
meh Need
meh Thor's Chariot
meh, char dev Message in a Bottle
meh Family
good, watchy watchy Secrets
meh, but good moments Bane
# data source:
# http://www.census.gov/genealogy/www/data/1990surnames/dist.male.first
# http://www.census.gov/genealogy/www/data/1990surnames/dist.female.first
from collections import namedtuple
n = namedtuple("n", "freq, index")
m = namedtuple("m", "delta, mindex, findex, mfreq, ffreq")
def df1(f1, f2):
return abs(f1 - f2)
class q(object):
def __nonzero__(self):
import inspect
import re
stack = inspect.stack()
matchy = re.compile("^if q: (.*)$")
parentframe = stack[1]
stackframe = parentframe[0]
text = parentframe[4][0].strip()
@lahwran
lahwran / nltk_bot.py
Last active December 21, 2015 04:09
"""
To use:
1. Install virtualenv and pip - probably best done via your package manager:
sudo apt-get install python-pip python-virtualenv
2. `virtualenv stupidaibot`
3. `source stupidaibot/bin/activate`
4. save this file somewhere (if you haven't already)
@lahwran
lahwran / index.html
Last active December 21, 2015 04:09 — forked from mbostock/.block
Pink hexbinning ♥
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.axis text {
font: 10px sans-serif;
}
.axis path,
.axis line {
#!/usr/bin/env python
def setup_args(parser):
import os
parser.add_argument("--key", help="Github key. Create one at"
" https://github.com/settings/applications under"
" 'Personal API Access Tokens'.")
parser.add_argument("--user", help="Username that the key belongs to")
parser.add_argument("--directory", help="Directory for repos and apicache")
class love(int):
"""
More heartfelt replacement for bool
"""
def __nonzero__(self):
return self <3
def __new__(cls, other):
x = int(other)
if x == 3: