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
xs = [ float(i)/64.0 for i in range(-150, 41) ] | |
ys = [ float(i)/16.0 for i in range(-25,26) ] | |
for y in ys: | |
s = '' | |
for x in xs: | |
z = 0j; i = 0 | |
while i < 10: | |
z = z**2 + x+y*1j | |
if abs(z) > 2: | |
break # Get out of inner loop |
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
# wget http://neuro.imm.dtu.dk/services/bredewiki/download/bredewiki-templates.sqlite3 | |
import matplotlib.pyplot as plt | |
import networkx as nx | |
from pysqlite2 import dbapi2 | |
connection = dbapi2.Connection('bredewiki-templates.sqlite3') | |
sql = "SELECT DISTINCT tid FROM brede WHERE (template='paper' OR template='conference_paper');" | |
cursor = connection.cursor() | |
cursor.execute(sql) | |
tids = [ row[0] for row in cursor.fetchall() ] |
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 urllib, urllib2 | |
import simplejson as json | |
import dateutil.parser | |
import datetime | |
import matplotlib.dates | |
import matplotlib.finance | |
from matplotlib import pyplot as plt | |
import nltk.corpus | |
import numpy as np | |
import re |
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 | |
import math, sys # Importing modules. | |
def formatresult(res): # Define function. Remember colon! | |
"""This is the documentation for a function.""" | |
return "The result is %f" % res # Percentage for formating | |
if len(sys.argv) < 3: # Conditionals should be indended | |
print("Too few input argument") |
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
# 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' |
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 simplejson, urllib # To get posts from Twitter | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib import cm # Colormap | |
import scipy.stats # For kernel density estimation | |
# Get geo-tagged posts from Twitter | |
url = 'http://search.twitter.com/search?q=geotag&format=json&rpp=100' | |
resp = simplejson.load(urllib.urlopen(url)) | |
coords = np.asarray([ t['geo']['coordinates'][::-1] |
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 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 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 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 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 |