Skip to content

Instantly share code, notes, and snippets.

View mhvelplund's full-sized avatar
🦄
SwissArmyRonin

Mads Hvelplund mhvelplund

🦄
SwissArmyRonin
View GitHub Profile
@mhvelplund
mhvelplund / scan-versions.sh
Created February 26, 2021 20:21
Scan a Terraform module for dependencies that can be upgraded.
#!/usr/bin/env bash
set -euo pipefail
modules=($(grep -r --exclude-dir={examples,.terraform} --include '*.tf' '\"git@github.com:' | cut -d ":" -f3 | cut -d "\"" -f1 | sort -u))
declare -A latest_versions needs_upgrade
for module in ${modules[@]}; do
if [[ $module =~ ([^\/]+)\/([^\.]+)[^?]+\?ref=(.+) ]]; then
@mhvelplund
mhvelplund / README.md
Last active September 21, 2020 11:53 — forked from steenkamby/README.md
Fresh mac install

install dev tools on a fresh mac

Run the script a couple of times to get through everything. Re-run later to update versions.

If you feel lucky:

bash <(curl -s https://gist.githubusercontent.com/steenkamby/e3ab7c35d2a08b1df1ef01c920999104/raw/1f3177546a3b31c857ae7d563dff0ec2d452ed93/install_mac.sh)
@mhvelplund
mhvelplund / Makefile
Last active July 24, 2020 07:05
NASM project for VS Code
%.o : %.asm
nasm -felf64 -F dwarf $< -o $@
hello: greet.o write.o readline.o termio.o
ld $^ -o $@
clean:
rm -f *.o hello
@mhvelplund
mhvelplund / memorydb.clj
Last active March 12, 2020 16:28
Clojure workshop memory db
(def memory-db "A blank database" (atom {}))
(defn read-db "Return the entire database" [] @memory-db)
(defn write-db "Update the database" [new-db] (reset! memory-db new-db))
(defn create-table "Create a new table" [table]
(write-db (assoc-in (read-db) [table] {:data [], :indexes {}})))
(defn drop-table "Destroy a table" [table]
(write-db (dissoc (read-db) table)))
@mhvelplund
mhvelplund / aws-login.sh
Created January 21, 2020 18:02
Create temporary AWS credentials using ADFS2 SAML.
#!/bin/bash
# If you're unfamiliar with this syntax,
# $1, $2 ... are the position arguments
# to this script. The ${1:-DEFAULT} means
# that if there is no argument given,
# DEFAULT is used.
# So you could either fill in the defaults
# and only type your password, or you could
# call
@mhvelplund
mhvelplund / aws-ssm-ec2-proxy-command.sh
Last active October 2, 2019 11:31
AWS SSM SSH ProxyCommand
#!/usr/bin/env sh
set -eu
######## Usage #################################################################
#
# #1 Install the AWS CLI
# https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
#
# #2 Install the Session Manager Plugin for the AWS CLI
# https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html

Keybase proof

I hereby claim:

  • I am mhvelplund on github.
  • I am mhvelplund (https://keybase.io/mhvelplund) on keybase.
  • I have a public key ASDgxOPHeh-Al6Lu6gbgF800-aXUuJK8YsEIRhz7GBaqUwo

To claim this, I am signing this object:

@mhvelplund
mhvelplund / build.xml
Last active March 1, 2017 15:34
Introduce Maven in your Ant team, using ninja magics.
<?xml version="1.0" ?>
<project default="main">
<property name="maven_install_dir" value="maven_install" />
<property name="maven_version" value="apache-maven-3.3.9" />
<target name="get-maven" if="get.maven" description="Download Maven if needed">
<mkdir dir="${maven_install_dir}" />
<get src="http://ftp.download-by.net/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip" dest="${maven_install_dir}/apache-maven-3.3.9-bin.zip" />
<unzip src="${maven_install_dir}/apache-maven-3.3.9-bin.zip" dest="${maven_install_dir}" />
</target>