Skip to content

Instantly share code, notes, and snippets.

@tg-x
tg-x / kbd-nav.py
Last active April 2, 2021 21:50
uinput-mapper config for kbd nav layer
from uinputmapper.cinput import *
"""
Configuration for keyboard navigation layer
"""
mods = { }
def set_mod (mod, x):
mods[mod] = x
@tg-x
tg-x / spacenav.py
Last active April 2, 2021 20:16
uinput-mapper config for space navigator
from uinputmapper.cinput import *
"""
Configuration for a 3DConnexion SpaceNavigator as pointer device
"""
counter = { }
def every_nth (ev, n, val):
if ev not in counter:
@tg-x
tg-x / x-mpc
Last active March 17, 2021 19:23
x-mpc
#!/usr/bin/env zsh
# x-mpc console MPD client
# 1. shows history of played tracks
# useful for streams where history is not visible in regular clients
# 2. allows bookmarking favourite tracks by saving them to a file
fav=${MPD_FAV:-"$HOME/.mpd.fav"}
jobs=()
@tg-x
tg-x / node-tls-detect.js
Created February 20, 2011 02:48
TLS detection for node.js
/*
* Autodetect if SSL/TLS is used by having a look at the first incoming bytes
* This technique is from http://webview.jabberd.org/cgi-bin/viewvc.cgi/trunk/jadc2s/clients.cc?view=markup
*
* used heuristic:
* - an incoming connection using SSLv3/TLSv1 records should start with 0x16
* - an incoming connection using SSLv2 records should start with the record size
* and as the first record should not be very big we can expect 0x80 or 0x00 (the MSB is a flag)
* - everything else is considered to be unencrypted
*/