Skip to content

Instantly share code, notes, and snippets.

gen_dev_config() {
if [[ -z "$1" ]]; then
echo "Usage: gen_site_config <site_name>";
echo;
return 1;
fi
password=$(</dev/urandom tr -dc '0-9!@#$%a-zA-Z' | head -c16; echo "");
underscores=$(echo "$1" | sed 's/\./_/g' | sed 's/-//g');
dev_underscores=$(echo "dev_$underscores");
@weaver299
weaver299 / bash_escaping.sh
Last active September 5, 2018 16:19
Can't output desired string with "..." in bash??
#!/usr/bin/env bash
# This outputs "\$conf" as desired
echo $'s/^(\\$conf\\[\'simplesamlphp_auth_installdir\'\\] = .*)/if(whatever){ $1 } else { whatever };/'
# Yes, it can also be done with this craziness
echo 's/^(\$conf\['"'"'simplesamlphp_auth_installdir'"'"'\] = .*)/if(whatever){ $1 } else { whatever };/'
# But it doesn't seem to be possible with "..." ?
echo "s/^(\$conf\['simplesamlphp_auth_installdir'\] = .*)/if(whatever){ \$1 } else { whatever };/"
@weaver299
weaver299 / gist:e44185e548196db038afcfba145c11c2
Created May 7, 2018 15:41
check what a URL redirects to
check_redirect () {
echo -n "$1: ";
curl -is "$1" | grep '^Location:' | perl -pe 's/^Location: //;chop;'
echo;
}