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 | |
me = "freaky" | |
print "before I was %s" % me | |
from re import compile as cum | |
twist = lambda x : str(x).encode("rot-13") | |
D = 8 | |
print "I was always thinking of s%sx" % chr(int( "".join(reduce( lambda x : x+y , cum("(.)(.)").findall("69") )))) | |
print "coding transformed me the following way" | |
print "I became %s" % (8==D and twist(cum( "(.)(.).(y)").sub( twist("x") + 'v' + twist(chr(69)) + chr(69), me))) |
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: utf-8 -*- | |
""" | |
mixed query on stat file | |
""" | |
from os import environ, path | |
from json import load | |
import datetime as dt |
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: utf-8 -*- | |
# Copyright (c) Twisted Matrix Laboratories. | |
# See LICENSE for details. | |
""" | |
Twisted original example of an irc bot. |
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 yahi.fixed_size_dict import * | |
from time import time | |
sample=1000000 | |
def time_for(size, constructor): | |
if constructor==dict: | |
a=dict() | |
else: | |
a=constructor(size) | |
print "size %d" % size | |
print "fact %s" % repr(constructor.__name__) |
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 |
OlderNewer