Skip to content

Instantly share code, notes, and snippets.

@jsundram
jsundram / random.sh
Created April 4, 2021 22:01
get a few random words from the osx dictionary file
# 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

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # 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
@snorfalorpagus
snorfalorpagus / export_to_csv.sh
Last active March 8, 2024 17:13
Simple conversion utility for Microsoft Access databases (.mdb) to SQLite3.
#!/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
@jakevdp
jakevdp / README.md
Last active September 30, 2023 13:25
Numba Ball Tree example

Numba Ball Tree

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

@hrldcpr
hrldcpr / tree.md
Last active April 26, 2024 08:53
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@mattbaker
mattbaker / README
Created December 22, 2011 06:02
SVG to PNG render with Node and D3.js
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
@cemre
cemre / greatcirclearc.java
Created October 22, 2011 22:36
Rendering great circle arcs in Processing between two coordinates
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;
@also
also / tilemill.pde
Created September 26, 2011 17:29
TileMill provider for Unfolding
// 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.*;
@huyng
huyng / matplotlibrc
Created February 8, 2011 15:50
my default matplotlib settings
### 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).