Skip to content

Instantly share code, notes, and snippets.

@capezotte
capezotte / s6-comp.bash
Last active April 4, 2023 19:11
Bash completion for s6-rc (≥ 0.5.3.3)
#!/usr/bin/env bash
# bash completion for s6/s6-rc
# adds yet-unused options and actions to COMPREPLY
# side effect: sets _s6_action and _s6_opt_[A-Za-z0-9] variables if they are found
# usage: __s6_getopt optspec actions
# example: __s6_getopt v:l:t:n:audDp change diff
# example: __s6_getopt upo:
__s6_getopt() {
local i optspec="$1" opt opts='' optsarg=''
@capezotte
capezotte / iwd-dmenu.sh
Created November 26, 2022 19:58
iwd-dmenu
#!/bin/sh
# BEGIN: dependency boilerplate
test_cmd() { [ -x "$(command -v "$1" 2>/dev/null)" ]; }
for dep in busctl iwctl jq; do
test_cmd "$dep" || {
printf >&2 "Dependency '%s' not found.\n" "$dep"
exit 1
}
@capezotte
capezotte / zorgs.c
Created November 23, 2022 15:57
poor man's xargs (ft. skalibs)
#define SUBGETOPT_SHORT
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <poll.h>
#include <stdlib.h>
#include <spawn.h>
#include <sys/wait.h>
#include <skalibs/types.h>
#include <skalibs/bytestr.h>
@capezotte
capezotte / zpf.sh
Created May 23, 2022 02:34
ShrinkPDF (two step)
#!/bin/sh
# Modified from https://github.com/aklomp/shrinkpdf
# Licensed under the 3-clause BSD license:
#
# Copyright (c) 2014-2022, Alfred Klomp
# Copyright (c) 2020-2022, Carlos E.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@capezotte
capezotte / kate-syntax-jq.xml
Created February 14, 2022 16:25
Kate Syntax for JQ
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language name="jq" section="Scripts" extensions="*.jq" mimetype="" version="2" kateversion="5.0" author="oc1024" license="LGPL" indenter="python">
<highlighting>
<list name="builtins">
<item>not</item>
<item>length</item>
<item>utf8bytelength</item>
<item>keys</item>
@capezotte
capezotte / Replacing_Udev.md
Last active November 11, 2023 00:08
Instructions on replacing udev/eudev on Artix

Replacing udev on Artix Linux

Reminder this is UNSUPPORTED. Reproduce bugs on a stock install with xudev/eudev before reporting them.

Preparations

Do not reboot until you've done them all.

Step 1 - remove udev

@capezotte
capezotte / paragraphify.sed
Last active December 27, 2022 02:20
fmt -w600, sed edition
#!/usr/bin/sed -nf
# First line: only hold and skip.
1 { h;d; }
# Line with only spaces: wow, free paragraph information!
/^\s*$/ { s/^.*$//; bfinished }
# Append line to hold space.
H
# Line ends with dot? We have a new paragraph.
/\.$/bfinished
# Render last line
@capezotte
capezotte / regional-emoji.awk
Created May 12, 2021 21:38
Text-to-Emoji gawk script
#!/usr/bin/gawk -f
# GAWK because unicode
# Keycap boilerplate
function keycap(k) { return sprintf("%c%c%c",k "",65039,8419); }
BEGIN {
# Regex of included characters
unmatch="[^-[:blank]"
# A-Z (regional indicators are also a continuous range)
for (i=65;i<=90;i++) { regional[sprintf("%c",i)] = sprintf("%c",i+127397); }
@capezotte
capezotte / compression-benchmark.py
Last active March 22, 2021 02:16
Testing multiple compression algorithms
#! /usr/bin/env python3
# Finds files in the "in" subfolder of the current working directory,
#
# loads them into memory,
# dumps them into a compressor program's stdout,
# loads the stdout into memory,
# then dump 'em again into a decompressor's stdin.
#
# Logs ratio, compression and decompression speeds
# to stdout (each file MiB/s) and to a log.csv (average B/s) into the current working directory