Skip to content

Instantly share code, notes, and snippets.

View eykd's full-sized avatar

David Eyk eykd

View GitHub Profile
@eykd
eykd / esv_ranges.py
Created February 24, 2011 14:14
Data structure defining the number of verses in every chapter of every book of the ESV bible.
# list of books, padded with None to be 1-indexed
# each book is a tuple with name of book, # of chapters, [number of verses in each chapter]
# the list with the number of verses per chapter is padded to make it 1-indexed
passage_data = [None,
('Genesis', 50, [None, 31, 25, 24, 26, 32, 22, 24, 22, 29, 32, 32, 20, 18, 24, 21, 16, 27, 33, 38, 18, 34, 24, 20, 67, 34, 35,
46, 22, 35, 43, 55, 32, 20, 31, 29, 43, 36, 30, 23, 23, 57, 38, 34, 34, 28, 34, 31, 22, 33, 26]),
('Exodus', 40, [None, 22, 25, 22, 31, 23, 30, 25, 32, 35, 29, 10, 51, 22, 31, 27, 36, 16, 27, 25, 26, 36, 31, 33, 18, 40, 37, 21,
43, 46, 38, 18, 35, 23, 35, 35, 38, 29, 31, 43, 38]),
('Leviticus', 27, [None, 17, 16, 17, 35, 19, 30, 38, 36, 24, 20, 47, 8, 59, 57, 33, 34, 16, 30, 37, 27, 24, 33, 44, 23, 55, 46, 34]),
('Numbers', 36, [None, 54, 34, 51, 49, 31, 27, 89, 26, 23, 36, 35, 16, 33, 45, 41, 50, 13, 32, 22, 29, 35, 41, 30, 25, 18, 65,
@eykd
eykd / python_evolution.py
Created January 20, 2011 21:18
Profiling the factorial implementations at http://metaleks.net/programming/the-evolution-of-a-python-programmer/comment-page-1 with results for factorial(10) run 100,000 times.
# -*- coding: utf-8 -*-
"""Profiling The Evolution of the Python Programmer
Based on the code offered in good humor at
<http://metaleks.net/programming/the-evolution-of-a-python-programmer>.
I thought it would be fun to profile the various approaches to a
factorial implementation offered by Aleks. My attempt below.
I couldn't profile the EXPERT PROGRAMMERS or the Unix Programmer, as I
@eykd
eykd / output
Created July 31, 2013 21:59
Python Serialization: Comparing the performance of msgpack, cPickle, and marshal.
In [33]: msgpack_lt, pickle_lt, marshal_lt
Out[33]: (0.004015207290649414, 0.039834022521972656, 0.007205963134765625)
In [34]: msgpack_dt, pickle_dt, marshal_dt
Out[34]: (0.015387773513793945, 0.04079103469848633, 0.006851911544799805)
In [35]: len(s_msgpack), len(s_pickle), len(s_marshal)
Out[35]: (16, 48, 41)
@eykd
eykd / .gitignore
Created January 19, 2012 04:37
Full stack BDD testing with Behave+Mechanize+Django
*.pyc
bin/
include/
lib/
### Keybase proof
I hereby claim:
* I am eykd on github.
* I am eykd (https://keybase.io/eykd) on keybase.
* I have a public key ASCtPxBeTQqK-TZwsV225mEtCNQO1VwTa01NGBf2aS8XoAo
To claim this, I am signing this object:
@eykd
eykd / nginx_error_rate.py
Created July 26, 2011 15:44
Munin plugin for displaying error rates from Nginx
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""nginx_error_rate -- Munin plugin to report the error rate in an access log.
The access log defaults to `/var/log/nginx/access.log`. This may be
customized with the following stanza in your munin plugin conf:
[nginx_error_rate]
env.access_log /path/to/access.log
"""
$ echo 'hello world' >> /mnt/repo/helloworld.txt
$ cat /mnt/repo/helloworld.txt
$ echo 'hello world' >> /mnt/repo/helloworld.txt
$ cat /mnt/repo/helloworld.txt
hello world
$ cat /mnt/repo/helloworld.txt
hello world
$ cat /mnt/repo/helloworld.txt
hello world
$ echo 'hello world' >> /mnt/repo/test.txt
@eykd
eykd / .gitignore
Last active December 13, 2017 00:19
Demonstrating weird behavior in git.latest
.vagrant
@eykd
eykd / comp_scope_bug.py
Created October 11, 2016 21:36
Demonstrating what appears to be a scoping bug in Python 3.5.1
from __future__ import print_function
foo = 'bar'
# This works
[foo for _ in range(5)]
# This also works:
class Foo:
import logging
import random
logger = logging.getLogger('mylib.query')
def query_predicates(query, predicates):
matches = []
qkeys = set()
for rkey, predicate in predicates: