Skip to content

Instantly share code, notes, and snippets.

View lost-theory's full-sized avatar

Steven Kryskalla lost-theory

View GitHub Profile
@lost-theory
lost-theory / dog_reader.py
Created February 18, 2014 19:53
dogpile.cache
'''
Starting a reader while a few dog_writer.py processes are running in the background:
$ bin/python dog_reader.py
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ???
??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 190 172 159 ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? 732 ???
??? ??? ??? ??? ??? 190 ??? ??? ??? ??? 190 172 190 ??? ??? ??? 172 ??? ??? 732 ??? ??? ??? ??? ??? ??? ??? ??? 732 159
??? 172 ??? ??? 159 172 ??? ??? ??? ??? 190 172 190 ??? ??? ??? 172 159 ??? 732 ??? ??? ??? 172 732 ??? ??? 732 732 159
172 172 ??? ??? 159 172 ??? ??? 172 ??? 190 172 190 159 ??? ??? 172 159 ??? 732 ??? ??? ??? 732 732 ??? 172 732 732 159
172 732 ??? ??? 159 172 ??? ??? 172 ??? 190 172 190 159 159 ??? 172 732 ??? 732 ??? ??? ??? 190 732 732 172 732 732 159
@lost-theory
lost-theory / rq_custom_scheduler.py
Last active August 29, 2015 14:08
subclassing rq_scheduler.Scheduler for https://github.com/ui/rq-scheduler/pull/43
from datetime import datetime
import logging
logging.basicConfig(level=logging.DEBUG)
from redis import Redis
from rq_scheduler import Scheduler
from rq_scheduler.utils import to_unix
class CustomRQScheduler(Scheduler):
>>> orange_vit_c = "78 mg, 130%"
>>> orange_vit_c = (78, 130) #mg, %
>>> tablet_vit_c = (250, 416)
>>> 250/78.0
3.2051282051282053
>>> 416/130.
3.2
>>> drink_vit_c = (None, 1500)
>>> rda_vit_c = (90, 100)
>>> #i've eaten 1500 + (416*3) percentage points of Vitamin C
@lost-theory
lost-theory / keybase.md
Created December 15, 2014 09:57
github identity proof for keybase.io

Keybase proof

I hereby claim:

  • I am lost-theory on github.
  • I am stevek (https://keybase.io/stevek) on keybase.
  • I have a public key whose fingerprint is 5393 7141 0A78 7E8A C2B2 6FBC C662 4F35 8456 52AB

To claim this, I am signing this object:

@lost-theory
lost-theory / minimal.sh
Created July 24, 2015 21:04
minimal python package
$ find . -type f -name "*.py"
./setup.py
./mypkg/__init__.py
./mypkg/config.py
./mypkg/shapes/__init__.py
./mypkg/shapes/square.py
$ find . -type f -name "*.py" | xargs head -n999
==> ./setup.py <==
from setuptools import setup, find_packages
'''
http://stackoverflow.com/questions/31632461/can-mechanize-support-ajax-filling-out-forms-via-javascript/
'''
import urllib.parse, urllib.request
URL = "https://interactive.web.insurance.ca.gov/survey/survey?type=homeownerSurvey&event=HOMEOWNERS"
LOCATIONS = '''
ALAMEDA ALAMEDA
import os
from fnmatch import fnmatch
def find(pat, root):
for path, dirs, files in os.walk(root):
for f in files:
if fnmatch(f, pat):
yield os.path.join(path, f)
if __name__ == "__main__":
@lost-theory
lost-theory / enqueue.py
Created April 8, 2011 22:08
pyres: defining a class and enqueueing it from the same file
class Adder(object):
queue = "Adder"
@staticmethod
def perform(a, b):
return a+b
if __name__ == "__main__":
import random
from pyres import ResQ
@lost-theory
lost-theory / gist:1592662
Created January 11, 2012 02:46
git-branched
#!/usr/bin/env python
"""
git-branched - show metadata about where a branch came from (and optionally,
what commits were on the branch)
Based on the method here:
http://stackoverflow.com/a/4991675/75956
Some examples:
#!/usr/bin/env python
"""
Command line tool for showing the result of a simple python expression.
Some common modules are imported for you (e.g. math, datetime, pprint, etc.).
Exceptions are caught and printed, instead of showing a full traceback.
Examples:
$ py "2+2"