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
from pylab import * | |
_value=[ 26.190, 26.964, 27.504, 27.692, 29.121, 30.657, 79.694] | |
_title=['dict +nc','dict' , 'repoze', 'fixed', 'repoze - mono', 'beaker', 'nocache' ] | |
figure(1) | |
lim=7 | |
pos = arange(len(_value[:lim]))+.5 | |
xticks(pos,_title[:lim]) | |
ylabel("execution time (seconds)") | |
title("Impact of different caches on parsing 193114 lines with yahi") | |
rect=bar(pos,_value[:lim],align='center',width=.8) |
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
from repoze.lru import LRUCache, _MARKER | |
from repoze.lru import ExpiringLRUCache,lru_cache,_DEFAULT_TIMEOUT | |
"""A (decorator) cache maker for lru.repoze so you can clear | |
your cache if needed""" | |
class CacheMaker(): | |
def __init__(self,default={}): | |
self._maxsize=default.get("maxsize",_MARKER) | |
self._time_out=default.get("time_out",_DEFAULT_TIMEOUT) |
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
from scikits.audiolab import Sndfile | |
import numpy as np | |
import pylab as plt | |
from numpy import fft | |
koln=Sndfile("test.wav") | |
sample=koln.read_frames(18300000) | |
plt.specgram(sample[:,1]) | |
plt.show() |
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
from scikits.audiolab import Sndfile | |
import numpy as np | |
import pylab as plt | |
import csv | |
import matplotlib.mlab as mlab | |
from math import floor, log | |
#NFFT windows make calculus faster if a power of 2 | |
closest_2_power=lambda x : 1<<int(floor(log(x,2))) | |
def load_freq(fn="freq.csv"): |
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
#!/usr/bin/perl | |
sub a_p_p { | |
($x,$n)=@_; | |
return ($x>>$n)%2 && a_p_p($x^(1<<$n),a_p_p($n)) || $x|($x^(1<<$n)) | |
} | |
a_p_p($A) |
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
q = 0 or """ #=;$A=41;sub A { ~-$A+2}; A() && q' """ | |
A=lambda A: -~A #'; | |
print A(41) # python + perl = <3 |
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
from flask import Flask, flash, redirect, url_for | |
from flask import render_template, safe_join | |
from flask import Markup | |
from patch import Proxied | |
import os | |
_cdir="content" | |
conf={ | |
'_cdir' : "content" | |
} |
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
#!/usr/bin/env python | |
# -*- coding: utf8 -*- | |
class decorate(object): | |
def __init__(self,name="must have key",hook=None, api_hook=None,): | |
self.hook=hook | |
self.name=name | |
self.api_hook=api_hook | |
def __call__(self,*pos,**named): |
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 sys | |
from time import clock | |
from random import randint as rand | |
from math import sqrt | |
sample = [ rand(0,(1<<16) - 1 ) for i in range(0,10000000 ) ] | |
fsample=map(lambda x : .0001 *x, sample) | |
def time_me(sample, tag,op): | |
start=clock() |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import matplotlib.pyplot as plt | |
from scipy.signal import medfilt | |
import numpy as np | |
NOISE_AMPLITUDE = 4.0 | |
PERIOD = 200 | |
PRESENCE_PROBABILITY = .4 |