Skip to content

Instantly share code, notes, and snippets.

@dimsmol
dimsmol / enum.py
Created May 14, 2010 19:28
Enum implementation example
class Unset(object):
pass
class Item(object):
_cnt = 0
def __init__(self, value=Unset, choice=Unset):
self.key = None
self.value = value
self.choice = choice
@sampsyo
sampsyo / multijson.py
Created April 14, 2011 18:59
quick & dirty reading/writing of files containing multiple JSON objects
"""A couple of very simple utilities for reading and writing files
that contain multiple JSON values. Could be useful in situations where
you're generating a bunch of data for later processing and then, later,
you want to read it in an element at a time.
The json module doesn't really support streaming reads, though, so this
is limited by that. If you need real streaming, you probably want to use
something like ijson:
http://pypi.python.org/pypi/ijson/
"""
@karpathy
karpathy / gist:587454dc0146a6ae21fc
Last active July 11, 2024 10:36
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@Alir3z4
Alir3z4 / xapian-virtualenv.sh
Last active September 29, 2021 16:46
install xapian inside virtualenv
#!/usr/bin/env bash
pkgver=1.2.21
mkdir -p $VIRTUAL_ENV/src && cd $VIRTUAL_ENV/src
curl -O http://oligarchy.co.uk/xapian/$pkgver/xapian-core-$pkgver.tar.xz && tar xf xapian-core-$pkgver.tar.xz
curl -O http://oligarchy.co.uk/xapian/$pkgver/xapian-bindings-$pkgver.tar.xz && tar xf xapian-bindings-$pkgver.tar.xz
cd $VIRTUAL_ENV/src/xapian-core-$pkgver