Skip to content

Instantly share code, notes, and snippets.

View astoeckel's full-sized avatar

Andreas Stöckel astoeckel

View GitHub Profile
@astoeckel
astoeckel / nbdkit.service
Last active November 16, 2020 07:44
nbdkit systemd socket and service file
# nbdkit.service
[Unit]
Description=nbdkit Service
After=nbdkit.socket
Requires=nbdkit.socket
[Service]
Environment="LD_LIBRARY_PATH=/opt/nbdkit/lib64"
Environment="TMPDIR=/var/lib/nbdkit/cache/"
@astoeckel
astoeckel / compile_and_install_nbdkit_centos_7.sh
Created November 15, 2020 23:22
Compiling and installing nbdkit on CentOS 7
#!/usr/bin/bash
# Downloads NBDKit and builds a minimal version. This minimal version only
# installs basic plugins and filters, and the SSH plugin.
# For compilation to succeed, you'll need to install
# yum install gcc gcc-c++ libssh-devel openssl-devel autoconf automake libtool
# Also, best create a user nbdkit
# adduser --system --user-group --shell /sbin/nologin --home-dir /opt/nbdkit --create-home nbdkit
@astoeckel
astoeckel / gist:fae7fd37a0f5c5f48bce03bee301fbcd
Created April 29, 2020 17:23
Libre Office Export All Sheets As CSV
Sub ExportAllToCsv
document = ThisComponent
' Use the global string tools library to generate a base filename for each CSV
' based on the current prefixless filename
GlobalScope.BasicLibraries.loadLibrary("Tools")
DocumentName = Left(document.Namespace, Len(document.Namespace) - 1)
BasePath = Tools.Strings.DirectoryNameoutofPath(DocumentName, "/")
BaseFilename = Tools.Strings.GetFileNameWithoutExtension(DocumentName, "/")
@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,
@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 / 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 / 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 / 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 / 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 / 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,