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 / docker_rm_exited_containers.sh
Created October 7, 2020 09:34
Remove exited docker containers.
#!/bin/bash
set -euo pipefail
IFS=$'\t\n'
docker rm \
$(docker ps -a | grep Exited | awk -F ' ' '{print $NF}')
@sepastian
sepastian / unzip_fix_encoding.sh
Created September 18, 2020 08:25
Unzip with correct encoding in filenames
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Unzip a zipfile, then fix encoding in filenames.
#
# Assume filenames have been encoded with CP1250 (Win);
# convert encoding in filenames to UTF-8.
#
@sepastian
sepastian / downgrade_debian.md
Last active March 16, 2024 12:19
Downgrade Debian
@sepastian
sepastian / mongo_dump_all_collections_to_json.sh
Last active June 18, 2020 09:36
Dump all Mongo collections to JSON files
#!/bin/bash
set -euo pipefail
docker_container=sipts-mongo
db=si-pts
target=$(mktemp -d "${db}_mongoexport_XXX")
echo "Dumping into ${target}."
docker exec "$docker_container" mongo --quiet \
@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