This file contains hidden or 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 | |
# | |
# (originally entered at https://gist.github.com/1035399) | |
# | |
# License: GPLv3 | |
# | |
# To download the AFINN word list do: | |
# wget http://www2.imm.dtu.dk/pubdb/views/edoc_download.php/6010/zip/imm6010.zip | |
# unzip imm6010.zip | |
# |
This file contains hidden or 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 shelve | |
import multiprocessing | |
import os | |
filename = "tmp.shelve" | |
N = 4 | |
end = 10000 | |
def insert((offset, jump, end, filename)): |
This file contains hidden or 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
######### | |
# Tornado | |
wget https://raw.github.com/facebook/tornado/master/demos/helloworld/helloworld.py | |
python helloworld.py | |
# 100 concurrent | |
ab -c 100 -n 1000 -k localhost.localdomain:8888/ | grep "Time taken for tests:" | |
# Time taken for tests: 0.709 seconds | |
# 5 concurrent |
This file contains hidden or 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
# http://docs.cherrypy.org/stable/concepts/basics.html | |
import cherrypy | |
class HelloWorld: | |
def index(self): | |
return "Hello world!" | |
index.exposed = True | |
cherrypy.quickstart(HelloWorld()) |
This file contains hidden or 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 Tkinter import * | |
root = Tk() | |
canvas = Canvas(root, width=400, height=200) | |
canvas.pack() | |
canvas.create_oval(10, 10, 110, 60, fill="grey") | |
canvas.create_text(60, 35, text="Oval") | |
canvas.create_rectangle(10, 100, 110, 150, outline="blue") | |
canvas.create_text(60, 125, text="Rectangle") | |
canvas.create_line(60, 60, 60, 100, width=3) |
This file contains hidden or 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 Tkinter import * | |
def hello(): | |
"""Callback function for button press.""" | |
print "Hello World" | |
# Main root window | |
root = Tk() | |
# A button with a callback function |
This file contains hidden or 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 htmllib, formatter, urllib, urlparse | |
k = 1 | |
urls = {} | |
todownload = set(['http://www.dtu.dk']) | |
while todownload: | |
url0 = todownload.pop() | |
urls[url0] = set() | |
try: | |
p = htmllib.HTMLParser(formatter.NullFormatter()) |
This file contains hidden or 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 * | |
from urllib2 import urlopen | |
from simplejson import load | |
from re import findall | |
url = 'http://neuro.imm.dtu.dk/w/api.php?' + \ | |
'action=query&list=blocks&' + \ | |
'bkprop=id|user|by|timestamp|expiry|reason|range|flags&' + \ | |
'bklimit=500&format=json' | |
data = load(urlopen(url)) |
This file contains hidden or 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 matplotlib.finance import quotes_historical_yahoo | |
from matplotlib.dates import num2date | |
from matplotlib.pyplot import * | |
from datetime import date | |
quotes = quotes_historical_yahoo('NVO', date(2011, 1, 1), date.today()) | |
dates = [ num2date(row[0]) for row in quotes ] | |
closeprice = [ row[1] for row in quotes ] | |
plot(dates, closeprice) | |
show() |
This file contains hidden or 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
# Modified Step1 Cone1.py from VTK examples by W. Schroeder (2006) Visualization... | |
import vtk, time | |
cone = vtk.vtkConeSource() # Cone graphical object | |
coneMapper = vtk.vtkPolyDataMapper() # 'Mapper' | |
coneMapper.SetInputConnection(cone.GetOutputPort()) | |
coneActor = vtk.vtkActor() # 'Actor' | |
coneActor.SetMapper(coneMapper) | |
ren1= vtk.vtkRenderer() # 'Renderer' |