Skip to content

Instantly share code, notes, and snippets.

View cbrunnkvist's full-sized avatar

Conny Brunnkvist cbrunnkvist

View GitHub Profile
@cbrunnkvist
cbrunnkvist / GRUB_INIT_TUNE.md
Last active June 13, 2024 02:31 — forked from ArtBIT/GRUB_INIT_TUNE.md
A collection of GRUB init tunes

Docs

http://wiki.thorx.net/wiki/GRUB

My tunes

That ringtone of the CTU intercom you know 😎

36600 740 22 0 10 740 22 0 60 740 22 0 10 740 22 0 180 1050 22 0 10 1050 22 0 10 1050 22 0 10 1050 22 0 20 520 22 0 10 520 22 0 10 520 22 0 10 520 22 0 10 520 22 0 10 520 22 0 10 520 22 0 10 520 22 (demo)

@cbrunnkvist
cbrunnkvist / shell
Created June 9, 2024 12:05
Colorize any log (ANSI, sed)
#!/bin/bash
echo "Starting screens with logs tailing ..."
colors="sed --unbuffered \
-e 's/\\(.*\\[ERROR.*\\)/\\o033[1;31m\\\1\\o033[0;39m/' \
-e 's/\\(.*\\[WARN.*\\)/\\o033[1;33m\\\1\\o033[0;39m/' \
-e 's/\\(.*\\[INFO.*\\)/\\o033[1;32m\\\1\\o033[0;39m/' \
-e 's/\\(.*\\[DEBUG.*\\)/\\o033[1;34m\\\1\\o033[0;39m/' \
-e 's/\\(.*\\[TRACE.*\\)/\\o033[1;35m\\\1\\o033[0;39m/'"
@cbrunnkvist
cbrunnkvist / perl locale warning
Last active June 6, 2024 10:06
How to resolve perl warnings about locale when SSH:ing from macOS into Debian/Ubuntu Linux
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
@cbrunnkvist
cbrunnkvist / performers_next_level.txt
Created June 8, 2023 13:34
Ode to the Noble Commodore 64
Ode to the Noble Commodore 64
06/03/23 13:37 PM
When, in the midst of Time's swift race,
Did mortals first spy Cyberspace,
And in their humble dwellings brought
Machines to weave their cyber-thought?
From whence did spring this wondrous beast,
This great enabler of the least,
@cbrunnkvist
cbrunnkvist / c-tap-test.h
Created February 18, 2023 16:38
TAP (Test Anything Protocol) in C
/* from https://www.lemoda.net/c/simple-tap-test/ */
static int tap_count;
static int tap_todo;
static int tap_fail;
#define ENDLINE { \
if (tap_todo) { \
printf (" # TODO\n"); \
} \
@cbrunnkvist
cbrunnkvist / avg_with_reduce.js
Last active July 26, 2022 13:52 — forked from ekrem-aktas/avg_with_reduce.js
the complexity comes from relying on a complex accumulator object instead just returning the average number ;)
const basket = [
{ name:"apple", type: "fruit", calories: 52 },
{ name:"broccoli", type: "vegetable", calories: 45 },
{ name:"banana", type: "fruit", calories: 89 }
];
class CaloriesAccumulator {
constructor(fruitCount = 0, avgCalories = 0) {
console.debug(`count: ${fruitCount}\tavg: ${avgCalories}`)
this.fruitCount = fruitCount
@cbrunnkvist
cbrunnkvist / docker-compose.with-adp-messaging.yml
Last active October 5, 2020 10:29
Allow stubbing ADP client log directory with (and without-) Docker Compose
version: "3.5"
services:
with-adp-messaging:
image: cmd.cat/grep
command: sh -c "mount|egrep --color=always 'adp-messaging|^'"
volumes:
# THIS IS THE IMPORTANT LINE - defaults to /var/log/adp-messaging when env is undefined
- ${ADP_MESSAGING_LOG_DIR:-/var/log/adp-messaging}:/var/log/adp-messaging
@cbrunnkvist
cbrunnkvist / encodeURI.sh
Last active November 12, 2019 07:24
echo $annoyingPath | encodeURI
# I actually just pasted this inline as part of a TC buildstep but hey, wanna get the Gist to color coding correctly
encodeURI() {
# for each char from stdin
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
for c in $(grep -o .)
do
case $c in
[a-zA-Z0-9.~_-/?=&]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
@cbrunnkvist
cbrunnkvist / ssh-keyscan.yml
Last active July 14, 2022 09:49
SSH keyscan all Ansible inventory
---
# in retrospect, it's better to just run e.g.
# ansible all -a true --ssh-extra-args="-o UpdateHostKeys=yes -o StrictHostKeyChecking=accept-new"
- hosts: all
gather_facts: false
tasks:
- name: Set custom SSH port fact (or use default)
delegate_to: localhost
set_fact:
@cbrunnkvist
cbrunnkvist / winkwink.sh
Last active October 1, 2018 13:23
E2E verification testing Node.js -> Scala ISOString datetime conversion
node -e 'd=new Date("2000-01-01");console.error(`Start JS: ${d}`);console.log(d)' \
| xargs scala -nc -e 'val d=java.time.OffsetDateTime.parse(args.head);System.err.println(s"In Scala: $d");println(d)' \
| xargs node -e 'd=new Date(process.argv.pop());console.error(`End JS: ${d} ;-)`);console.log(d)'