Skip to content

Instantly share code, notes, and snippets.

@soerface
soerface / compress.sh
Created July 6, 2022 17:01
Strong compression
tar -cf - INPUT_DIR | xz -0e -c > OUTPUT_FILE.tar.xz
@soerface
soerface / main.py
Created July 6, 2022 14:03
logging.basicConfig
import logging
logging.basicConfig(
format="%(asctime)s %(levelname)s: %(message)s",
level=logging.getLevelName("INFO"),
)
logger = logging.getLogger()
@soerface
soerface / config.json
Last active June 21, 2020 11:01
flipdot-mqtt-dash-config
[
{
"iconOff": "ic_power_settings_new",
"iconOn": "ic_power_switch",
"offColor": -10461088,
"onColor": -65536,
"payloadOff": "0",
"payloadOn": "1",
"enableIntermediateState": true,
"enablePub": true,
@soerface
soerface / jless.sh
Created March 10, 2020 23:09
jless
# Just put this in your ~/.zshrc or ~/.bashrc!
# Pretty format of json files. Usage: jless path/to/file.json
function jless {
python -mjson.tool "$1" | pygmentize -l json | less -Nr
}
@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'
@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 / 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
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;
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()
@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'))