Skip to content

Instantly share code, notes, and snippets.

View vaygr's full-sized avatar
🛡️

Val V vaygr

🛡️
View GitHub Profile
@vaygr
vaygr / opentype-bitmap.py
Created August 23, 2023 15:34
BDF/PCF to OTB font converter
#!/usr/bin/env python3
# opentype-bitmap - generate opentype bitmap (.otb) from BDF/PCF fonts
# NOTE
# Greater than version 20190413 is needed. Otherwise ensure your fontforge
# has commit 79f9e0b8442631ac39ab907af20b813ac584298f
import argparse
import fontforge
import gzip
@vaygr
vaygr / file_magic_numbers.md
Created December 21, 2022 19:21 — forked from leommoore/file_magic_numbers.md
File Magic Numbers

File Magic Numbers

Magic numbers are the first bits of a file which uniquely identify the type of file. This makes programming easier because complicated file structures need not be searched in order to identify the file type.

For example, a jpeg file starts with ffd8 ffe0 0010 4a46 4946 0001 0101 0047 ......JFIF.....G ffd8 shows that it's a JPEG file, and ffe0 identify a JFIF type structure. There is an ascii encoding of "JFIF" which comes after a length code, but that is not necessary in order to identify the file. The first 4 bytes do that uniquely.

This gives an ongoing list of file-type magic numbers.

Image Files

@vaygr
vaygr / spotify-desktop-send.lua
Created July 29, 2022 02:23
devilspie2 Spotify config
-- Move spotify to the designated desktop
local spotify_desktop = 5
if (get_application_name() == "Untitled window" and get_window_name() == "Untitled window") then
if get_process_name() == "spotify" then set_window_workspace(spotify_desktop) end
end
@vaygr
vaygr / gist:26e4386deb9f149e94887f7c4232c9f4
Created April 20, 2021 19:52
Monitor 3440х1440 split
xrandr --setmonitor VRT-LFT 1720/0x1440/1+0+0 DP-0;
xrandr --setmonitor VRT-RGT 1720/1x1440/1+1720+0 none;
xrandr --fb 3440x1440;
xrandr --fb 3440x1440;
@vaygr
vaygr / script-template.sh
Created December 15, 2020 17:58 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
#!/bin/bash
# Fetch layouts and make sure each entry is on a new line
layout_data=$(dwm-msg --ignore-reply get_layouts | jq --unbuffered -c '.[]')
# Create an associative array layout-address pairs
declare -A layouts
# Iterate over all layouts
for row in ${layout_data}; do
@vaygr
vaygr / .tmux.conf
Last active June 18, 2020 19:38
tmux config (rev 0)
bind -n F12 select-pane -t:.+
bind y set-window-option synchronize-panes
bind m select-layout tiled
bind X confirm-before -p "kill-window #W? (y/n)" kill-window
bind C new-session
bind L command-prompt -p "Link window from (session:window):" "link-window -s %% -a"
bind U unlink-window
bind r source-file ~/.tmux.conf\; display "Reloaded tmux config."
bind R refresh-client
# switch panes using Alt-arrow without prefix
@vaygr
vaygr / ovpn2cm.sh
Created May 30, 2019 21:29
OpenVPN to connman VPN configuration converter
#!/bin/sh
declare -i limit=5
usage() {
echo "Usage: $0 [-l <limit>] <name> <domain> <directory>"
echo
echo "Default limit: $limit"
}
@vaygr
vaygr / i3lock-2.10-no-pam.patch
Created May 18, 2019 16:35
i3lock no-PAM patch (v2.10)
+++ LICENSE-slock
@@ -0,0 +1,24 @@
+MIT/X Consortium License
+
+© 2015-2016 Markus Teich <[email protected]>
+© 2014 Dimitris Papastamos <[email protected]>
+© 2006-2014 Anselm R Garbe <[email protected]>
+© 2014-2016 Laslo Hunhold <[email protected]>
+
+Permission is hereby granted, free of charge, to any person obtaining a
@vaygr
vaygr / xp
Last active June 11, 2020 22:29
X window [un]pause
#!/bin/sh
case "$1" in
toggle)
pgrep -x xprop && pkill -x xprop && exit 0
IFS=$'\n' info=(`xprop _NET_WM_PID _NET_WM_NAME`)
pid=`echo ${info[0]} | awk '!/not found/ { print $3 }'`