Skip to content

Instantly share code, notes, and snippets.

@josephkern
josephkern / bloom.py
Created June 8, 2012 19:04
A Simple Bloom Filter in Python
#!/usr/bin/env python
"""A simple Bloom Filter implementation
Calculating optimal filter size:
Where:
m is: self.bitcount (how many bits in self.filter)
n is: the number of expected values added to self.filter
k is: the number of hashes being produced
(1 - math.exp(-float(k * n) / m)) ** k
http://en.wikipedia.org/wiki/Bloom_filter
"""
anonymous
anonymous / ep1.py
Created December 12, 2011 00:48
Euler Project 1
#!/usr/bin/python
# Find the sum of all the multiples of 3 or 5 below 1000.
import unittest
from multiprocessing import Pool
class main_test(unittest.TestCase):
def test_multisum(self):
self.assertEqual(multisum(3, 10), 18) # 3,6,9
@turicas
turicas / example_image_utils.py
Created December 10, 2011 19:04
Layer on top of Python Imaging Library (PIL) to write text in images easily
#!/usr/bin/env python
# coding: utf-8
# You need PIL <http://www.pythonware.com/products/pil/> to run this script
# Download unifont.ttf from <http://unifoundry.com/unifont.html> (or use
# any TTF you have)
# Copyright 2011 Álvaro Justen [alvarojusten at gmail dot com]
# License: GPL <http://www.gnu.org/copyleft/gpl.html>
from image_utils import ImageText
@josephkern
josephkern / emacs-in-thirty-days-1.el
Created August 24, 2011 16:29
emacs-in-thirty-days-1
; Welcome to the first installment of emacs-command-a-day. Learning
; emacs can be hard as there are many commands and key-bindings that
; beginners find difficult. To help you make the transition to "the
; best text editor ever", I'll bring you one command each week day, so
; you can practice on your own at a reasonable pace.
;; Emacs Installation Notes
; I assume that you can start emacs. If you have no idea how, (on a
; mac or linux system) you should be able to open up a terminal and