Skip to content

Instantly share code, notes, and snippets.

@binweg
binweg / weatherlogger.py
Created July 28, 2012 13:03
Request current weather from Yahoo's public weather API and append to a log
#!/usr/bin/env python3
from urllib.request import urlopen
from xml.dom.minidom import parseString
import os
"""
Request current weather from Yahoo's public weather API and append to a log
"""
# Where to put the log file?
desired_path = os.getenv("HOME") + '/weather.log'
# Temperature unit: c for Celsius, f for Fahrenheit
@binweg
binweg / gravitytrain.py
Created November 13, 2012 11:08
Gravity train time calculation
#!/usr/bin/env python3
"""
Calculate travel time for an object falling through a tunnel through the
earth's core, only driven by gravitation
"""
from scipy.integrate import odeint, quad
from scipy.interpolate import interp1d
from numpy import arange, linspace, where, sign, diff
import math
import matplotlib.pyplot as plt
@binweg
binweg / twitter_json.py
Created June 14, 2013 08:41
get list of tweets from twitter archive
import os
import json
from itertools import chain
tweets_path = 'data/js/tweets/'
json_files = [os.path.join(tweets_path, filename) for filename in os.listdir(tweets_path)]
def read_json(filename):
'''
For a given filename read the json and return a list of
@binweg
binweg / Europawahl.ipynb
Created May 24, 2014 20:44
Analyse der Wahl-O-Mat Antworten zur Europawahl 2014
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@binweg
binweg / plusses.pyde
Created June 28, 2014 11:25
Source code for plusses
DEBUG = False
max_frames = 135.
total_revs = 2
pw = 10 # width
pl = 40 # length
plus = None
def setup():
@binweg
binweg / traffic.pyde
Created July 3, 2014 14:01
Source code for traffic
DEBUG = True
max_frames = 80.
grid = 100
offset = 25
cent_width = 25
def setup():
size(400, 400)
if DEBUG:
@binweg
binweg / floor.pyde
Created July 11, 2014 11:04
Source code for floor
DEBUG = True
max_frames = 120.
tiles = []
def setup():
size(400, 400, P3D)
smooth(8)
if DEBUG:
frameRate(100 / 3)
@binweg
binweg / hilbert.pyde
Created July 19, 2014 10:39
Source code for hilbert
DEBUG = True
maxFrames = 100.
l = 60 # edge length
s = 1.1 # spacing
lim = None
def setup():
size(400, 400)
smooth(8)
@binweg
binweg / before_after.ipynb
Created May 2, 2018 21:23
Matplotlib Vorher/Nachher Plots
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@binweg
binweg / transfers.ipynb
Last active May 21, 2018 09:54
Interplanetary Transfers from Kerbin's Moons
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.