Skip to content

Instantly share code, notes, and snippets.

View ndom91's full-sized avatar

Nico Domino ndom91

View GitHub Profile
@ndom91
ndom91 / create-raspi-docker-machine.sh
Created December 29, 2022 18:59
Create `docker-machine` Raspberry Pi
docker-machine create --driver generic --generic-ip-address 10.0.0.25 --generic-ssh-key ~/.ssh/id_ndo4 --generic-ssh-user ndo --engine-storage-driver overlay2 checkly-pi
@ndom91
ndom91 / totp.js
Last active June 14, 2022 07:28
js-totp (no dependencies)
// totp.js
// Description: Will generate a TOTP from 2FA Seed. No dependencies.
// Usage:
// import { TOTP } from './snippets/totp'
// console.log(TOTP(process.env.2FA_SEED))
//
// Sources:
// - Minor modernisation by ndom91
// - Minified pieces of [jsSHA](https://github.com/Caligatio/jsSHA)
// - [js-otp](https://github.com/jiangts/JS-OTP)
@ndom91
ndom91 / haproxy.cfg
Last active June 8, 2022 15:48
HAProxy JSON Body Routing Config
global
stats socket /var/run/api.sock user haproxy group haproxy mode 660 level admin expose-fd listeners
log stdout format raw local0 info
defaults
mode http
timeout client 10s
timeout connect 5s
timeout server 10s
timeout http-request 10s
@ndom91
ndom91 / upgrade_netbox.sh
Created April 28, 2022 21:51
Automated Upgrade Netbox Bash Script
#!/usr/bin/env bash
#########################################
#
# Netbox Update Script
# Author: ndomino
# Update: 28.04.2022
#
# Usage: sudo ./upgrade_netbox.sh [version_number]
# i.e.: sudo ./upgrade_netbox.sh 3.1.0
@ndom91
ndom91 / update-docker.sh
Created February 2, 2022 18:07
Watchtower Docker Update
#!/usr/bin/env bash
# Use 'containrrr/watchtower' to auto-update docker container image
# argv[1] is used as docker container name to update
docker run \
--rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--run-once \
"$1"
@ndom91
ndom91 / dmenu-emoji.sh
Created November 18, 2021 23:29
Dmenu Emoji Script
#!/bin/bash
set -e
case "$1" in
"list")
data=$(sed '0,/^__DATA__$/d' "$0")
echo "$data"
;;
"copy")
@ndom91
ndom91 / covermyass.sh
Created November 2, 2021 22:18
covermyass
#!/usr/bin/env bash
LOGS_FILES=(
/var/log/messages # General message and system related stuff
/var/log/auth.log # Authenication logs
/var/log/kern.log # Kernel logs
/var/log/cron.log # Crond logs
/var/log/maillog # Mail server logs
/var/log/boot.log # System boot log
/var/log/mysqld.log # MySQL database server log file
@ndom91
ndom91 / monaco-completion.js
Last active October 8, 2021 19:50
Monaco Auto-complete Example
const snippets = [
'const example = autocompleteSuggestionFn1(() => console.log("this is an example function")'
];
const buildSuggestion = (model, position) => {
const suggestions = [];
// Contextually aware autocompletion, i.e. snippets in handlebars delimiters,
// This will allow you to only insert suggestions if the previous character is
// X, Y, or Z, for example.
@ndom91
ndom91 / mitmproxy.md
Last active March 22, 2025 22:42
How to use a MITM Proxy with any node app

mitmproxy

How-to man-in-the-middle your own application's traffic for debugging. Below is a quick step-by-step guide to putting mitmproxy between your hard-to-debug application's HTTP(s) network traffic and its destinations. Allowing you to spy on all requests, as well as modify and replay them. Theres a nice blog post with more screenshots and some explanation behind mitm-ing available here: https://earthly.dev/blog/mitmproxy/

1. Install dependencies

  1. global-agent - Global node proxy configuration via environment variables (npm) Optional - only necessary for proxying local node scripts/apps that don't have an explicit proxy option. a. $ npm i -g global-agent
  2. mitmproxy - Popular opensource python man-in-the-middle proxy with web interface (homepage)
@ndom91
ndom91 / watchtower.sh
Created February 24, 2021 14:07
Watchtowerr - Upgrade only specific containers
#!/usr/bin/env bash
CONTAINER=$1
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--run-once $CONTAINER