Skip to content

Instantly share code, notes, and snippets.

View borestad's full-sized avatar

Johan Borestad borestad

View GitHub Profile
@borestad
borestad / debug.txt
Last active February 14, 2024 13:51
github-actions debug filesystem
$ cd /etc/apt/sources.list.d
$ cat microsoft-prod.list
deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/ubuntu/22.04/prod jammy main
$ cat ubuntu-toolchain-r-ubuntu-test-jammy.list
deb https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu/ jammy main
# deb-src https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu/ jammy main
@borestad
borestad / debuggerdemo.js
Last active October 11, 2023 17:17
Node Debugger demo
/*
Simple demo to show how the node inspector works
✨ 1: Run with:
node --inspect-brk debuggerdemo.js
By default, the debug process runs on "ws://127.0.0.1:9229", but you can change the port. See node --help for more info
--inspect[=[host:]port] activate inspector on host:port (default: 127.0.0.1:9229)
--inspect-brk[=[host:]port] activate inspector on host:port and break at start of user script
@borestad
borestad / bash argument parsing.md
Created September 20, 2023 08:32
This code snippet processes command line arguments and assigns values to variables based on the provided options. It supports options like -o (for output), -ttl (for time to live), and their corresponding long forms (--output, --ttl). It also handles

bash argument parsing

Preview:
URL=$1
shift 1

while [ "$#" -gt 0 ]; do
  case "$1" in
    -o) OUTPUT="$2"; shift 2;;
    -ttl) TTL="$2"; shift 2;;
@borestad
borestad / unicode-arrows.txt
Created June 21, 2023 14:41
Arrows in Unicode
⟵ ⟶ ⟷ ← → ↓ ↑ ↕ ↔ ↖ ↘ ↗ ↙ ⇿ ⇽ ⇾ ⇄ ⇆ ⇈ ⇊ ⇉ ⇇ ⬱ ⇶ ⤡ ⤢ ↧ ↥ ↦ ↤ ↹ ⇐ ⇒ ⇔ ⇕ ⇑ ⇓ ⇗ ⇙ ⇖ ⇘ ⇦ ⇨ ⇧ ⇩ ⇳ ⇣ ⇡ ⇢ ⇠ ➙ ➝ ➞ ➘ ➚ ➛ ➡ ➟ ➠ ➜ ➥ ➦ ➢ ➣ ➤ ▶ ◀ ▼ ▲ ➲ ➧ ➽ ➾ ➪ ➩ ➱ ➯ ➴ ➶ ➷ ➹ ➳ ⬄ ⬀ ⬃ ⬁ ⬂ ⬇ ⬆ ⬍ ⬉ ⬊ ⬈ ⬋ ⤊ ⤋ ⟰ ⟱ ⇜ ⇝ ⬳ ⟿ ↜ ⬿ ↭ ⤳ ↝ ⤝ ⤞ ↚ ↛ ↞ ↠ ↟ ↡ ↢ ↣ ⤌ ⤍ ⬸ ⤑ ↼ ↽ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇋ ⇌ ⥪ ⥬ ⥫ ⥭ ⥍ ⥌ ⥊ ⥋ ⥎ ⥐ ⥏ ⥑ ⥒ ⥓ ⥔ ⥘ ⥖ ⥗ ↫ ↬ ↶ ↷ ↩ ↪ ⤶ ⤷ ⤴ ⤵ ⤣ ⤥ ⤤ ⤦ ⤾ ⤿ ⤸ ⤹ ⤺ ⤻ ↻ ↺ ⟳ ⟲ ⥁ ⥀ ↰ ↱ ↲ ↳ ⬐ ⬑ ⬎ ⬏ ⬲ ⟴ ⥺ ⭄ ⥂ ⥃ ⥆ ⥅ ⥻ ⥹ ⇱ ⇲ ↯
@borestad
borestad / sponge
Last active October 13, 2022 09:07
sponge - soak up standard input and write to a file (poor mans version)
#!/usr/bin/env bash
set -euo pipefail
#
# sponge - soak up standard input and write to a file
#
# NOTE: Poor mans versions of sponge
# ... to avoid having to 'apt-get install moreutils' and perl dependencies) in CI pipeline
# Example Usage:
#!/bin/bash
echo "Cleaning Linux Headers"
#echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge
#dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
echo ""
echo "Cleaning orphan .deb packages"
deborphan | xargs sudo apt-get -y remove --purge
echo ""
<!DOCTYPE html>
<html>
<head>
<title>Akamai | Hello world</title>
<meta name="viewport" content="width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
#!/usr/bin/env bash
GITROOT=$(git rev-parse --show-toplevel)
ROOT=$GITROOT/packages/www
INPUT=$ROOT/public
OUTPUT=$ROOT/public
minifier=$ROOT/node_modules/.bin/html-minifier
# See: html-minifier --help
@borestad
borestad / h.ts
Created October 10, 2017 07:11
JSX/TSX without React
/*
* Custom jsx parser
* See: tsconfig.json
*
* {
* "jsx": "react",
* "jsxFactory": "h"
* }
*
*/
###
# This script assumes 2 things
# 1. One have already downloaded the El Capitan ( /Applications/Install OSX El Capitan.app) installer through Appstore or at leaast put "Install OSX El Capitan.app" into the /Apps folder
# 2. A fresh 8 GB+ USB Memory is inserted and have the name "Untitled"
#
# Installation instructions:
# 1. Insert a USB stick into your computer (it will be totally erased - make sure you backup your important files on that USB)
# 2. Open up a terminal (Terminal.app, iTerm etc)
# 3. Fire up Disk utilities
# - I.e `open /Applications/Utilities/Disk\ Utility.app`