AmigaDOS - format floppy


AmigaDOS - make floppy bootable


Read floppy to ADF image using drawbridge

drawbridge /dev/ttyUSB0 test.adf READ

Compile for Kickstart 1.3

Using the toolchain from

m68k-amigaos-gcc hello.cpp -mcrt=nix13 -o hello

Add binary to ADF image using xdftool

xdftool test.adf + write hello
xdftool test.adf list

Write ADF image to floppy using drawbridge

drawbridge /dev/ttyUSB0 test.adf WRITE VERIFY

(Boot from floppy, start binary with "hello")


Run playbook verbosely

ansible-playbook -vv playbook.yml

Run tasks of playbook having a specific tag

ansible-playbook playbook.yml -t exampletag


HTTP authentication (login; password protect a directory)

htpasswd -c .htpasswd exampleuser


AuthType Basic
AuthName "Protected directory"
AuthUserFile /full/path/to/.htpasswd
Require valid-user


Filter (exclude) long lines

awk '{ if ( length < 400 ) { print $0 } }' input.txt > short_lines.txt

Get the length of the longest line of a file

awk '{ if ( length > x ) { x = length } } END { print x }' input.txt

Filter lines by value of a field

cat input.txt | awk ' BEGIN { FS = "\t" } ; { if ($2 > 10) { print $2 "\t" $1 } } ' > field_2_greater_10.txt


Add Capacitor to existing app and initialize

npm install @capacitor/core
npm install @capacitor/cli --save-dev
npx cap init

Add Android support to project

npm install @capacitor/android
npx cap add android

Set environment variables for Android SDK etc.

export ANDROID_HOME=$HOME/Android
export PATH="$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH"

List targets (devices)

npx cap run android --list

Run on specific target

npx cap run android --target [Target Id]

(Target Id as listed by --list)


Create and format encrypted partition

# WARNING: destroys existing data
cryptsetup luksFormat /dev/sda5
cryptsetup luksOpen /dev/sda5 sda5_crypt
mkfs.ext4 /dev/mapper/sda5_crypt

Open and mount encrypted partition

cryptsetup luksOpen /dev/sda5 sda5_crypt
mount /dev/mapper/sda5_crypt /mnt/tmp

Unmount and close encrypted partition

umount /mnt/tmp
cryptsetup luksClose sda5_crypt

List opened encrypted partitions

dmsetup ls

(will list other logical volumes too)


List printers

lpstat -s


POST request with form data

curl -v -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -X POST -d 'text=This+is+an+example.&language=en' ""

date (GNU coreutils)

Get date in a specific format

date "+%Y%m%d_%H%M%S"


debootstrap a minimal Debian installation and chroot into it

export MY_CHROOT="/mnt/tmp"
debootstrap --arch i386 --variant=minbase sid "$MY_CHROOT"
mount -t proc /proc "$MY_CHROOT/proc"
mount --rbind /sys "$MY_CHROOT/sys"
mount --rbind /dev "$MY_CHROOT/dev"
chroot "$MY_CHROOT" /bin/bash

unmount it after leaving chroot (exit / CTRL + D)

mount --make-rslave "$MY_CHROOT/sys"
mount --make-rslave "$MY_CHROOT/dev"
umount -R "$MY_CHROOT/sys"
umount -R "$MY_CHROOT/dev"



docker build -t example .

Run (with port forwarding + automatic restart)

docker run -p --restart unless-stopped -d example

Run (with bind mount)

docker run -i -t -v /path_on_host_to/app:/app example

Remove not running containers

docker container prune

Remove unused images

docker image prune


Extract subtitles from DVDs

cat VTS_04_[1-6].VOB | tcextract -x ps1 -t vob -a 0x20 > de
subtitle2vobsub -i VTS_04_0.IFO -p de -o subtitles_de
mkdir images_de
vobsub2pgm -i VTS_04_0.IFO -g 2 subtitles_de images_de/de
pgm2txt images_de/de
srttool -s -w < images_de/de.srtx >


Remove all Exif data using exiv2

exiv2 -d a filename.jpg


Convert WAV to MP3 with ffmpeg

ffmpeg -i example.wav -ab 192k example.mp3

Cut a video with ffmpeg

ffmpeg -sameq -ss 209 -t 26 -i XMjcCAkCNGM.flv postbank.flv

Images to video and add audio

avconv -framerate 25 -f image2 -i reverse/%05d.png -i ../out.wav -c:a libmp3lame out.mp4

Images to video using glob pattern

ffmpeg -f image2 -pattern_type glob -i '*.jpg' out.mp4

Find silence

ffmpeg -i input.mp4 -af silencedetect=noise=0.05:duration=5 -f null -

Deinterlacing + No Audio + H.264

