Skip to content

Instantly share code, notes, and snippets.

def say_hello():
print("Hello world from Cython!")
def build_book_inventory(book_ids, shops):
shop_labels = [shop['label'] for shop in shops]
book_list = Persistency.books_table.read(
shops=shop_labels,
books=book_ids)
inventory = {}
for book_item in book_list:
shop_label = book_item['shop_label']
cell_label = book_item['cell_label']
book_id = book_item['book_id']
@afroisalreadyinu
afroisalreadyinu / stashpy-config.yml
Created March 23, 2016 05:31
Rotating file handler config for stashpy
processor_spec:
to_dict:
- "My name is {name} and I'm {age:d} years old."
port: 8888
address : '0.0.0.0'
indexer_config:
host: localhost
port: 9200
import socket
import json
from tornado.testing import AsyncTestCase, gen_test
from tornadoes import ESConnection
from tornado.iostream import IOStream
from SampleService import MainHandler
class SampleServiceTests(AsyncTestCase):
function nukebranch () {
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [ $BRANCH == 'master' ]; then
echo "Refusing to delete master"
else
(git push origin --delete $BRANCH || true) && git checkout master && git branch -d $BRANCH
fi
}
@afroisalreadyinu
afroisalreadyinu / pq_examples.py
Created November 3, 2011 10:11
Product query examples
product = Product(color='red', size='small', weight='light')
pq = BasicProductQuery(color='red')
assert product in pq
assert product not in ~pq
SmallAndLight = BasicProductQuery(size='small') & BasicProductQuery(weight='light')
assert product in SmallAndLight
SmallAndLightOrNotRed = SmallAndLight | ~BasicProductQuery(color='red')
product2 = Product(size='big', color='blue', weight='heavy')
@afroisalreadyinu
afroisalreadyinu / products_and_queries.py
Created November 3, 2011 10:08
DSL for simple products and product descriptions
class Product(object):
def __init__(self, color, size, weight):
self.color, self.size, self.weight = color, size, weight
class CombinableQueryMixin(object):
def __and__(self, other):
return CompoundQuery(self, other, anded=True)