Skip to content

Instantly share code, notes, and snippets.

@ae-s
ae-s / switch-foo.c
Last active February 11, 2023 01:56
Fun with C: Braces Optional
$ gcc switch-foo.c -o switch-foo
$ ./switch-foo
Got 1 for 1
$
@ae-s
ae-s / ingest.sh
Last active February 11, 2023 01:55
Receipt ingestion machine
#!/bin/bash
display -sample 600 $1 2>&1 >/dev/null &
viewer_pid=$!
sleep 0.5
echo '===='
echo 'What is the date shown? YYYY-MM-DD'
read -p 'date> ' -e -i "$date" date
@ae-s
ae-s / hexdump.c
Last active February 11, 2023 01:55
Hexdump suitable for debugging
#include <ctype.h>
#include <stdio.h>
void hexdump(void *ptr, int buflen) {
unsigned char *buf = (unsigned char*)ptr;
int i, j;
for (i=0; i<buflen; i+=16) {
printf("%06x: ", i);
for (j=0; j<16; j++)
if (i+j < buflen)
@ae-s
ae-s / xmodmap.onehand-colemak
Last active February 11, 2023 01:53
Single-hand keyboard with xmodmap
keycode 29 = j J g G
keycode 30 = l L p P
keycode 31 = u U f F
keycode 32 = y Y w W
keycode 33 = semicolon colon q Q
keycode 43 = h H d D
keycode 44 = n N t T
keycode 45 = e E s S
keycode 46 = i I r R
keycode 47 = o O a A
@ae-s
ae-s / c-switch-continue.c
Last active February 11, 2023 01:52
Example of continue within a case statement, in C
#include <stdio.h>
int main(void)
{
int i = 0;
while (i < 5) {
i++;
printf("\n%d\n", i);
switch (i) {
case 1:
@ae-s
ae-s / .bashrc
Last active February 11, 2023 01:48
Host-dependent automatic prompt colorization
#!/bin/bash
# Put the contents of this file in your .bashrc, to
# get a prompt that is automatically a distinct,
# stable color on every host you log into.
# ^O puts terminal back into default text mode for every prompt,
# preventing random glyphs.
resetterm="\[\017\]"
@ae-s
ae-s / unicode.7
Last active February 11, 2023 02:03
A manpage for unicode
This file has been truncated, but you can view the full file.
'\" t
.\" Copyright (c) 2013 Astrid Smith
.\" Created Sun Dec 22 21:21:39 PST 2013
.\"
.\" %%%LICENSE_START(WTFPL)
.\" DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
.\" Version 2, December 2004
.\"
.\" Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
.\"
@ae-s
ae-s / bbcode-quotes.txt
Last active February 11, 2023 02:04
bbcode is a nightmare
* bbcode is a nightmare
** quote formats
- [quote], [QUOTE]
- universal
- [quote name="{username}" post={post_id} timestamp={time_t}]
- [quote name="{username}" post={post_id}]
- [quote={username};{post_id}]
- vbulletin
- [QUOTED={username};{post_id}]
- kittyforums, rare
@ae-s
ae-s / Makefile
Last active February 11, 2023 02:06
# These are rules which don't correspond to an actual file
.PHONY: calibrate flatten
export MAGICK_TMPDIR=/tmp/3
# We maybe don't want to keep all these huge bitmaps lying around
#.INTERMEDIATE: out/%.ppm orig/%.ppm
# There is a tool ... which make knows how to compile ...
ppmunwarp: ppmunwarp.cc
@ae-s
ae-s / neighsupdate.sh
Last active February 11, 2023 02:12
nsupdate $(ip neigh list)
#!/bin/bash
# Tiny tool to run as a cronjob, which will update
# (using nsupdate) your zone files to include dhcp-
# and statelessly-assigned addresses.
# Space-separated list of address-to-name resolution methods to try.
# They'll be tried in the order listed here.
METHODS="hostfile avahi localdns"
# Zone to update for each type of IP address. In my home network,