Skip to content

Instantly share code, notes, and snippets.

Christian Stade-Schuldt Tafkas

Block or report user

Report or block Tafkas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Tafkas
Tafkas / pysml.py
Last active Aug 29, 2015
Script to read SML data packages from a residential meter
View pysml.py
#!/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 / read_ehz.sh
Created Oct 27, 2014
Reading data from an eHZ-IW8E2A5 residential meter
View read_ehz.sh
#!/bin/bash
# read and evaluate SML output received from EMH eHZ
# set serial device
INPUT_DEV="/dev/ttyUSB0"
#set $INPUT_DEV to 9600 8N1
stty -F $INPUT_DEV 1:0:8bd:0:3:1c:7f:15:4:5:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
SML_START_SEQUENCE="1B1B1B1B0101010176"
@Tafkas
Tafkas / collect_weather.py
Created Jul 28, 2014
Fetch current weather from openweathermap api and save it to a sqlite database
View collect_weather.py
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 / sun_flight_map.R
Created May 20, 2014
Plot sun elevations along a flight path.
View sun_flight_map.R
# 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 / decodeLine.R
Created Feb 12, 2014
Decode Encoded Polylines in R
View decodeLine.R
decodeLine <- function(encoded){
require(bitops)
vlen <- nchar(encoded)
vindex <- 0
varray <- NULL
vlat <- 0
vlng <- 0
while(vindex < vlen){
@Tafkas
Tafkas / fitbitdownload.gs
Created Jan 28, 2014
This script will access your Fitbit data via the Fitbit API and insert it into a Google spreadsheet.
View fitbitdownload.gs
/* FitbitDownload.gs
This script will access your Fitbit data via the Fitbit API and insert it into a Google spreadsheet.
The first row of the spreadsheet will be a header row containing data element names. Subsequent rows will contain data, one day per row.
Note that Fitbit uses metric units (weight, distance) so you may wish to convert them.
Original script by loghound@gmail.com
Original instructional video by Ernesto Ramirez at http://vimeo.com/26338767
Modifications by Mark Leavitt (PDX Quantified Self organizer) www.markleavitt.com
Further Modifications by Christian Stade-Schuldt blog.tafkas.net
Here's to your (quantified) health!
@Tafkas
Tafkas / sleepdata.R
Last active Apr 4, 2016
A first look at the sleepdata recorded with the Sleep Cycle app for the iPhone
View sleepdata.R
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
@Tafkas
Tafkas / AtlanticCity10Miler.r
Created Dec 9, 2013
Some charts of the St. Pat's 10 Miler and 5K 2008
View AtlanticCity10Miler.r
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 / rouletty.py
Created Dec 9, 2013
A simulation of the martingale roulette system
View rouletty.py
#!/usr/local/bin/python
# encoding: utf-8
import random
import time
import matplotlib.pyplot as plt
import numpy as np
#simulates the martingale roulette system
def simulation():
@Tafkas
Tafkas / trendweight.r
Last active Aug 31, 2018
Chart your data from http://trendweight.com/export with ggplot2 in R
View trendweight.r
#read data
tw <- read.csv(file="TrendWeightData.csv",header=T)
summary(tw)
#remove interpolated values
tw <- tw[tw$WeightIsInterpolated == "False",]
#convert strings to date and extract year
tw$Date <- as.POSIXlt(as.character(tw$Date), format="%Y-%m-%d")
tw$Year <- tw$Date$year + 1900
You can’t perform that action at this time.