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 / sort_by_german_month_names.sh
Last active November 30, 2024 09:41
Sort by German month names
# Use the `sort` command to sort by German month names.
#
# E.g. sort files containing month names in ther path.
# make sure desired locale is installed
$ localectl list-locales
C.UTF-8
en_US.UTF-8
# install missing locales, if required
@sepastian
sepastian / debian_laptop_networking_setup.md
Created November 7, 2024 07:50
Debian laptop networking setup

This guide describes how to setup networking under Debian Linux on a laptop. While there are many options to choose from, Debian 12 (bookworm) uses NetworkManager and wpa_supplicant as a default. This guide installs systemd-networkd and iwd, with the goal of controlling networking form the command line, using modern components.

The official Debian documentation lists various options and serves as a starting point.

NetworkManager → systemd-networkd

Replacing NetworkManager with systemd-networkd has been done following the official Debian docs and a great guide by Fernanto Cejas.

@sepastian
sepastian / .bashrc_venv
Last active November 7, 2024 10:00
Activate and deactivate venv automatically when changing directories in Bash.
# Activate Python venv when changing into directory containing .venv/bin/activate;
# deactivate Python venv when leaving directory containing .venv/bin/activate.
#
# Handle edge case, where presend and new directory contain .venv/bin/activate,
# i.e. switching from one venv into the next.
#
# This works for Bash only, place at the end of ~/.bashrc.
#
# Based on https://unix.stackexchange.com/a/170282
cd() {
@sepastian
sepastian / jq_select_by_missing_attribute.sh
Created September 17, 2024 06:30
jq: select objects missing a specific attribute
#!/bin/bash
set -euo pipefail
# Select all objects which do not contain an attribute named 'message'.
#
# Background: a log file contains messages from an application and
# numerous messages from Mongo db; the messages from Mongo contain
# an attribute called 'message', the application logs contain 'msg'
# instead. Filter the application logs only by selecting all objects
@sepastian
sepastian / dvgrab_ffmpeg.sh
Created March 3, 2024 17:20
Camcorder to digital video
# Grab video from a camcorder using dvgrap,
# convert to h.265 encoded video using ffmpeg.
#
# https://trac.ffmpeg.org/wiki/Encode/H.265
# https://regx.dgswa.com/html/content/dvgrab-ffmpeg-capture-compression
dvgrab --format dv1 --rewind - \
| ffmpeg -f dv -i - \
-vf yadif \
-c:v libx265 -crf 26 \
@sepastian
sepastian / DEPRECATED_pip_install_in_coderpad.py
Last active October 25, 2023 10:13
(DEPRECATED) Install any pip package in Coderpad
# DEPRECATED:
# In addition to running Python code, the coderpad console allows
# to pip install packages as well:
#
# >>> pip install sortedcontainers
#
# Using the code below is not required.
# It will be kept here for reference, as it shows how to access
# the Coderpad environment.
@sepastian
sepastian / main.cpp
Last active September 29, 2023 13:28
Multiple STL containers referencing same object in C++
#include <set>
#include <iostream>
#include <vector>
/*
* How to order a set<vector<A>::iterator>.
*/
struct A
{
@sepastian
sepastian / meson_ninja.sh
Created September 29, 2023 07:33
Building C++ with Meson and Ninja
# https://germandiagogomez.medium.com/getting-started-with-meson-build-system-and-c-83270f444bee
# Create project directory.
mkdir new_project
cd new_project
# Create source file.
echo "int main() {};" >> main.cpp
# Init meson, setup meson.
@sepastian
sepastian / v4l2_set_camera_zoom_level.md
Last active June 29, 2023 07:58
V4L2 set camera zoom level

Environment

$ uname -a
Linux x220 6.3.0-1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.3.7-1 (2023-06-12) x86_64 GNU/Linux

List Cameras

@sepastian
sepastian / raw_to_ppm_to_jpg.sh
Created June 18, 2023 12:34
RAW to PPM (dcraw) to JPG (imagemagick)
#!/bin/bash
set -euo pipefail
# Convert (Nikon/NEF) RAW images to PPM using dcraw;
# write results to stdout with -c;
# convert stdin to JPG using Imagemagick's convert;
# specify format of input image with 'ppm:-'.
find /path/to/sdcard/ -name '*.NEF' \
| parallel 'dcraw -c {} \