ffmpeg -i input.dv -vcodec libx264 -filter:v yadif -an output.avi

Deinterlacing + Cropping + No Audio + H.264

ffmpeg -i dvgrab-2016.02.06_16-28-04--00\:10\:32\:18.avi -vcodec libx264 -filter:v "crop=576:576:0:0, yadif=1" -an out.avi

Cutting + Deinterlacing + Cropping + No Audio + H.264

ffmpeg -i float.avi -ss 00:00:16 -t 00:00:59 -vcodec libx264 -crf 10 -filter:v "crop=540:540:0:0, yadif=1" -an out/float.avi

Side by side with black space etc...

ffmpeg -i tmp/float_cut_dv.avi -f lavfi -i color=c=black:size=20x535 -i tmp/float_cut_dv.avi -filter_complex "[0:v:0]pad=535*2+20:ih,yadif=1[bg]; [bg][1:v:0]overlay=535[bg2]; [bg2][2:v:0]overlay=555,yadif=1" -vcodec libx264 -crf 10 -preset ultrafast test3.avi
ffmpeg -i tmp/float_cut_dv.avi -f lavfi -i color=c=black:size=20x535 -i tmp/float_cut_dv.avi -filter_complex "[0:v:0]pad=535*2+20:ih,yadif=1[bg]; [bg][1:v:0]overlay=535[bg2]; [bg2][2:v:0]overlay=555,yadif=1,crop=535*2+20:535" -vcodec libx264 -crf 10 -preset ultrafast test3.avi


ffmpeg -i "concat:input.avi|input.avi" -vc copy -an output.avi

Concatenation + Cutting

ffmpeg -i "concat:input.avi|input.avi" -ss 00:00:30 -t 00:01:00 -vc copy -an output.avi

Get Image from video (first frame)

ffmpeg -i input.mp4 -vframes 1 output.png

Overlay with opacity (transparency)

ffmpeg -i 1.MTS -i 2.MTS -filter_complex '[0:v][1:v] blend=shortest=1:all_mode=overlay:all_opacity=0.5' -vcodec libx264 -crf 30 -an -y result.mp4


ffmpeg -i in.mp4 -filter:v "scale=1920:1012" out.mp4

Extract Audio

ffmpeg -i input.mp4 -vn -acodec copy audio.mp3

Capture frame from webcam

ffmpeg -y -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 -frames 1 "output_$(date '+%Y%m%d_%H%M%S').jpg"

No Audio

ffmpeg ... -an ...

Fix DV AVI with wrong audio sample rate using ffmpeg and sox:

ffmpeg -i "$1" -vn -c:a copy /tmp/dv_audio.wav
sox -r 48k /tmp/dv_audio.wav /tmp/dv_audio_48k.wav
ffmpeg -i "$1" -i /tmp/dv_audio_48k.wav -c:v copy -c:a copy -map 0:v:0 -map 1:a:0 "$1.fixed.avi"


ffmpeg -ss 0:48 -i 00034.MTS -frames 1 34_00-48.jpg

Encode video using H.264 + AAC + 420

ffmpeg -i -c:v libx264 -c:a aac -pix_fmt yuv420p output.yuv420p.h264.aac.mp4

Encode video using deinterlacing + H.264 + AAC + 420

ffmpeg -i in.mp4 -filter:v yadif -c:a aac -c:v libx264 -pix_fmt yuv420p out.aac.h264.mp4


Find files that are older than 10 days

find -type f -mtime +10


Disable stack-pointer protection

gcc -fno-stack-protector execute.c

Make stack executable

gcc -z execstack execute.c

Compile for 32 bit architecture

gcc -fno-stack-protector -m32 execute.c

Turn off address space randomization (Linux kernel)

echo 0 > /proc/sys/kernel/randomize_va_space


Initialize local repository

git init --bare example.git

Use local repository

git clone ~/path/to/example.git
cd example
echo "Hello world!" > README
git add README
git commit .
git push ~/path/to/example.git master

Configure current working copy

git config "John Doe"
git config

Clone from bare repository via SSH

git clone

Clone from bare repository using local file system

git clone ~/path/to/example.git

Create bare repository from working copy

git clone --bare -l example example.git

Remove from index

git rm -r --cached .
git add .

Shallow cloning (get only state the latest commit)

git clone --depth 1

Shallow cloning (get only state of the latest commit) for specific tag/branch

git clone --depth 1 --branch example-tag


Plot a specific x-range (and y-range)

plot [-5:5] sin(x),cos(x)
plot [-5:5] [-2:2] sin(x),cos(x)

Replot last plot


Set labels of axis

set xlabel "x"
set ylabel "y"

Specify line width when plotting

plot [-5:5] sin(x) lw 2,cos(x) lw 10

Specify title for key

