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 / pcg-random.c
Last active November 20, 2015 14:10
Quickly generate a stream of random data
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <time.h>
#include <pthread.h>
// see https://github.com/imneme/pcg-c
#include "pcg_variants.h"
@fritschy
fritschy / dmenu_mount.py
Last active July 6, 2016 14:12
Simple dmenu pmount/pumount helper for removable block devices
#!/usr/bin/env python3
# dmenu removable devie mount/umount helper
import subprocess as subp, glob, sys, os, os.path as p
def error(msg):
sys.stderr.write('ERROR: %s\n' % msg)
subp.call(['i3-nagbar', '-t', 'error', '-m', 'ERROR: ' + msg, '-f', 'Monospace'])
sys.exit(1)
def get_removable_devices():
#!/bin/bash
# XXX not my work, just keeping it here for everyone to see, -fritschy
# Based in part on https://wincent.com/wiki/Fixing_the_baseline_on_the_Consolas_font_on_OS_X
function fail()
{
local error=${1:-Unknown error}
echo "Failed! $error"
exit 1
#!/bin/sh
set -eu
tpid=0
for id in $(xinput list --id-only)
do
if xinput list-props $id | grep -q "^Device 'SynPS/2 Synaptics TouchPad':"
then
#!/bin/sh
c=$1
max=$2
title=""
set -eu
[ "$c" = "" ] && exit 1
[ "$max" = "" ] && max=100 || { shift 2; title="$@ "; }
@fritschy
fritschy / flac-recode-mp3.py
Last active May 18, 2017 15:35
Recode a number of FLACs to mp3, python, multiprocess, needs mpv, flac, metaflac and lame
#!/usr/bin/env python3
# coding=UTF-8
from os import system, cpu_count, getpid
from os.path import isfile, split, splitext, join
from sys import argv, exit, stderr
from re import sub
from subprocess import call
from multiprocessing import Pool
from traceback import print_exc
#!/bin/sh
S="$1"
set -eu
I=$(xdpyinfo | grep focus:\ | cut -d\ -f4)
P=$(xprop -id $I | grep -m 1 _NET_WM_PID | cut -d\ -f3)
kill $S $P
@fritschy
fritschy / fullerene.hpp
Last active March 7, 2017 16:09
C++ wrapper around some of graphene @ https://github.com/ebassi/graphene
#ifndef FULLERENE_HPP
#define FULLERENE_HPP
#include <float.h>
#include <inttypes.h>
#include <stddef.h>
#include <graphene.h>
namespace C {
@fritschy
fritschy / gist:df184ea16fa794d8898a4ecd20327ade
Last active August 6, 2017 15:17
Chromium (59) on FreeBSD lockup fix
# set following sysctl settings in /boot/loader.conf
kern.ipc.shmseg=1024
kern.ipc.shmmni=1024
# (that is in addition to the instmsg setting)
# source: https://forums.freebsd.org/threads/36809/#post-206410
@fritschy
fritschy / mpc-status.sh
Last active August 25, 2017 08:12
Simple mpd status for use in i3status
#!/bin/busybox sh
set -eu
# reset
export LD_LIBRARY_PATH=
# call mpc once
STATUS=$(mpc|tr -s ' ')
FIRST=$(echo "$STATUS" | head -n1)