Skip to content

Instantly share code, notes, and snippets.

@mmh
mmh / pre-commit
Last active December 21, 2017 11:19
terraform fmt git pre-commit hook
#!/usr/bin/env bash
set -e
# Formats any *.tf files according to the hashicorp convention
files=$(git diff --cached --name-only)
for f in $files
do
if [ -e "$f" ] && [[ $f == *.tf ]]; then
#terraform validate `dirname $f`
terraform fmt $f
#!/bin/sh
# regex to validate in commit message
commit_regex='#[A-Z]{2,}-[0-9]+'
error_msg="Aborting commit. Your commit message is missing a JIRA Issue ('XXX-YY')"
if ! grep -qE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi
#!/bin/bash
# Download, extract and convert maxmind country db to varnish acl format for countries defines in the COUNTRIES array
# DB found here: http://dev.maxmind.com/geoip/geoip2/geolite2/
# [email protected], 2015
set -o errexit
set -o nounset
declare -A COUNTRIES=( [syria]=",SY," [sudan]=",SD," [northkorea]=",KP," [cuba]=",CU," [iran]=",IR,")
TMPDIR="/tmp/maxmind-geoip"
# Cleanup possible old run
if [ -d $TMPDIR ]; then
@mmh
mmh / gist:f98e6e9331077408dd4f
Created October 19, 2015 09:15
Maxmind to Varnish country ACL
#!/bin/bash
# Download, extract and convert maxmind country db to varnish acl format for countries defines in the COUNTRIES array
# DB found here: http://dev.maxmind.com/geoip/geoip2/geolite2/
# [email protected], 2015
set -o errexit
set -o nounset
declare -A COUNTRIES=( [syria]=",SY," [sudan]=",SD," [northkorea]=",KP," [cuba]=",CU," [iran]=",IR,")
TMPDIR="/tmp/maxmind-geoip"
# Cleanup possible old run
if [ -d $TMPDIR ]; then

Keybase proof

I hereby claim:

  • I am mmh on github.
  • I am mortenmh (https://keybase.io/mortenmh) on keybase.
  • I have a public key whose fingerprint is C9D3 3208 9DB0 839A AC8C F8EF CB68 A3EB D6BD 526F

To claim this, I am signing this object:

@mmh
mmh / gist:6657197
Created September 22, 2013 06:18
iTunes total
total=0;for i in $(egrep -iho 'I alt: [0-9,.]*\ ?Kr|Order Total: [0-9,.]*\ ?Kr' *.eml | sed 's/,/./g' | grep -o [0-9.]*);do total=$(echo $total + $i| bc -l);done;echo $total