Skip to content

Instantly share code, notes, and snippets.

@acidDrain
acidDrain / event-loop.ts
Created May 19, 2023 20:00
Demonstrate the JavaScript event-loop
console.log("Before setTimeout\n");
setTimeout((): void => {
// prints out "2", meaning that the callback is not called immediately after 500 milliseconds.
console.log("Inside 'setTimeout' callback\n");
}, 1000);
console.log("After 'setTimeout'\n");
@acidDrain
acidDrain / Azure-Incident-az-prod-zone.md
Created September 10, 2021 17:32
Summary and Root Cause of Accidental Infrastructure Deletion in Azure
@acidDrain
acidDrain / pipe-to-container.md
Created August 26, 2021 01:41
Example of how to pipe output into a container
# This is how piping a file into a container could be done for a build.
# The container’s ID will be printed after the build is done and the build logs
# could be retrieved using docker logs. This is useful if you need to pipe a
# file or something else into a container and retrieve the container’s ID once
# the container has finished running.
#
# See https://docs.docker.com/engine/reference/commandline/run/#attach-to-stdinstdoutstderr--a

$ date | docker run -i -a stdin debian:buster sh -c 'printf "%s\\n" "Hello world $@" && cat -'
@acidDrain
acidDrain / st.info
Created July 27, 2021 22:25
st.info - Terminal info - use tic -sx st.info
st-mono| simpleterm monocolor,
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
am,
bce,
bel=^G,
blink=\E[5m,
bold=\E[1m,
cbt=\E[Z,
cvvis=\E[?25h,
civis=\E[?25l,
@acidDrain
acidDrain / sxhkdrc
Last active June 16, 2021 17:22
My sxhkdrc configuration
#!/usr/bin/env sh
# vim: noexpandtab:softtabstop=0:
#
# wm independent hotkeys
#
# suckless' simple terminal emulator
super + Return
st
@acidDrain
acidDrain / bash-script-template.sh
Last active November 15, 2021 05:15
bash scripting template
#!/usr/bin/env bash
# vim: ft=sh:
# Obtained from
# https://betterdev.blog/minimal-safe-bash-script-template/
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
@acidDrain
acidDrain / generateRange.js
Last active March 2, 2021 08:34
Generate an array of length n in JavaScript
const generateRange = rangeLength => Array.from({ length: rangeLength }, (_,i) => i);
console.log(generateRange(20));
[
0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19
]
@acidDrain
acidDrain / 404.html
Last active June 2, 2022 14:19
404 html page and css
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Error 404 (Not Found)</title>
<style>
html {
box-sizing: border-box;
@acidDrain
acidDrain / mount-raw-disk-img.sh
Last active November 17, 2020 01:46
Script demonstrating mounting a raw disk image with multiple partitions from zsh
#!/usr/bin/env bash
fdisk -l 2020-08-20-raspios-buster-arm64.img
### Example Output
# Disk 2020-08-20-raspios-buster-arm64.img: 3.5 GiB, 3779067904 bytes, 7380992 sectors
# Units: sectors of 1 * 512 = 512 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes