Skip to content

Instantly share code, notes, and snippets.

@mcenirm
mcenirm / cleanqueryparameters.js
Last active Oct 3, 2021
clean query parameters
View cleanqueryparameters.js
location.search=location.search.replace(/^\?/,"&").replace(/\&(utm_[^=]*)(=[^&]*)?/g,"").replace(/^\&/,"?")
@mcenirm
mcenirm / make-an-image.ps1
Created Jan 5, 2021
Make an image using PowerShell and System.Drawing
View make-an-image.ps1
#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 Jul 10, 2019
Show active servername and serveralias values in Apache httpd.conf
View list_servername_serveralias.sh
apacheconfigtool --lowercasenames --configpath $PWD --useapacheinclude conf/httpd.conf | jq -S '..|[.servername?,.serveralias?]|.[]|strings'
@mcenirm
mcenirm / README.md
Created May 18, 2019
Create multiboot USB stick on macOS
@mcenirm
mcenirm / camel2snake.jq
Last active Apr 27, 2019
Convert camel to snake in jq
View camel2snake.jq
def camel2snake:
gsub("(?<x>[A-Z][a-z]+)"; "_"+.x|ascii_downcase)|ltrimstr("_");
View bash test older than, newer than.md
$ 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 |

View convert_proftpdconf_to_json
#!/bin/bash
set -e
set -u
Usage () { cat >&2 <<EOF
Usage: $0
Convert proftpd.conf to naive JSON version
EOF
}
View bad-atcf-mirror
#!/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
Prepare the transferred-files log from `snowball cp` for easy comparison to `find . -type f -print`.
View prepare_snowball_transferred_files_log_for_comparison.bash
#!/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
Add `/usr/bin/pg_config` using alternatives when using RPMs from https://yum.postgresql.org/
View install_alternative_for_pg_config.sh
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