I hereby claim:
- I am thatdatabaseguy on github.
- I am albarrentine (https://keybase.io/albarrentine) on keybase.
- I have a public key whose fingerprint is 1161 3CA5 F450 D731 F502 A2C3 7479 17BB 69EE EBB1
To claim this, I am signing this object:
set -e | |
if [ "$#" -lt 3 ]; then | |
echo "Usage: chunked_shuffle filename parts outfile" | |
exit 1 | |
fi | |
filename=$1 | |
parts=$2 | |
outfile=$3 |
#!/usr/bin/env bash | |
./libpostal "12 Three-hundred and forty-fifth ave, ste. no 678" en | |
#12 345th avenue, suite number 678 | |
./libpostal "C/ ocho P.I. cuatro" es | |
#calle 8 polígono industrial 4 | |
./libpostal "V XX Settembre" it | |
#via 20 settembre |
# Pre-requisites: steps provided for Mac and Debian/Ubuntu | |
# 1. Install autotools if you don't have it already | |
# Mac: brew install autoconf automake libtool | |
# Ubuntu: apt-get install autotools-dev | |
# 2. Install snappy | |
# Mac: brew install snappy | |
# Ubuntu: apt-get install libsnappy-dev) | |
git clone https://github.com/openvenues/libpostal | |
cd libpostal |
I hereby claim:
To claim this, I am signing this object:
# Even more fun | |
def array_gen(some_strings): | |
for s in some_strings: | |
yield numpy.fromstring(s, dtype=numpy.int) | |
# Let's say I know the length of all the arrays coming out of my generator | |
# and I want to build a matrix | |
K = 10 | |
M = 5 |
import numpy | |
# Imagine these come from a db cursor or something | |
coordinates = [(1,2,3), (4,5,6), (7,8,9)] | |
def my_gen(some_tuple): | |
for x, y, z in some_tuple: | |
yield x, y, z | |
a = numpy.fromiter(my_gen(coordinates), dtype=[('x', 'l'), ('y', 'l'), ('z', 'l')]) | |
""" |
import numpy | |
a = numpy.arange(10) | |
b = numpy.arange(5, 15) | |
numpy.setdiff1d(a,b) # array([0, 1, 2, 3, 4]) | |
numpy.union1d(a,b) # array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) | |
numpy.intersect1d(a,b) # array([5, 6, 7, 8, 9]) |
# In myapp.tasks __init__.py | |
from celery import Celery | |
celery = Celery() | |
Task = celery.create_task_cls() | |
class MyBaseTask(Task): | |
abstract = True | |
# ... |
""" | |
Assuming a model and table "Thingy" with columns type and id (I love generic association tables, | |
so you will see this a lot in schemas I write). | |
While this seems like a headache for multigets, there is a very easy way to do an IN operation on such a table using SQL tuples (index obviously needs to be on both columns for it to be fast): | |
SELECT * FROM thingy WHERE (type, id) IN (('foo', 1), ('bar', 2)); | |
And SQLAlchemy has a great construct for just this case... | |
""" |
class webhelpers.misc.NotGiven | |
A default value for function args. | |
Use this when you need to distinguish between None and no value. | |
Example: | |
>>> def foo(arg=NotGiven): | |
... print arg is NotGiven | |
... |