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 / git-history-to-xlsx.py
Created September 12, 2017 15:06
Create a useless AF spreadsheet from git history
#!/usr/bin/env python3
import xlsxwriter, os, re, sys
from os.path import join as pjoin, isdir
from datetime import timezone, datetime, timedelta
from pygit2 import Repository as GR, Tree, Blob, Diff, GIT_SORT_REVERSE, GIT_SORT_TIME
from functools import reduce
CONTEXT_LINES = 100
OUTFILE = 'winman-patches.xlsx'
@fritschy
fritschy / mpc-status.c
Created September 12, 2017 15:11
MPD status for i3status-rust
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
char buf[1024];
@fritschy
fritschy / save-opened-file.sh
Last active March 2, 2018 07:33
Recover a still open file from a long-running process that still has the file opened
#!/bin/sh
# the open is done right away, reading however, is done only after a
# connection is established to the unix domain socket. This keeps the file
# around, and also "waits" for the last write from the producer process to
# happen. (Tested with socat version 1.7.3.2(-1 debian testing)
socat open:/proc/$PID/fd/$FD unix-listen:/tmp/$PID.$FD.sock &
# Wait until the producer process exits, then "retrieve" the file.
socat unix-connect:/tmp/$PID.$FD.sock -> /tmp/the-file # -> it is!
@fritschy
fritschy / media-player-control.py
Created March 2, 2018 07:16
Control mpc or spotify, giving precedence to spotify
#!/usr/bin/env python3
from glob import glob
from os import readlink, getenv
from sys import argv, exit
def is_spotify():
for path in glob('/proc/*/exe'):
try:
if readlink(path) == '/usr/share/spotify/spotify':
@fritschy
fritschy / gist:8eaf5150ad17a0f890851f4bbc0c65bc
Created March 28, 2018 05:27
Firefox 57+ about:config apulse settings
## Some sandboy settings in firefox
1. Add /dev/snd/ to the write_path_whitelist
2. Add ioctl syscall (no. 16 for linux-amd64) to syscall_whitelist
## See the following
```
security.sandbox.content.level;3
security.sandbox.content.read_path_whitelist;
@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);
@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 / 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 / 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-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