Skip to content

Instantly share code, notes, and snippets.

@thalweg
thalweg / arch-linux-install
Created May 13, 2016 01:05 — forked from mattiaslundberg/arch-linux-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# Set swedish keymap
@thalweg
thalweg / simp_le_batch.sh
Last active March 29, 2016 17:15
Invoke https://github.com/kuba/simp_le for multiple domains
#!/usr/bin/env bash
here="$(cd "$(dirname "$0")"; pwd -P)"
cd "$here"
source venv/bin/activate
IFS=$'\n\t'
# if you want a cert with multiple DNS names (SubjectAlternateName), use space-delimited
# names in the string array below. e.g.: "example.org www.example.org" will result in
# a single certificate file with two SAN fields
domains=(
### Keybase proof
I hereby claim:
* I am thalweg on github.
* I am nlopez (https://keybase.io/nlopez) on keybase.
* I have a public key whose fingerprint is 55DF 016B 21FD A6AF 0982 87C6 8DA7 AACB F29F 440F
To claim this, I am signing this object:
@thalweg
thalweg / gist:5396274
Created April 16, 2013 14:19
Wrapper for aws-cli validate-template
#!/usr/bin/env bash
# A simple wrapper for validating locally-stored CloudFormation templates
# Requires aws-cli <https://github.com/aws/aws-cli>
usage(){
echo "$(basename $0) <cfn.json>"
}
if (( $# == 0 )); then
usage
exit 1
@thalweg
thalweg / two_factor_ssh.rb
Created January 6, 2013 06:26
TOTP authentication script that uses the ~/.google_authenticator file in the user's home directory. Based on https://moocode.com/posts/5-simple-two-factor-ssh-authentication
#!/usr/bin/env ruby
require 'rubygems'
require 'rotp'
# use ~/.google_authenticator to store the secret for
# compatibility with the google authenticator pam lib
secret_file = "#{ENV['HOME']}/.google_authenticator"
begin
secret = File.open(secret_file).read
@thalweg
thalweg / varnish_reload_config.sh
Created June 13, 2011 18:55
Reload varnish config
#!/usr/bin/env bash
set -eu
FILE="/etc/varnish/default.vcl"
HOST="localhost"
PORT="6082"
NOW=$(date +%s)
NC="nc ${HOST} ${PORT}"
error() {
echo 1>&2 "Failed to reload ${FILE}."
#!/usr/bin/env sh
#configurables
DBINSTANCE="yourdbinstanceID"
ENDPOINT="XXXXXXXXXXXX.us-east-1.rds.amazonaws.com"
USER='yourUser'
PASSWD='yourPassword'
DB1="yourDatabase1 yourDatabase2"
BUCKET='s3://your-bucket'
BACKUP_HOME='/mnt/backups'
@thalweg
thalweg / domain_from_hostname.sh
Created April 29, 2011 20:45
Isolates the second- and top-level domain from the rest
#!/usr/bin/env awk -f
# returns "google.com" when called on "www.google.com"
# returns "google.com" when called on "foo.bar.zot.www.google.com"
BEGIN {
string=ARGV[1];
search=".";
n=split(string,array,search);
printf("%s%s%s\n",array[n-1],search,array[n]);
exit;
}