Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
### MATPLOTLIBRC FORMAT | |
# This is a sample matplotlib configuration file - you can find a copy | |
# of it on your system in | |
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it | |
# there, please note that it will be overridden in your next install. | |
# If you want to keep a permanent local copy that will not be | |
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux | |
# like systems) and C:\Documents and Settings\yourname\.matplotlib | |
# (win32 systems). |
// TileMill provider for Unfolding (or modestmaps-processing?) | |
// requires Unfolding (http://unfoldingmaps.org/) and GLGraphics (http://glgraphics.sourceforge.net/) | |
// this is important. weird. | |
import processing.opengl.*; | |
import codeanticode.glgraphics.*; | |
import de.fhpotsdam.unfolding.core.*; | |
import de.fhpotsdam.unfolding.geo.*; | |
import de.fhpotsdam.unfolding.utils.*; |
void drawPath(float lat1, float lon1, float lat2, float lon2) { | |
stroke(0); | |
strokeWeight(5); | |
noFill(); | |
lat1 *= PI/180; | |
lon1 *= PI/180; | |
lat2 *= PI/180; | |
lon2 *= PI/180; | |
This example expects to have d3.min.js and d3.layout.min.js in the same directory as pie.js and pie_serv.js. | |
Run with node pie_serv.js |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
This is a quick attempt at writing a ball tree for nearest neighbor searches using numba. I've included a pure python version, and a version with numba jit decorators. Because class support in numba is not yet complete, all the code is factored out to stand-alone functions in the numba version. The resulting code produced by numba is about ~10 times slower than the cython ball tree in scikit-learn. My guess is that part of this stems from lack of inlining in numba, while the rest is due to some sort of overhead
#!/bin/bash | |
# usage: export_to_csv.sh <database.sqlite> | |
sqlite3 $1 "SELECT tbl_name FROM sqlite_master WHERE type='table' and tbl_name not like 'sqlite_%';" | while read table; do | |
echo $table | |
sqlite3 $1 <<! | |
.headers on |
# make sure to replace `<hash>` with your gist's hash
git clone https://gist.github.com/<hash>.git # with https
git clone git@gist.github.com:<hash>.git # or with ssh
# https://stackoverflow.com/questions/9245638/select-random-lines-from-a-file | |
cat /usr/share/dict/words | sort -R | head -10 $lines | |
# faster | |
gshuf -n 10 /usr/share/dict/words |