Skip to content

Instantly share code, notes, and snippets.

View faroit's full-sized avatar
🚀
Rocket Science

Fabian-Robert Stöter faroit

🚀
Rocket Science
View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@turbinenreiter
turbinenreiter / serialplot
Created December 10, 2013 20:43
Code to read data from the serial port and plot it.
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
from pyqtgraph.ptime import time
import serial
app = QtGui.QApplication([])
@domenic
domenic / 0-github-actions.md
Last active May 26, 2024 07:43
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.
@JRHeaton
JRHeaton / midimsg.swift
Last active May 6, 2023 16:41
elegant midi message model w/ swift
import CoreMIDI
enum ChannelMessage {
case NoteOn(key: UInt8, velocity: UInt8)
case NoteOff(key: UInt8)
case ControlChange(controller: UInt8, value: UInt8)
func bytesForChannel(channel: Int) -> [UInt8] {
let status = { $0 | (UInt8(channel) & 0x0F) }
let removeMSB = { $0 & UInt8(0x7F) }
@kylemcdonald
kylemcdonald / ffmpeg_load_audio.py
Last active June 6, 2023 03:06
Load audio from ffmpeg into Python using numpy.
import numpy as np
import subprocess as sp
import os
DEVNULL = open(os.devnull, 'w')
# load_audio can not detect the input type
def ffmpeg_load_audio(filename, sr=44100, mono=False, normalize=True, in_type=np.int16, out_type=np.float32):
channels = 1 if mono else 2
format_strings = {
np.float64: 'f64le',
@kastnerkyle
kastnerkyle / audio_tools.py
Last active July 2, 2024 19:06
Audio tools for numpy/python. Constant work in progress.
raise ValueError("DEPRECATED/FROZEN - see https://github.com/kastnerkyle/tools for the latest")
# License: BSD 3-clause
# Authors: Kyle Kastner
# Harvest, Cheaptrick, D4C, WORLD routines based on MATLAB code from M. Morise
# http://ml.cs.yamanashi.ac.jp/world/english/
# MGC code based on r9y9 (Ryuichi Yamamoto) MelGeneralizedCepstrums.jl
# Pieces also adapted from SPTK
from __future__ import division
import numpy as np

Build tensorflow on OSX with NVIDIA CUDA support (GPU acceleration)

These instructions are based on Mistobaan's gist but expanded and updated to work with the latest tensorflow OSX CUDA PR.

Requirements

OS X 10.10 (Yosemite) or newer

@alexanderwallin
alexanderwallin / unpack_stems.sh
Created June 27, 2016 18:38
Unpacks stems into folders with cover art and separate tracks using ffmpeg
#!/bin/bash
#
# Extracts tracks from stems files and puts them in folders
# named after the stem filenames.
#
for stem in *.mp4
do
name=${stem%\.*}
@udibr
udibr / gruln.py
Last active November 7, 2020 02:34
Keras GRU with Layer Normalization
import numpy as np
from keras.layers import GRU, initializations, K
from collections import OrderedDict
class GRULN(GRU):
'''Gated Recurrent Unit with Layer Normalization
Current impelemtation only works with consume_less = 'gpu' which is already
set.
# Arguments