Skip to content

Instantly share code, notes, and snippets.

@soerface
soerface / fetch_number_of_people.py
Created January 13, 2015 23:18
Flipdot usercounter
import httplib
import json
from influxdb import InfluxDBClient
SERVER = 'flipdot.org'
API = {
'status': '/spacestatus/status.json',
}
#!/usr/bin/env python
import sys
import httplib
import json
from influxdb import InfluxDBClient
SERVER = 'flipdot.org'
API = {
'status': '/spacestatus/status.json',
@soerface
soerface / imagegenerator.py
Created April 13, 2015 15:00
Generate images of letters in different colors
from subprocess import call
import os
import sys
n = int(sys.argv[1])
for i in range(n):
directory = 'output/{0}'.format(i)
if not os.path.exists(directory):
os.makedirs(directory)
for letter in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
print 'Hello World!'
@soerface
soerface / app.py
Last active January 10, 2016 23:09
Wordsearch
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
if len(sys.argv) == 3:
wordlength = int(sys.argv[1])
wordchars = sys.argv[2]
else:
wordlength = int(input('Word length?\n'))
import argparse
import csv
from datetime import datetime
from matplotlib import pyplot
import numpy as np
parser = argparse.ArgumentParser(description='Plot N26 CSV')
parser.add_argument('filepath', type=str, help='path to csv file downloaded from N26')
args = parser.parse_args()
const {random, sin, PI, pow} = Math
this.t += 1 / 44100
const freq = noteNumber => pow(2, (noteNumber-69) / 12) * 440
const lowPass = (name, v, amount) => {
amount = amount ? amount : 1;
const val = (this[name] * amount + v) / (amount + 1)
this[name] = val;
@soerface
soerface / mixins.py
Last active January 18, 2019 10:11
ActionSerializerMixin for the Django Rest Framework. Allows usage of multiple serializers for a single ViewSet
from typing import Union, Dict
from rest_framework.viewsets import GenericViewSet
from rest_framework.serializers import BaseSerializer
class ActionSerializersMixin(object):
"""
Allows the usage of different serializer classes depending on the action.
When your `ViewSet` class is using this mixin, it should provide a `serializer_classes` attribute instead
of a `serializer_class` attribute. This attribute must be dict, which provides for every action name the
@soerface
soerface / NetflixViewingHistory.ipynb
Last active May 12, 2019 18:59
Calculates and plots how many profiles were watching simultaneously on each day.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soerface
soerface / splitscreen.sh
Created June 23, 2019 21:08
Splits up to four videos into a grid and starts them at different timemarks using ffmpeg
#!/bin/bash
# timestamps in trim filter can be used to sync the videos
# The duration of the first color filter specifies the length of the output video
# Scale / crop may be adjusted for the individual files
ffmpeg -i a.mp4 -i b.mp4 -i c.mp4 -filter_complex \
"color=
d='02\:50\:00':
c=0x161618:
s='1366x768'