Skip to content

Instantly share code, notes, and snippets.

View Tafkas's full-sized avatar

Christian Stade-Schuldt Tafkas

View GitHub Profile
@Tafkas
Tafkas / sun_flight_map.R
Created May 20, 2014 14:00
Plot sun elevations along a flight path.
# sun_flight_map.R
#
# Plot sun elevations along a flight path.
#
# Airport information can be sourced from http://openflights.org/data.html.
# Note that the time zone offsets provided in their airports.dat never count
# daylight savings time.
#
# This code is for fun only, so it comes with no guarantee of accuracy and
# is not to be used for any serious purpose including making any decisions
@Tafkas
Tafkas / collect_weather.py
Created July 28, 2014 21:44
Fetch current weather from openweathermap api and save it to a sqlite database
import sqlite3
import json
import urllib
import datetime
import calendar
WEATHER_DATA_URL = 'http://api.openweathermap.org/data/2.5/weather?q=Berlin,de&units=metric'
DB_PATH = ''
def get_data():
@Tafkas
Tafkas / pysml.py
Last active August 29, 2015 14:08
Script to read SML data packages from a residential meter
#!/usr/bin/env python
# encoding: utf-8
"""
pysml.py
Created by Christian Stade-Schuldt on 2014-10-25.
"""
import sys
import os
import datetime
@Tafkas
Tafkas / codebase_munin.py
Last active November 24, 2015 16:00
A munin plugin for Linux to monitor Codebase ticket progress
#!/usr/bin/env python
"""
codebase_munin - A munin plugin for Linux to monitor Codebase ticket progress
Copyright (C) 2015 Christian Stade-Schuldt
Author: Christian Stade-Schuldt
Like Munin, this plugin is licensed under the GNU GPL v2 license
http://www.opensource.org/licenses/GPL-2.0
Add the following section to your munin-node's plugin configuration:
[codebase_*]
@Tafkas
Tafkas / fitbit_stride_regression.R
Created December 19, 2014 22:59
Fitbit Stride Length Linear Regression
runs <- read.csv("myrunninglog.csv", header=T, sep=",")
#convert date
runs$Date <- strptime(as.character(runs$Date), format="%Y-%m-%d")
#convert distance from km to meters
runs$Distance <- 1000 * runs$Distance
ggplotRegression <- function (fit) {
@Tafkas
Tafkas / berlin_marathon_2014_participants.R
Created November 13, 2013 12:48
Distribution of Birth Year and Top 10 Participating Nations in Berlin Marathon 2014
Distribution of Birth Year and Top 10 Participating Nations in Berlin Marathon 2014
setwd("~/")
bm <- read.csv("BerlinMarathon2014.csv", header=T)
library(ggplot2)
p <- ggplot(bm, aes(birth_date, ..density..))
p <- p + geom_histogram(binwidth=1, colour = "black", fill = "lightblue") + geom_density()
p + ggtitle("Distribution of Birth Year for the Berlin Marathon 2014") + xlab("Year of Birth") + ylab("Density")
# get the top 10 particpating nations
@Tafkas
Tafkas / activity_extractor.py
Created November 17, 2013 19:00
Extracts duration from gpx and tcx files for further processing
#!/usr/local/bin/python
# encoding: utf-8
"""
activity_extractor.py
Created by Christian Stade-Schuldt on 2013-10-29.
"""
import os
from lxml import etree as et
from datetime import timedelta, datetime
@Tafkas
Tafkas / goeuro_test.py
Created November 21, 2013 14:24
Python solution to the GoEuroTest
#!/usr/bin/env python
# encoding: utf-8
"""
Created by Christian Stade-Schuldt on 2013-11-12.
"""
import sys
import os
import csv
import json
@Tafkas
Tafkas / AtlanticCity10Miler.r
Created December 9, 2013 14:27
Some charts of the St. Pat's 10 Miler and 5K 2008
data <- read.csv(file = "2008TenMiler.csv", header = TRUE, sep=",")
summary(data)
data <- na.omit(data)
#convert time to minutes
data$Nettime <- as.character(data$Nettime)
data$Nettime <- sapply(strsplit(data$Nettime, ":"),
function(x) {
x <- as.numeric(x)
x[1]*60 + x[2] + x[3]/60
@Tafkas
Tafkas / sleepdata.R
Last active April 4, 2016 14:00
A first look at the sleepdata recorded with the Sleep Cycle app for the iPhone
sleep <- read.csv(file="sleepdata.csv", header=T, sep=";")
#split end time
sleep$End <- as.character(sleep$End)
#get the date
sleep$Date <- sapply(strsplit(sleep$End, " "),"[[",1)
sleep$Date <- strptime(sleep$Date, format="%Y-%m-%d")
#fix sleep quality