Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
#!/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 | |
""" |
class classproperty(property): | |
def __get__(self, cls, inst): | |
return self.fget.__get__(None, inst)() | |
class MyClass(object): | |
numbers = [1,2,3,4,5] |
from sys import version_info | |
assert version_info.major == 3 and version_info.minor >= 3, \ | |
'requires PEP 362; Python 3.3 or later; python.org/dev/peps/pep-0362/' | |
from inspect import signature | |
class memoise(dict): | |
def __init__(self, func): | |
self.func, self.signature = func, signature(func) | |
def __missing__(self, key): | |
args, kwargs = key |
# Install ARCH Linux with encrypted file-system and UEFI | |
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description. | |
# Download the archiso image from https://www.archlinux.org/ | |
# Copy to a usb-drive | |
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux | |
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration. | |
# Set swedish keymap |
"""Routines that examine the internals of a CPython dictionary using python 3.3.""" | |
from ctypes import Structure, c_ulong, POINTER, cast, py_object, CFUNCTYPE, pointer, c_ssize_t, c_void_p | |
#from math import log | |
UMAX = 2 ** 32 | |
def cbin(n): | |
"""Return `n` as a clean 32-bit binary number, without a leading '0b'.""" |