View gist:2311175
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import wave, array | |
wi = wave.open('a.wav', 'rb') | |
wo = wave.open('a-reduced.wav', 'wb') | |
wo.setparams(wi.getparams()) | |
def process_start(frms): | |
delta, threshold = 50, 250 |
View gist:3368186
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
def debug(func, var): | |
print "Timing", func, | |
stmt = lambda: func(var) | |
tm = timeit.Timer(stmt=stmt) | |
res = tm.timeit(10000) | |
lst = stmt() | |
print "%1.10f" % (res*1000) |
View ccnumvalidate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original code: http://code.activestate.com/recipes/578202-credit-card-number-check/ | |
cc_patterns = { # '<cc_type>' : { dict of valid lengths : [list of associated prefixes] } | |
'amex' : { (15) : ('34', '37') }, | |
'carteblanche' : { (14) : ('300', '301', '302', '303', '304', '305', '36', '38') }, | |
'dinersclub' : { (14) : ('300', '301', '302', '303', '304', '305', '36', '38') }, | |
'discover' : { (16) : ('6011') }, | |
'enroute' : { (15) : ('2014', '2149') }, | |
'jcb' : { (15) : ('2131', '1800'), (16) : ('3') }, | |
'mastercard' : { (16) : ('51', '52', '53', '54', '55') }, |
View gist:8800421
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install btrfs-tools | |
sudo su | |
mkdir /data | |
cd /data | |
# create 500 MB file | |
dd if=/dev/zero of=/data/datadisk bs=1024 count=500000 | |
# create btrfs |
View zipfile2_bz2extended.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Read and write ZIP files. | |
""" | |
import struct, os, time, sys, shutil | |
import binascii, cStringIO, stat | |
import io | |
import re | |
import string, bz2 |