Skip to content

Instantly share code, notes, and snippets.

@goofrider
goofrider / LinkAgg
Created June 28, 2023 02:09
Link aggregation script for Asuswrt-Merlin
#!/bin/sh
# Written By KAD
# Dynamic Link Aggregation Setup
# Version 1.5
# see https://github.com/RMerl/asuswrt-merlin.ng/wiki/Link-Aggregation
Help()
{
echo -e "\n---- Link Aggregation Version 1.5 Help ----"
echo -e "\nDynamically enable Link Aggregation using 802.3ad"
@goofrider
goofrider / rm-frontmatter.js
Last active May 18, 2023 18:30
Regex for Removing YAML Front Matter before processing Jekyll file in Gulp
// taken from https://codepen.io/tech4him1/pen/dNyydZ
var replace = require('gulp-replace');
// Regex to recognize YAML Front Matter (at beginning of file, 3 hyphens, than any charecter, including newlines, then 3 hyphens).
var YAMLFrontMatter = /^---[.\r\n]*---/;
gulp.src('./!(_)**/*.md')
.pipe(replace(YAMLFrontMatter, ''))
.pipe(gulp.dest('./'));
@goofrider
goofrider / multipass-resize.md
Last active May 17, 2023 04:52
Changing CPU/hard disk/RAM size of a multipass instance

How to resize hard disk of a multipasss instance on osx

(see canonical/multipass#62)

    # if you have Docker Desktop installed
    
    sudo /Applications/Docker.app/Contents/MacOS/qcow-tool resize --size=$(( 15 * 1024**3 )) /var/root/Library/Application\ Support/multipassd/vault/instances/ubuntu20/ubuntu-20.04-server-cloudimg-amd64.img 

or

@goofrider
goofrider / jq-cheatsheet.sh
Last active September 26, 2020 19:42
[jq cheatsheet] Basic jq usage #jq #json
#### jq: sort by key value
jq '. | sort_by(.name)'
# Input
# [{name: "casey","age":54}, {"name": "Mary", "age":31}, {"name": "John", "age":20}]
# Output:
# [{"name": "John", "age": 20}, {"name": "Mary", "age":31}.{"name": "casey", "age":54}]
#### jq: filter by key value
@goofrider
goofrider / brew-show-orphans.sh
Last active January 30, 2024 09:48
Show all orphaned Homebrew formulas installed on your system that are safe to uninstall
#! /bin/sh
# Homebrew doesn't remember which formulas are installed by user and
# which are installed as dependancies, and it doesn't uninstall dependancies
# when you uninstall a formula.
#
# This script will how you find orphaned formulas that were insatlled as dependecies
# but no londer needed because you've unsintalled the parent packages.
#
# Usage:
@goofrider
goofrider / shell-one-liners.sh
Last active September 26, 2020 19:43
[shell one-liners] Some usefuel shell one-liners #shell #bash #zsh #sed
#### Remove YAML frontmatter. Requires GNU sed. OSX sed doesn't seem to work.
gsed '1 { /^---/ { :a N; /\n---/! ba; d} }
#### Remove '#' comments, empty lines and leading/trailing spaces
sed 's/#.*$//
s/[[:space:]]//g
/^$/d'
@goofrider
goofrider / to_json.rb
Created September 22, 2020 21:09
How to serializer Sawyer::Resource object to json?
# How to serializer Sawyer::Resource object to json?
# https://github.com/lostisland/sawyer/issues/34
require 'json'
sawyer_resource.map(&:to_h).to_json
@goofrider
goofrider / multipass-tmexclude.sh
Last active September 24, 2020 19:22
Exclude VM instances and download cache in Ubuntu Multipass on Mac OS from Time Machine backup
## Exclude VM instances and download cache in Ubuntu Multipass on Mac OS from Time Machine backup
## Once you added them to the exclusion list they will show up in the Time Machine prefpane exclusion dialog.
sudo tmutil addexclusion -p /var/root/Library/Application\ Support/multipassd/vault/instances/
sudo tmutil addexclusion -p /var/root/Library/Caches/multipassd/