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 / 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 {} \
@sepastian
sepastian / ext4_fs_tuning.md
Last active March 10, 2023 16:36
ext4 file system tuning
@sepastian
sepastian / record_left_monitor.zsh
Last active November 2, 2022 11:25
Record left monitor from CLI
# Oh-My-ZSH custom function to record left monitor from CLI.
#
# Place in $ZSH/.oh-my-zsh/custom.
#
# Two monitors at screen 0, the left one connected at DP-1:
#
# xrandr
# Screen 0: minimum 320 x 200, current 3840 x 1200, maximum 16384 x 16384
# DP-1 connected primary 1920x1200+1920+0 (normal left inverted right x axis y axis) 518mm x 324mm
# 1920x1200 59.95*+
@sepastian
sepastian / compress_pdf.zsh
Last active November 2, 2022 11:15
Compress PDF custom Oh-My-ZSH function
# Place in $ZSH/.oh-my-zsh/custom.
#
# The following ZSH function uses GhostScript's `gs` command to reduce the file size of a PDF file.
# The result of compressing `test.pdf` will be written to `test.compressed.pdf`.
# If `test.compressed.pdf` exists, it will only be overwritten after confirmation.
#
# Now, restart/open a new shell and compress PDFs with:
#
# compress_pdf test.pdf
# File exists: test.compressed.pdf, overwrite (Y/n)?
@sepastian
sepastian / determine_dpi.sh
Last active October 14, 2022 09:16
Determine Image DPI
# Based on https://apple.stackexchange.com/a/389067/453491
# In order to calculate DPI, determine units and resolution first.
identify -verbose warc2corpus@2x_300dpi.png | grep -E -i "resolution|units"
# Resolution: 118.11x118.11
# Units: PixelsPerCentimeter
# png:pHYs: x_res=11811, y_res=11811, units=1
# 1 PixelsPerCentimeter corresponds to 2.54 DPI.
# Calculate DPI using the following command.