View croniter.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
from croniter import croniter as ci | |
import os | |
from datetime import datetime as dt | |
from time import time | |
from itertools import takewhile | |
from functools import reduce | |
from os import walk | |
before = 3600.0 | |
after = 3600.0 | |
import re |
View pb.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
def ift(p, vt, vf): | |
return lambda val: (ift(*vt)(val) if isinstance(vt, tuple) else vt) \ | |
if p(val) else (ift(*vf)(val) if isinstance(vf, tuple) else vf) | |
compile = lambda f: sum([ int(bool(f(x)))<<x for x in range(0, 256) ] ) | |
interpret = lambda code: lambda val: int((1<<(val))&code != 0) | |
code_by3=compile( lambda x: (x%3)==0) | |
print bin(code_by3) | |
evaluate=interpret(code_by3) | |
sign = ift(lambda x:x>0, 1, (lambda y: y==0, 0, (lambda z:z<0, -1, 1))) |
View turing.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
def ift(p, vt, vf): | |
return lambda val: (ift(*vt)(val) if isinstance(vt, tuple) else vt) \ | |
if p(val) else (ift(*vf)(val) if isinstance(vf, tuple) else vf) | |
compile_nbit = lambda nbit: lambda f: sum([int(bool(f(x)))<<x for x in range(0, nbit)]) | |
compile = compile_nbit(256) | |
interpret = lambda code: lambda val: int((1<<(val))&code != 0) | |
code_by3 = compile(lambda x: (x%3)==0) | |
code_by2 = compile(lambda x: (x%2)==0) |
View version.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
"""Given a string of three comma separated values X.Y.Z | |
where | |
X = API change | |
Y = improvement | |
Z = bugfix | |
and where X, Y, Z is in the form figures followed by letters | |
where figures should be compared as decimal int and letters ... as letters | |
by convention letters are ascii lower case alphabet letters. | |
""" | |
import re |
View aval.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
#!/usr/bin/env python | |
def aval(xstr): | |
""" eval a string with all builtins from the interpreter forbidden & no | |
globals""" | |
print "".join(["*" * 20, "<", xstr, ">", "*" * 20]) | |
try: | |
print "'safe' EVAL" | |
print eval( xstr,{'__builtins__':{}},{}) | |
except Exception as e: | |
print "!%s not usable %r" % (xstr,e) |
View takens.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
import matplotlib.pyplot as plt | |
import numpy as np | |
from mpl_toolkits.mplot3d import Axes3D | |
from matplotlib.finance import quotes_historical_yahoo_ohlc | |
from random import randint | |
import matplotlib.cm as cmx | |
import matplotlib.colors as colors | |
date1 = (2013, 2, 1) | |
date2 = (2015, 7, 12) | |
quotes = quotes_historical_yahoo_ohlc('GE', date1, date2) |
View python_makes_me_sexy.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
#!/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))) |
View query.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
!/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 |
View Liz.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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Copyright (c) Twisted Matrix Laboratories. | |
# See LICENSE for details. | |
""" | |
Twisted original example of an irc bot. |
View bench_fsd.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
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__) |
OlderNewer