Skip to content

Instantly share code, notes, and snippets.

@mcenirm
mcenirm / cleanqueryparameters.js
Last active October 3, 2021 04:54
clean query parameters
location.search=location.search.replace(/^\?/,"&").replace(/\&(utm_[^=]*)(=[^&]*)?/g,"").replace(/^\&/,"?")
@mcenirm
mcenirm / make-an-image.ps1
Created January 5, 2021 21:06
Make an image using PowerShell and System.Drawing
#Requires -Version 2
# https://stackoverflow.com/a/2068019
Add-Type -AssemblyName System.Drawing
$filename = "$psscriptroot\foo.png"
$bmp = new-object System.Drawing.Bitmap 250, 61
$font = new-object System.Drawing.Font Consolas, 24
$brushBg = [System.Drawing.Brushes]::Yellow
@mcenirm
mcenirm / list_servername_serveralias.sh
Created July 10, 2019 15:33
Show active servername and serveralias values in Apache httpd.conf
apacheconfigtool --lowercasenames --configpath $PWD --useapacheinclude conf/httpd.conf | jq -S '..|[.servername?,.serveralias?]|.[]|strings'
@mcenirm
mcenirm / README.md
Created May 18, 2019 16:27
Create multiboot USB stick on macOS
@mcenirm
mcenirm / camel2snake.jq
Last active April 27, 2019 16:03
Convert camel to snake in jq
def camel2snake:
gsub("(?<x>[A-Z][a-z]+)"; "_"+.x|ascii_downcase)|ltrimstr("_");
$ names=(missing older newer);echo '```';for op in -ot -nt;do echo;echo "# a $op b";echo;for a in "${names[@]}";do echo -n \|;for b in "${names[@]}";do echo -n " \`$a $op $b\` = ";test "$a" "$op" "$b";echo -n "$? |";done;echo;done;done

a -ot b

| missing -ot missing = 1 | missing -ot older = 0 | missing -ot newer = 0 | | older -ot missing = 1 | older -ot older = 1 | older -ot newer = 0 | | newer -ot missing = 1 | newer -ot older = 1 | newer -ot newer = 1 |

#!/bin/bash
set -e
set -u
Usage () { cat >&2 <<EOF
Usage: $0
Convert proftpd.conf to naive JSON version
EOF
}
#!/bin/bash
set -e
set -u
top='http://ftp.nhc.noaa.gov/atcf/'
folders=(
# adv
# aid_public
# btk
# com
@mcenirm
mcenirm / prepare_snowball_transferred_files_log_for_comparison.bash
Created May 21, 2017 15:05
Prepare the transferred-files log from `snowball cp` for easy comparison to `find . -type f -print`.
#!/bin/bash
set -e
set -u
Usage () { cat >&2 <<EOF
Usage: $0 < /tmp/snowball-xxx/transferred-files
Prepare the transferred-files log from 'snowball cp'
for easy comparison to 'find . -type f -print'.
(Reads from stdin and writes to stdout.)
EOF
@mcenirm
mcenirm / install_alternative_for_pg_config.sh
Created May 9, 2017 16:47
Add `/usr/bin/pg_config` using alternatives when using RPMs from https://yum.postgresql.org/
pg_major=9
pg_minor=5
alternatives --install /usr/bin/pg_config pgsql-pg_config /usr/pgsql-${pg_major}.${pg_minor}/bin/pg_config ${pg_major}${pg_minor}0