Skip to content

Instantly share code, notes, and snippets.

View ceving's full-sized avatar
💭
Ejaculating

ceving

💭
Ejaculating
View GitHub Profile
@ceving
ceving / registration_code.md
Created April 25, 2024 12:15
Registration Code

Registration Code Generation

This function creates a registration code with 8 ASCII characters. The aim is to send a user a secret, which can be easily copied by the user into a registration dialog. The secret uses a reduced alphabet of 32 letters and digits. Characters known to be commonly confused by users are removed. The secret is not a password. It is just a personal token to enable the registration in order to prevent annonymous registration attempts.

@ceving
ceving / recover.go
Created April 25, 2024 07:04
Go recover with stack trace
package main
import (
dbg "runtime/debug"
fmt "fmt"
os "os"
tm "time"
)
func outer() {
@ceving
ceving / Web Component for Copyright Years.md
Last active April 21, 2024 09:46
Web Component for Copyright Years
@ceving
ceving / Find all Go CVEs.md
Last active March 13, 2024 10:35
Find all Go CVEs

Find all Go CVEs

Suppose you have cloned https://github.com/CVEProject/cvelistV5

Find all CVE-IDs for which the assignerShortName of the cveMetadata is "Go":

find cves -type f -name 'CVE-*.json' -exec cat {} + |
  jq -r '.cveMetadata | select(.assignerShortName == "Go") | .cveId'
@ceving
ceving / jless
Created March 13, 2024 10:09
Jq with colored pager
#! /bin/bash
if [[ -e "$1" && ! -d "$1" ]]; then
jq -C . "$@"
else
jq -C "${@-.}"
fi |
less -R
@ceving
ceving / bounce.html
Last active February 14, 2024 20:52
Bouncing Ball with requestAnimationFrame in JavaScript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bounce</title>
<style>
body { background: silver; }
canvas { background: white; }
span.sign { display: inline-block; white-space: pre; width: 1ch; text-align: center; }
span.number { display: inline-block; white-space: pre; }
@ceving
ceving / screenshot.sh
Created February 1, 2024 16:44
Bash script to take a screenshot
#! /bin/bash
set -eu
usage() { echo "Usage: $0 [-w WAIT] [PNGFILE]" 1>&2; }
while getopts "w:h" o; do
case "${o}" in
w) wait=$((OPTARG));;
h) usage; exit 0;;
*) exit 1;;
@ceving
ceving / Endliche Automaten.md
Last active January 31, 2024 14:24
Endliche Automaten

Endliche Automaten

Grundlage des folgenden Codes ist das Video "[Endliche Automaten][1]". Der Code ist mit [Gambit Scheme][2] getestet worden.

Kürzel Bedeutung
S Nichtleere endliche Menge von Zuständen
I Eingabealphabet
δ Übergangsfunktion von S ⨉ I nach S
@ceving
ceving / Processing tabular data with JQ instead of AWK.md
Last active January 26, 2024 08:59
Processing tabular data with JQ instead of AWK

Processing tabular data with JQ instead of AWK

The following produces a table with two columns: a date and a file name.

$ find /etc/network -type f -printf '%T@\t%p\n'
1670618223.0000000000   /etc/network/if-down.d/resolved
1689161114.2422386520   /etc/network/interfaces
1673911860.0000000000   /etc/network/if-up.d/ntpsec-ntpdate
1670618223.0000000000   /etc/network/if-up.d/resolved
@ceving
ceving / WASM-Instructions_in_JSON.md
Last active January 15, 2024 14:54
WASM Instructions in JSON