Skip to content

Instantly share code, notes, and snippets.

View cmer's full-sized avatar

Carl Mercier cmer

  • Toronto, ON, Canada
View GitHub Profile
@cmer
cmer / update_iptables.sh
Created November 8, 2020 02:22
Script to port-forward to a dynamic IP address. Run in CRON.
#!/bin/bash
HOST=myhost.example.com
IP=`dig +short $HOST | sed -e '1d'`
LAST_IP_FILE=/tmp/LAST_IP
LAST_IP=`cat $LAST_IP_FILE 2> /dev/null`
tcpPorts=(8080 8880 8843 8443)
udpPorts=(3478 10001)
@cmer
cmer / custom.sh
Last active July 6, 2020 07:57
Script to update Wireguard routes in DD-WRT
#!/bin/bash
while :
do
WGPROC=$(wg)
WGIF=$(ip route show gateway | grep -io oet1)
WGSERVER=$(/usr/sbin/nvram get oet1_rem0)
WANGWY=$(/usr/sbin/nvram get wan_gateway)
WANIF=$(/usr/sbin/nvram get wan_iface)
@cmer
cmer / install_last.sh
Created June 16, 2020 19:05
Install last downloaded file on macOS
#/bin/bash
# Install the last downloaded file on macOS
dl_path=~/Downloads
last_dl=`ls -tl -A1 $dl_path/*.{dmg,pkg} | head -n1`
if [[ $last_dl == *.dmg ]]; then
echo "Installing DMG: $last_dl..."
VOLUME=$(hdiutil attach -nobrowse "$last_dl" | cut -f3 | tail -n1 ; exit ${PIPESTATUS[0]}) && (rsync -a "$VOLUME"/*.app /Applications/; SYNCED=$?
@cmer
cmer / gen-ssl.md
Last active May 30, 2020 02:25
Generating a wildcard self-signed SSL cert with custom Certificate Authority
@cmer
cmer / pump.sh
Created May 1, 2020 17:26
Control Kraken pump from OSX
#!/bin/bash -xe
# brew install libusb
# pip3 install git+https://github.com/jonasmalacofilho/liquidctl
# https://github.com/jonasmalacofilho/liquidctl/blob/master/docs/nzxt-kraken-x-3rd-generation.md
liquidctl set pump speed 100
liquidctl set ring color covering-marquee FC5C7D 6A82FB 1EFF48 C2F970 564D80
liquidctl set logo color breathing FC5C7D 6A82FB 4E5166 44344F
@cmer
cmer / rmssh
Last active August 12, 2019 01:58
Script to remove last attempted SSH host from ~/.ssh/known_hosts
#!/usr/bin/env ruby
host = ARGV[0].to_s
if host == ""
history_output = `cat ~/.bash_history | grep "^ssh\s" | tail -1`
host = history_output.sub(/^ssh\s/i, '').split("@").last.split(" ").first
end
puts `ssh-keygen -R #{host}`
@cmer
cmer / no_automount
Last active December 23, 2018 05:45 — forked from voltechs/no_automount
Add volume (UUID) to fstab to prevent automount (macOS)
#!/usr/bin/env ruby
# Usage: no_automount /Volumes/My\ Disk
if ARGV[0].nil?
puts "Usage: no_automount /Volumes/My\ Disk"
exit 1
end
diskinfo = `diskutil info '#{ARGV[0]}'`.gsub("\n\n", "\n").split("\n").collect do |b|
@cmer
cmer / gist:1724957
Created February 2, 2012 18:20
Hetzner EX 4S UnixBench
# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #
Version 5.1.3 Based on the Byte Magazine Unix Benchmark
Multi-CPU version Version 5 revisions by Ian Smith,

Keybase proof

I hereby claim:

  • I am cmer on github.
  • I am cmer (https://keybase.io/cmer) on keybase.
  • I have a public key whose fingerprint is D086 FC72 06E0 89F8 7FAE C495 E5F6 43EA 38F0 16D0

To claim this, I am signing this object:

@cmer
cmer / gist:6063133
Created July 23, 2013 15:10
Hetzner EX40 UnixBench
# # # # # # # ##### ###### # # #### # #
# # ## # # # # # # # ## # # # # #
# # # # # # ## ##### ##### # # # # ######
# # # # # # ## # # # # # # # # #
# # # ## # # # # # # # ## # # # #
#### # # # # # ##### ###### # # #### # #
Version 5.1.3 Based on the Byte Magazine Unix Benchmark
Multi-CPU version Version 5 revisions by Ian Smith,