Skip to content

Instantly share code, notes, and snippets.

@olafdietsche
olafdietsche / LICENSE.txt
Created December 19, 2025 15:34
Minimal Unix init process (taken from https://ewontfix.com/14/)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@olafdietsche
olafdietsche / setup-raid1.sh
Last active December 29, 2025 13:32
Setup encrypted RAID 1
#! /bin/sh
# usage: $0 <device1> <device2>
# $0 /dev/sda1 /dev/sdb1
if test $# -ne 2; then
echo "usage: $0 <device1> <device2>" >&2
exit 2
fi
device1="$1"
@olafdietsche
olafdietsche / build-debian-image.sh
Last active December 26, 2025 21:04
Create a minimal debian image
#! /bin/bash
#
# usage: TMPDIR=/path/to/tmp bash $0 <image-path> <debian-release> [<debian-mirror>]
# sudo TMPDIR=/path/to/tmp bash build-image.sh /path/to/file.img trixie "file:///path/to/mirror-debian"
# sudo TMPDIR=/path/to/tmp bash build-image.sh /dev/sdx trixie
usage()
{
echo "usage: $0 <image-file/block-device> <debian-release> <debian-mirror>" >&2
exit 2
@olafdietsche
olafdietsche / make-debian-mirror.sh
Created December 10, 2025 17:56
Create a Debian mirror from /var/cache/apt, /var/lib/apt and /var/lib/dpkg. Mirror directory can then be used as "file:///path/to/mirror"
#! /bin/bash
if test $# -ne 2; then
echo "usage: $0 <chroot-dir> <mirror-dir>" >&2
exit 2
fi
chroot_dir="$1"
mirror_dir="$2"
@olafdietsche
olafdietsche / gist:a366bf8f0ec62b7caa0e3f99a5764030
Last active February 16, 2023 22:58 — forked from whosaysni/gist:5733660
Hello world with Xlib.
/*
hellox -- Hello world with Xlib.
$(CC) -o hellox hellox.c -lX11 -L/usr/X11/lib
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@olafdietsche
olafdietsche / fiddle.css
Created September 12, 2014 21:26
CSS: rotate an image on hover
img:hover {
transform: rotateY(180deg);
transition: all 1s ease 0s;
}
img {
transition: all 1s ease 0s;
}
@olafdietsche
olafdietsche / fiddle.css
Last active August 29, 2015 14:02
HTML and CSS only license badge, see [Badge-Poser](https://github.com/PUGX/badge-poser)
.badge {
font-family: DejaVu Sans, Verdana, Geneva, sans-serif;
font-size: 11px;
color: white;
}
.badge.tag {
background-color: #4c4c4c;
padding: 2px 4px 3px 7px;
border-radius: 4px 0 0 4px;
@olafdietsche
olafdietsche / fiddle.css
Last active August 29, 2015 14:01
Web: Input field with background image to the right
.valid {
background-image: url(http://lorempixel.com/20/20);
background-repeat: no-repeat;
background-position: right center;
padding-right: 25px;
}
@olafdietsche
olafdietsche / fiddle.js
Last active November 24, 2020 03:36
Javascript: get localStorage maximum size
if (!localStorage) {
console.log('unavailable');
} else {
var max = 'x', s;
var lower_bound = 1, upper_bound = 1, middle;
// determine lower and upper bound
try {
while (true) {
localStorage.setItem('test', max);