plot sin(x) title "Sine function"

Output as PNG

set terminal png
set output "example.png"

List all available output methods (latex, ...):

set terminal

Enable 0-axis

set zeroaxis

Enable background grid

set grid

Specify resolution of background grid

set xtics 3.14159
set ytics 0.5

Using variables and functions

v = 2
m = 0
f(x) = 1/(v*sqrt(2*pi))*exp(-0.5*((x-m)/v)**2)
plot [-9:9] [-0.1:0.5] f(x)

Using the ternary operator

plot [-5:5] [-3:3] (x > 3.14159/2 ? sin(x) : cos(x))

Plot x-y-pairs form CSV file connected with lines

plot "example.csv" using 1:2 with lines

Use formatted date as X-coordinate for CSV input

set xdata time
set timefmt "%d.%m.%Y" # date format used in input file
set xtics rotate by -45
set format x "%Y-%m-%d" # date format for output
plot [] [-20:40] "data.csv" using 1:2 title "Column 2" with lines, "data.csv" using 1:3 title "Column 3" with lines

Scatterplot from column 2 and 3

plot [-15:35] [-15:35] "data.csv" using 2:3

Calculating with values from CSV files (difference)

plot [-15:35] [-15:35] "data.csv" using 3:($3-$4)

Multiple plots (2 rows, 1 column):

set multiplot layout 2,1
plot sin(x)
plot x**2

Recursive function definitions

set xrange [0:30]
set sample 30
q(x) = (x <= 2) ? 1 : q(x-q(x-1))+q(x-q(x-2))
plot q(x)

Polynomial interpolation using fit

p(x) = a0+a1*x+a2*x**2
fit p(x) "data.csv" via a0, a1, a2
plot "data.csv" using 1:2 title "measurements", p(x) title "interpolation"


Boot ISO image using grub

apt install grub-imageboot

then after rebooting in Grub press C and enter

linux16 /memdisk
initrd16 (hd0,msdos5)/home/user/Downloads/example.iso


Convert Latin-1 encoding to UTF-8

iconv --from-code=ISO-8859-1 --to-code=UTF-8 input.txt > output.txt


Convert to greyscale

convert in.jpg -colorspace gray out.jpg


convert in.jpg -set colorspace RGB -colorspace gray out.jpg


convert in.jpg -crop 10x10+10+10 out.jpg

(target size 10x10 offset 10, 10)

Resize (scale, keep aspect ratio)

convert in.jpg -resize 800x out.jpg

Convert multiple images

for f in * ; do convert "$f" -resize "250x250>"  "../photos_small/$f.jpg" ; done

Convert first page of PDF to JPEG

convert -verbose -density 1200 -trim input.pdf[0] -quality 97 output.jpg


List JAR content

jar tf example.jar

Extract single files from JAR

jar xf example.jar path/inside/jar/to/file1.txt path/inside/jar/to/file2.txt

letsencrypt / certbot

Create/update certificate

sudo systemctl stop apache2
sudo certbot certonly --cert-name --standalone -d ","
sudo systemctl start apache2

The created certificates can be used for HTTPS in Apache in a VirtualHost configuration:

SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
SSLCertificateChainFile /etc/letsencrypt/live/

List certificates

certbot certificates

Remove certificate (interactively)

certbot delete


sudo service apache2 stop ; sudo certbot renew ; sudo service apache2 start


Create logical volume in specified volume group

lvcreate --size 2TB --name example-lv example-vg

List physical volumes (PV), volume groups (VG) and logical volumes (LV)


Remove logical volume

lvremove vg0/lvol0


Makefile to call pdflatex for all *.tex files

PDF = $(patsubst %.tex,%.pdf,$(wildcard *.tex))

all: $(PDF)

%.pdf: %.tex
  pdflatex $<

  rm *.pdf


Create video from single frames (JPEGs)

mencoder -oac copy -ovc copy mf://*jpg -audiofile audio.mp3 -o out.avi

or with resolution and fps

mencoder -ovc x264 -oac copy mf://*jpg -mf w=1280:h=960:fps=25:type=jpg -o out.avi

Trim video

mencoder -ss 00:00:00 -endpos 00:02:18 -oac copy -ovc copy in.avi -o out.avi


Decode (and hexdump) FSK encoded data from live audio input using minimodem

The input device name can be obtained using arecord -L. The sox call is required to strip one of the channels (use remix 2 to select the right channel).

arecord -D "hw:CARD=PCH,DEV=0" -c 2 -r 44100 -f S16_LE -t raw - | sox -t raw -r 44100 -e signed-integer -b 16 -c 2 - -t wav - remix 1 | minimodem -r 1200 -S 1200 -M 2400 --startbits 1 --stopbits 2 -f - | hd


