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
cdict={'red': ((0.0, 0.0, 0.15), | |
(0.25, 0.15, 0.48), | |
(0.50, 0.48, 0.139), | |
(0.75, 0.139, 0.155), | |
(1.00, 0.155, 0.155)), | |
'green': ((0.0, 0.0, 0.56), | |
(0.25, 0.56, 0.98), | |
(0.50, 0.98, 0.172), | |
(0.75, 0.172, 0.188), |
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 functools import wraps | |
conv={"int":int, "str":str, "bool":bool} | |
def arguments_as(typechoice): | |
def decorator(f): | |
@wraps(f) | |
def func_wrapper(*args, **kwargs): | |
return f(*[conv[typechoice](i) for i in args], **kwargs) |
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 | |
""" | |
Searches for a string inside text files | |
use: search.py <term> <file> | |
""" | |
import os, sys | |
def process(name,term): |
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 encode(string): | |
counter=1 | |
previous=out="" | |
for ind,i in enumerate(string): | |
if i==previous: counter+=1; previous=i | |
if ind+1==len(string) or i!=previous: | |
if counter>2: | |
if ind+1==len(string): out+="%i%s"%(counter,i) | |
else: out+="%i%s"%(counter,previous) | |
else: |
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 | |
import os,time | |
if __name__=="__main__": | |
print "Get ready!" | |
for i in range(3,0,-1): | |
print "%i..."%i, | |
time.sleep(1) | |
# Quarter stuff |
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 | |
import json,subprocess,urllib2 | |
jsonshit=json.loads(urllib2.urlopen("http://developer.echonest.com/api/v4/song/search?bucket=id:spotify&bucket=tracks&results=100&api_key=MZFEPELDSKFX4WAMA&artist=%s&title=%s"%(raw_input("group? ",),raw_input("title? ",))).read()) | |
print jsonshit["response"]["songs"][0]["artist_name"],jsonshit["response"]["songs"][0]["title"] | |
processeddata=json.loads(urllib2.urlopen("https://api.spotify.com/v1/tracks/"+jsonshit["response"]["songs"][0]["tracks"][0]["foreign_id"].split(':')[2]).read()) | |
subprocess.call(["vlc", processeddata["preview_url"]]) |
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 | |
import json,urllib2 | |
jsonshit=json.loads(urllib2.urlopen("http://developer.echonest.com/api/v4/song/search?results=100&api_key=MZFEPELDSKFX4WAMA&artist=%s"%raw_input("group? ",)).read()) | |
for x in jsonshit["response"]["songs"]: print "%s - %s"%(x["artist_name"],x["title"]) |
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
number=1234567890 | |
while 1: | |
if number%12==number%11==number%10==number%9==number%8==number%7==0 and set(list(str(number)))==set([str(a) for a in range(10)]):break | |
else: number+=10 | |
print number |
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 | |
import sys | |
try: | |
price=int(sys.argv[1]) | |
tax={"A":21,"B":10,"C":4}[sys.argv[2]] | |
transp=(price*int(sys.argv[3]))/100 | |
totvar=price+((price+transp)*tax/100) | |
print "Base price: %i + %i%% VAT + %i%% transport = %i" %(price,tax,transp,totvar) | |
except: |
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 bash | |
import os,random | |
if __name__=="__main__": | |
os.system('clear') | |
bullets=["O","O","O","O","O","O"] | |
bullets[random.randrange(6)]="X" | |
raw_input("? ? ? ? ? ?\nGo ahead!") | |
for i in range(6): | |
os.system('clear') |
NewerOlder