Skip to content

Instantly share code, notes, and snippets.

alvarow /
Created August 20, 2018 15:49
Using Let's Encrypt SSL with Subsonic
alvarow / select-csv.sql
Created November 17, 2017 15:49
MySQL SELECT into a CSV file
View select-csv.sql
SELECT name,organization,orgid,associateid FROM client JOIN client_key WHERE client.client_ident = client_key.client_ident INTO OUTFILE '/tmp/clients.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';
alvarow / wp-config.php
Created October 24, 2017 20:39
Wordpress sample config
View wp-config.php
* The base configurations of the WordPress.
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
* This file is used by the wp-config.php creation script during the
alvarow /
Created October 24, 2017 13:20
Encrypts & Decrypts single files using OpenSSL
# Source it on .bash_profile
# run with "encrypt a.file" or "decrypt a.file.aes-128-cbc"
# You can adjust encryption cipher (say aes-256-cbc) to your needs
function encrypt() {
if [ $# -eq 0 ]; then
echo "Provide a filename to encrypt"
exit 1
# SHA256 the given file
openssl dgst -sha256 "$1" > "$1.sha256"
alvarow / squid-xff-log.conf
Created February 9, 2017 21:49
Sets Squid Proxy to log IP address from X-Forwarded-For header instead of the real client ip address if the X-Forwarded-For header exists.
View squid-xff-log.conf
# Has XFF header with a value
acl has-xff req_header X-Forwarded-For ^(([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)|(\[([0-9a-f]+)?:([0-9a-f:]+)?:([0-9a-f]+|0-9\.]+)?\]))
# default logformat
logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
# default logformat using XFF instead of client IP address
logformat squid-xff %ts.%03tu %6tr %{X-Forwarded-For}>h %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
alvarow /
Created February 9, 2017 17:55
My AWS CLI ECS cheat sheet
# Get number of running containers of a service
aws --profile saml --output json ecs describe-services --cluster DIT-DMZ --service adp-e-bot-kafka | jq '.services[]|.desiredCount'
# Get a list of all task definitions
aws --profile saml --output text ecs list-task-definition-families
# Get the JSONs of a task definition
aws --profile saml --output json ecs describe-task-definition --task-def DIT-adp-e-bot | jq '.taskDefinition|if .networkMode then {family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, networkMode: .networkMode} else {family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions} end'
# Get all task definition and save each as a JSON
alvarow / apache-xff-log.conf
Created February 9, 2017 17:48
Sets Apache Log of the X-Forwarded-For client IP address or the real client ip address if the X-Forwarded-For header does not exist.
View apache-xff-log.conf
# Log the X-Forwarded-For client IP address or the real client ip address if the X-Forwarded-For header does not exist.
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
CustomLog "logs/access_log" combined env=!forwarded
CustomLog "logs/access_log" proxy env=forwarded
alvarow / tunnelbroker-update.cron
Created December 18, 2016 17:05
Crontab to update Hurricane Electric's IPv6 listed tunnel's client endpoint to the IP address making the update request.
View tunnelbroker-update.cron
*/15 * * * * alvaro /usr/bin/curl -q -o /dev/null
alvarow / boot-up-actions.plist
Created September 28, 2016 00:01
Launchd task to run a shell script on macOS boot up. It can be used to add things such as extra IP addresses, etc.
View boot-up-actions.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
alvarow / extra.loopback.alias.plist
Created September 19, 2016 01:58
How to add an extra loopback IP address on your MacOS
View extra.loopback.alias.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<!-- copy to /Library/LaunchDaemons/extra.loopback.alias.plist -->
<plist version="1.0">
<string>Loopback Alias</string>