Extract audio from a video using mplayer

mplayer -vc null -vo null -ao pcm:fast:waveheader:file=output.wav input.flv

Specify Referer header when playing via http

mplayer -http-header-fields "Referer:"


Load binary file


Load binary file and run


Load basic file and run



List dependencies of current project

npm list

List dependencies of current project (including indirect dependencies)

npm list -a

Run command in all (sub-) workspaces

npm run lint -ws

Rebuild packages for NW.js

npm rebuild --runtime=node-webkit --target_arch=x64 --target=0.43.6


Operate on each element of a vector

values = [6, 7, 2, 8, 5, 4, 2, 9].*2

Create vector from range

values = 5:10

Plot discrete values (returns handle)

H = bar(values)

Create vector/matrix with zeros

x = zeros(1, 5)


for i in [1, 3, 6]

Cell Arrays - mixed data types; for example with strings

x = {'a', 'b', 'c'}


Shape file (.shp) to GeoJSON

ogr2ogr -f GeoJSON -t_srs crs:84 example_output.geojson example_input.shp

GeoJSON to Mercator-Projected PDF

ogr2ogr -f "PDF" -s_srs WGS84 -t_srs EPSG:3857 example_output.pdf example_input.json


Open OpenFirmware

Win + Alt + O + F

(PC keyboard)

List device aliases


List devices connected to USB

dev usb0
dev usb1

Start OSX setup from USB disk

boot usb2/disk2,\\:tbxi

(not working on PowerMac G5?)


Run OpenMSX with specific machine and additional rom cartridge

openmsx -machine "Philips_VG_8020-20" rom-filename.rom


Create self-signed certificate

openssl req -new -x509 -days 365 -nodes -out /etc/ssl/certs/name.pem -keyout /etc/ssl/private/name.key

Display certificate fingerprint

openssl x509 -sha1 -in /etc/ssl/certs/name.pem -noout -fingerprint

Display expiry date

openssl x509 -enddate -noout -in /etc/ssl/certs/name.pem

Start SMTP TLS connection:

openssl s_client -CAfile /etc/ssl/certs/ca-certificates.crt -starttls smtp -connect


Put 2 pages on one page

pdfnup --nup 1x2 --batch input.pdf --outfile out.pdf --no-landscape


Set memory limit when executing CLI scripts

php -d memory_limit=1024M example.php

Run integrated web server:

php -S localhost:8000 --docroot .


Update virtuals db

/usr/sbin/postmap /etc/postfix/virtual


Import Shapefile (.shp) to PostgreSQL

shp2pgsql -W Windows-1250 -s 3765:4326 -I example.shp target_table | psql database


Load kernel and initrd

qemu-system-i386 -kernel bzImage -initrd rootfs.cpio

Load kernel and initrd with serial terminal

qemu-system-i386 -kernel bzImage -initrd rootfs.cpio -nographic -append 'console=ttyS0'

Raspberry Pi

Extract Raspbian image to SD-Card directly

unzip -p | sudo dd of=/dev/mmcblk0 bs=4M conv=fsync


Replace newlines with space

sed ':a;N;$!ba;s/\n/ /g'


Check whether device supports S.M.A.R.T.

smartctl -i /dev/sda

Health check

smartctl -H /dev/sda
smartctl -A /dev/sda

Check for Reallocated Sector Count. Should be 0 for healthy drives.


Change sample rate of MP3

sox in.mp3 out.mp3 rate 16k


Map port 22 at host to local port 2208 ("backconnect"); reverse port forwarding

ssh -N -R 2208:localhost:22

Create a key in Dropbear

dropbearkey -t rsa -f id_rsa

Create SOCKS proxy

ssh -D8080 host

then either configure SOCKS4-proxy in browser (localhost:8080) or use tsocks

Use password authentication

ssh -o PreferredAuthentications=password

Use specific key for authentication

ssh -i ~/.ssh/private_key_file

Inspect key (show host key fingerprint / inspect private key)

ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key

can be used for ~/.ssh/private_key_file too


Routing traffic via SSH host using tsocks

Edit /etc/tsocks.txt

server =
server_type = 5
server_port = 1080

Connect with SOCKS "tunneling" enabled

ssh -D1080

Pass program to launch as argument to tsocks

tsocks firefox


Install PPAs (example: ffmpeg)

sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg

Windows 10

Create bootable USB thumb drive

xdebug (PHP debugging)

Initiate xdebug-profiling via wget:

wget --post-data="XDEBUG_PROFILE=1" -qO /dev/null ""


Compile C source for KC 85/4 etc. in Docker container

docker run -v ${PWD}:/src/ -it z88dk/z88dk zcc +kc -create-app src/example.c -o example

Will create EXAMPLE.KCC that should be runnable using emulators.