Skip to content

Instantly share code, notes, and snippets.

View sepastian's full-sized avatar
💭
\_ . |‾‾‾| o-`o

Sebastian Gassner sepastian

💭
\_ . |‾‾‾| o-`o
View GitHub Profile
@sepastian
sepastian / annotate_parallel.sh
Created May 25, 2020 15:36
Annotate images in parallel
# Annotate images with respective filename.
# Note: quotes must be escaped, or parallel will 'swallow' them...
find height_1000 -type f -name '*png' \
| parallel convert \
-verbose \
-background \'#0009\' \
-gravity center \
-fill white \
caption:\"{/}\" \
{} \
@sepastian
sepastian / gist:301c4d5d08af11d8289aaa27b747ee01
Created March 30, 2020 09:54
Customize colors in Emacs with M-x customize-face
# Customize colors in Emacs with M-x customize-face.
#
# From: https://stackoverflow.com/a/41840175/92049
# Use a DSLR camera as a webcam, in Zoom and other applications.
# Inputs from https://gist.github.com/ianmackinnon/cf8a4d6cdb08852a818fc34bd4e1882f
# See # https://gstreamer.freedesktop.org/documentation/video4linux2/v4l2sink.html?gi-language=c#v4l2sink
# Install dependencies.
sudo apt install v4l2loopback-dkms gphoto2 gstreamer1.0-tools
# Load and verify module.
sudo modprobe v4l2loopback
@sepastian
sepastian / unzip_conv_utf8.sh
Created March 9, 2020 10:56
Unzip files, convert filenames from (win) cp-1252 to utf-8
#!/bin/bash
set -euo pipefail
unzip file.zip
# Show what would be renamed.
convmv -f cp-1521 -t urf-8 *
# Do the renaming.
@sepastian
sepastian / gst_screencast.sh
Last active March 5, 2020 08:26
Screencast to file through gstreamer, using resolution of screen
#!/bin/bash
set -euo pipefail
# Record the screen into an h264 encoded MP4.
# Determing video resolution from the screen being recorded.
#
# Required gst-launch and xrandr.
#
# Based on https://stackoverflow.com/a/33822024/92049
@sepastian
sepastian / record_audio_monitor.sh
Created December 28, 2019 11:18
Record audio that is currently output
# Record audio that is currently output.
# From https://askubuntu.com/questions/229352/how-to-record-output-to-speakers
sudo apt-get install pulseaudio-utils lame mpg123
pacmd list-sinks | grep -e 'name:' -e 'index' -e 'Speakers'
parec -d alsa_output.pci-0000_00_1f.3.analog-stereo.monitor | lame -r -V0 - out.mp3
# ctrl + c to stop recording
mpg123 out.mp3
@sepastian
sepastian / jupyter_remote_via_ssh_tunnel.txt
Last active October 26, 2022 09:25
Jupyter notebook on remote host via SSH tunnel
# SSH into remote host "R", startup Jupyter on port XXXX.
ssh [email protected]
jupyer notebook --no-browser --port=XXXX
# On the localhost "L", accessing jupyter via the browser:
# create a reverse tunnel, forwarding YYYY (L) to XXXX (R).
ssh -N -L YYYY:localhost:XXXX [email protected]
---- --------- ----
| | |
| | ` port on remote where Jupyer is listening
@sepastian
sepastian / img2pdf.sh
Created November 12, 2019 17:23
Recursively perform OCR on images, output searchable PDFs
#!/bin/bash
# Current directory contains a folder named 'img',
# which contains images nested in subfolders, e.g.
#
# img
# folder1
# img1.jpg
# img2.jpg
# folder2
@sepastian
sepastian / go_install_imports.sh
Last active November 8, 2019 14:24
Golang: install all packages imported in src
# Using go get can be confusing, here's what I learned.
#
# When go get ./... failed in a Dockerfile on Dockerhub, I listed and installed dependencies manually.
# Inspired by https://dave.cheney.net/2014/09/14/go-list-your-swiss-army-knife
#
# Recursively search for dependencies in $GOPATH/src; install dependencies using go get.
find "${GOPATH}/src" -type d \
-exec go list -f '{{ join .Imports "\n" }}' -e {} + \
| sort -u \
| xargs go get -v
@sepastian
sepastian / eduroam_uni_passau_cert_file.sh
Last active October 15, 2019 14:27
Connect to eduroam with personal certificate using wpa_supplicant or wicd
# First, install certificate with https://www.zim.uni-passau.de/dienstleistungen/netzwerk-und-server/netzwerkzugang/eduroam/fuer-uniangehoerige/linux/
# This will created ~/.cat_installer/user.p12 and ~/.cat_installer/ca.pem, which are the certificates required to connect.
# Create eduroam config for wpa_supplicant.
# ZIMID is your ZIM identifier, e.g. abcdef99
cat > /tmp/eduroam.conf <<EOF
network={
ssid="eduroam"
key_mgmt=WPA-EAP
pairwise=CCMP