Skip to content

Instantly share code, notes, and snippets.

View Tafkas's full-sized avatar

Christian Stade-Schuldt Tafkas

View GitHub Profile
@Tafkas
Tafkas / git-up.sh
Created September 18, 2023 07:15 — forked from 0x-2a/git-up.sh
Replacement for Git-Up ruby gem
#!/bin/zsh
# Add the following to your ~/.gitconfig
#
# [alias]
# up = !zsh /path-to-this-script/git-up.sh
#
# Then you can call
#
# `git up`
@Tafkas
Tafkas / computeSunrise.js
Last active August 3, 2023 20:04
A simple sunrise-sunset algorithm taken from http://williams.best.vwh.net/sunrise_sunset_algorithm.htm in JavaScript
function computeSunrise(day, sunrise) {
/*Sunrise/Sunset Algorithm taken from
http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
inputs:
day = day of the year
sunrise = true for sunrise, false for sunset
output:
time of sunrise/sunset in hours */
@Tafkas
Tafkas / rouletty.py
Created December 9, 2013 11:28
A simulation of the martingale roulette system
#!/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 / slack_user_munin.py
Last active April 7, 2022 20:53
A munin plugin for to monitor online presence in Slack
#!/usr/bin/env python
"""
slack_user_munin - A munin plugin for to monitor online presence in Slack
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:
[slack_*]
@Tafkas
Tafkas / slack_channel_munin.py
Created May 21, 2016 22:53
A munin plugin for to monitor channel count in Slack
#!/usr/bin/env python
"""
slack_channel_munin - A munin plugin for to monitor channel count in Slack
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:
[slack_*]
@Tafkas
Tafkas / rmsle.py
Created November 25, 2013 14:37
Compute the Root Mean Squared Log Error for hypothesis h and targets y
import numpy as np
def rmsle(h, y):
"""
Compute the Root Mean Squared Log Error for hypthesis h and targets y
Args:
h - numpy array containing predictions with shape (n_samples, n_targets)
y - numpy array containing targets with shape (n_samples, n_targets)
"""
@Tafkas
Tafkas / collect_kostal.py
Created May 18, 2016 20:55
A script to fetch data from a Kostal Piko 5 inverter
#!/usr/local/bin/python
# encoding: utf-8
"""
collect_kostal.py
Created by Christian Stade-Schuldt on 2014-07-27.
"""
import urllib2
@Tafkas
Tafkas / collect_weather.py
Created May 18, 2016 20:52
A script to fetch weather data from OpenWeatherMap
"""
Created by Christian Stade-Schuldt on 2014-07-28.
"""
import sqlite3
import json
import urllib
import time
import datetime
import calendar
@Tafkas
Tafkas / fitbitdownload.gs
Created January 28, 2014 22:41
This script will access your Fitbit data via the Fitbit API and insert it into a Google spreadsheet.
/* 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 / trendweight.r
Last active August 31, 2018 18:09
Chart your data from http://trendweight.com/export with ggplot2 in 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