Skip to content

Instantly share code, notes, and snippets.

View astoeckel's full-sized avatar

Andreas Stöckel astoeckel

View GitHub Profile
@astoeckel
astoeckel / rhythmdb_to_xspf.py
Created September 10, 2017 19:11
Script for converting a Rhythmbox database to a XSPF playlist
#!/usr/bin/env python3
import sys
import urllib.parse
import urllib.request
import xml.etree.ElementTree as ET
BASE_PATH = "file:///home/andreas/.audio_rhythmbox/"
if len(sys.argv) != 3:
@astoeckel
astoeckel / opusenc_example.c
Created November 15, 2017 07:06
libopusenc ope_continue_encoding_file
/*
Usage:
mkdir -p blocks
./opusenc_example test_libopusenc_ope_encoder_continue_new_file.raw
( for i in `find blocks -name '*.ogg' | sort -n`; do opusdec $i -; done ) | aplay -f dat
*/
@astoeckel
astoeckel / queue.cpp
Created April 30, 2018 05:45
Lock-free queue implementation problem
//// Implementation ////
#include <atomic>
#include <csignal> // XXX for debugging
#include <cstdint>
template <typename T>
class Queue {
private:
uint32_t m_data_size; // Number of elements allocated.
@astoeckel
astoeckel / linear_regression.js
Last active May 14, 2018 03:20
Code I wrote that I didn't happen to need for now
/*
* EOLIAN Web Music Player
* Copyright (C) 2018 Andreas Stöckel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@astoeckel
astoeckel / ipynb_to_pdf.sh
Created January 24, 2019 18:37
Convert ipynb to PDF
#!/bin/bash -e
jupyter nbconvert --to latex --template article $1.ipynb
sed -i 's/\\maketitle//' $1.tex
sed -i 's/section{/section*{/' $1.tex
sed -i 's/\(\\documentclass\[\(.*\)\]{article}$\)/\1\n\n \\usepackage{palatino}\n \\setlength{\\parindent}{0cm}\n \\setlength{\\parskip}{1em}\n/' $1.tex
sed -i 's/\\begin{Verbatim}\[\(.*\)\]/\\begin{Verbatim}[\1,fontsize=\\small]/' $1.tex
@astoeckel
astoeckel / imgshrink.py
Last active April 27, 2019 17:08
Mirrors a source directory containing images to a target directory and shrinks the images in the process
#!/usr/bin/env python3
################################################################################
# imgshrink.py #
# Mirrors a directory containing photos in smaller resolution #
# (c) 2019 Andreas Stöckel, licensed under the GPLv3 #
################################################################################
import math
import multiprocessing
@astoeckel
astoeckel / zfs_link_snapshots.py
Last active May 22, 2019 15:42
Populates a "snapshots" directory in each user's home directory with links at separate versions
@astoeckel
astoeckel / transfer_rhythmdb_ratings.py
Created August 11, 2019 22:29
Python script that transfers the ratings from multiple Rhythmbox databases into a single Rhythmbox database. If the same song exists multiple times in the target database, only the one with the highest quality is assigned a rating.
#!/usr/bin/env python3
import os
import sys
import urllib.parse
import urllib.request
import lxml.etree as ET
import icu
import collections
import math
@astoeckel
astoeckel / mount.qcow2
Last active December 25, 2019 04:51
Mounts a LUKS encrypted QCOW2 image
#!/bin/bash
QCOW2_ACTION="$1"
QCOW2_FILENAME="$2"
QCOW2_MOUNTPOINT="$3"
if test -z "$QCOW2_ACTION" || test -z "$QCOW2_FILENAME" || test -z "$QCOW2_MOUNTPOINT"; then
echo "Usage: mount.qcow2 <mount|unmount> <FILENAME> <MOUNTPOINT>";
exit 1
fi
@astoeckel
astoeckel / csc_matrix.cpp
Last active January 22, 2020 03:19
CSC Matrix Operations -- Code I wrote before I realised that Eigen can be made to directly interface with CSC matrices via SparseMatrix and makeCompressed()
/*
* libbioneuronqp -- Library solving for synaptic weights
* Copyright (C) 2020 Andreas Stöckel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,