Skip to content

Instantly share code, notes, and snippets.

from annoy import AnnoyIndex
a = AnnoyIndex(3)
a.add_item(10, [1, 0, 0])
a.add_item(11, [0, 1, 0])
a.add_item(13, [0, 0, 1])
a.build(-1)
print a.get_nns_by_item(13, 10)
print a.get_nns_by_item(1, 10)
@herrbuerger
herrbuerger / _euclidean.c
Created June 1, 2014 19:28
Squared euclidean distance calculation (C extension for Python)
#include <Python.h>
#include <numpy/arrayobject.h>
#include "euclidean.h"
/* Docstrings */
static char module_docstring[] =
"This module provides an interface for calculating squared euclidean distance";
static char euclidean_docstring[] =
"Calculate the squared euclidean distance of two 128-dimensional vectors";
@herrbuerger
herrbuerger / postgres-cheatsheet.md
Created December 8, 2016 15:25 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

### Keybase proof
I hereby claim:
* I am herrbuerger on github.
* I am herrbuerger (https://keybase.io/herrbuerger) on keybase.
* I have a public key ASDehSwsfC_aKN2WUeEHyWdANSMW8ppk7RjIDs8tFXekTQo
To claim this, I am signing this object: