Skip to content

Instantly share code, notes, and snippets.

View fritschy's full-sized avatar

Marcus Borkenhagen fritschy

  • Black Forest, Germany
View GitHub Profile
@fritschy
fritschy / Makefile
Created December 17, 2019 18:32
Sensible GNU Makefile Template
# Sensible Makefile Template
# Soure: https://web.archive.org/web/1/https://tech.davis-hansson.com/p/make/
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifeq ($(origin .RECIPEPREFIX), undefined)
@fritschy
fritschy / tcpdump-bpf-disasm.sh
Created December 17, 2019 11:01
How to disassemble a pcap BPF program
#!/bin/sh
(
echo -n load bpf ""
sudo tcpdump -ilo -ddd "$@" | tr '\n' ','
echo
echo disassemble
) | bpf_dbg
@fritschy
fritschy / Dockerfile
Created October 7, 2019 10:57
Loosely Debian-Based Docker image for blender
FROM debian:buster
ENV LD_LIBRARY_PATH /blender/lib
RUN apt update && \
apt install --no-install-recommends -y curl bzip2 libfreetype6 \
libx11-6 libxi6 libxrender1 libxxf86vm1 libxfixes3 runit \
busybox-static && \
mkdir /blender && curl -kSL https://mirror.clarkson.edu/blender/release/Blender2.80/blender-2.80-linux-glibc217-x86_64.tar.bz2 | \
tar -jx -C /blender --strip-components=1 && \
@fritschy
fritschy / Dockerfile
Last active July 29, 2019 13:04
Blender from source Dockerfile
FROM debian:buster
ENV LC_ALL C.UTF-8
RUN apt update
RUN apt install -y --no-install-recommends git
RUN git clone -j$(nproc) --recursive -b blender-v2.80-release git://git.blender.org/blender.git /usr/src/blender
#RUN git clone https://github.com/OpenImageIO/oiio /usr/src/oiio
@fritschy
fritschy / ffmpeg-one-liners.sh
Last active March 27, 2024 19:15
ffmpeg one-liners
# For all snippets, check documentation for details and settings.
# encode video from a V4L2 device, using specified settings.
# x265 worked somewhat better here and produced less skips (although uses 10x CPU compared to x264)
ffmpeg -f video4linux2 -framerate 30 -input_format mjpeg -video_size 1920x1080 -i /dev/video6 -c:v libx265 -preset ultrafast -c:a none -crf 20 out.mp4
# Convert a raw YUYV422 frame from my USB "microscope" to PNG:
# other valid pixel formats are e.g. rgb24 or yuv420p
ffmpeg -f rawvideo -video_size 2592x1944 -pixel_format yuyv422 -i input_yuyv422_2592x1944.dat -f image2 output.png
@fritschy
fritschy / anno-1503-gog.sh
Created February 6, 2019 20:40
Run Anno 1503 on Linux with Wine
#!/bin/sh
export WINEPREFIX=$PWD
case "$1" in
setup)
mkdir -p ~/Games/anno-1503
cd ~/Games/anno-1503
winetricks winxp directplay directmusic vd=off
case "$2" in
@fritschy
fritschy / off2obj.py
Created February 6, 2019 15:52
Convert OFF to OBJ
#!/usr/bin/env python3
import sys
num_vert, num_face, num_edge = 0, 0, 0
not_handled_lines = 0
expect_header = True
expect_count = None
expect_vertices = 0
expect_faces = 0
@fritschy
fritschy / anno-1602-gog.sh
Last active November 6, 2021 09:30
Run Anno 1602 on Linux with Wine
#!/bin/sh
export WINEPREFIX=$PWD
case "$1" in
setup)
mkdir -p ~/Games/anno-1602
cd ~/Games/anno-1602
winetricks winxp
winetricks ddr=gdi # do I need this?
@fritschy
fritschy / mouse-focus-win10.ps1
Last active January 25, 2019 09:36
Focus Follows Mouse for Windows 10
# According to: https://superuser.com/a/1209478/60220
$sinature = @"
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(int uAction, int uParam, ref
int lpvParam, int flags );
"@
$systemParamInfo = Add-Type -memberDefinition $signature -Name SloppyFocusMouse -passThru
[Int32]$newVal = 1
@fritschy
fritschy / bezier.hpp
Created January 5, 2019 17:39
Some bezier spline interpolation code
/// this is mix in glsl terms
template <typename T, typename S>
static inline float mix(T a, T b, S t) {
return (1 - t) * a + t * b;
}
template <typename T, typename S>
static inline T quadratic_bezier(T a, T b, T c, S t) {
T d = mix(a, b, t);
T e = mix(b, c, t);