Skip to content

Instantly share code, notes, and snippets.

View ndom91's full-sized avatar

Nico Domino ndom91

View GitHub Profile
@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 25, 2024 07:40
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
@ndom91
ndom91 / hassio-supervisor-installer.sh
Created February 18, 2021 02:59
HomeAssistant Supervisor Installer Script
#!/usr/bin/env bash
set -e
function error { echo -e "[Error] $*"; exit 1; }
function warn { echo -e "[Warning] $*"; }
warn "This installer is no longer supported."
warn ""
warn "Home Assistant might work today, tomorrow maybe not."
warn ""
@ndom91
ndom91 / resizeimage.pl
Created February 14, 2021 15:38
Perl Resize Image
#!/usr/bin/perl
use utf8;
use 5.010;
use strict;
#use autodie;
use warnings;
#use diagnostics;
my $who = `whoami`;
@ndom91
ndom91 / installer_bash_script_example.sh
Created February 8, 2021 00:39
Great Basic Bash Installer Example
#!/bin/sh
#
# This script installs Dnote into your PATH (/usr/bin/local)
# Use it like this:
# $ curl https://raw.githubusercontent.com/dnote/dnote/master/install.sh | sh
#
set -eu
BLACK='\033[30;1m'
# Download Loki
curl -O -L "https://github.com/grafana/loki/releases/download/v2.0.0/loki-linux-amd64.zip"
# Extract Loki's binary
unzip "loki-linux-amd64.zip"
# Make it executable
chmod a+x "loki-linux-amd64"
# Move it to your bin path with the name "loki"