Skip to content

Instantly share code, notes, and snippets.

sebastianhaas /
Created Dec 3, 2019
Advent of Code 2019 Day 1
import math
def calc_total_fuel(masses):
fuel_sum = 0
for x in masses:
fuel_sum += calc_fuel(x)
return fuel_sum
def calc_fuel(mass):
fuel = math.floor(mass / 3.0) - 2

Unfortunately, the mini fridge for our coffee machine seems to have either a broken power switch or a broken cable. If you move it, it will likely stop working and our milk will turn sour which I find particularly unpleasant. So, if you feel like replacing the milk, take some extra care not to displace the fridge.

sebastianhaas / pbshare.html
Last active Oct 30, 2017
Examplary Practice Session Result
View pbshare.html
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Sebastian's Practice Bird Score</title>
<meta property="og:title" content="Sebastian's Practice Bird Score" />
<meta property="og:description" content="Sebastian's just finished playing Air by Johann Sebastian Bach" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://your localtunnel/pst share url" />
<meta property="og:image" content="" />
sebastianhaas / .bootstraprc.yaml
Created Jan 30, 2017
.bootstraprc for bootstrap@4.0.0-alpha.6 with bootstrap-loader@2.0.0-beta.20
View .bootstraprc.yaml
# Output debugging info
# loglevel: debug
# Major version of Bootstrap: 3 or 4
bootstrapVersion: 4
# If Bootstrap version 4 is used - turn on/off flexbox model
useFlexbox: true
sebastianhaas / socketcan-interface.service
Created Aug 6, 2016
An example systemd unit file to setup a SocketCAN interface on startup
View socketcan-interface.service
Description=SocketCAN interface can0 with a baudrate of 250000
ExecStart=/sbin/ip link set can0 type can bitrate 250000 ; /sbin/ifconfig can0 up
ExecReload=/sbin/ifconfig can0 down ; /sbin/ip link set can0 type can bitrate 250000 ; /sbin/ifconfig can0 up
ExecStop=/sbin/ifconfig can0 down
sebastianhaas / can2udp.service
Created Aug 6, 2016
An example systemd unit file to run can2udp on startup
View can2udp.service
Description=can2udp socketcan-interface.service
ExecStart=/home/pi/development/railroad/can2udp/src/can2udp -f -v
sebastianhaas / Gruntfile.js
Created Mar 10, 2016
grunt-typings issue#2
View Gruntfile.js
module.exports = function(grunt) {
// refreshes ts definition files
typings: {
install: {}
sebastianhaas / mathjs.d.ts
Created Feb 26, 2016
Fixed math.js typings
View mathjs.d.ts
declare namespace MathJS {
interface Fraction {}
interface MathArray {}
interface Matrix {}
function config(options: any): void;
View median.cpp
// Compute the median with std::nth_element
template<class T>
T vtkComputeMedianOfArray(T *aBegin, T *aEnd)
T *aMid = aBegin + (aEnd - aBegin)/2;
std::nth_element(aBegin, aMid, aEnd);
T m = *aMid;
// if even size, get max of lower part of array and compute the average
if (aMid - aBegin == aEnd - aMid)
sebastianhaas / user.json
Created Oct 1, 2015
LoopBack User Friendship
View user.json
"name": "user",
"plural": "users",
"base": "User",
"idInjection": true,
"options": {
"validateUpsert": true
"properties": {},
"validations": [],