Skip to content

Instantly share code, notes, and snippets.

sgdan / awslogin
Last active Aug 24, 2019
Utility shell script for logging into AWS CLI named profile using an MFA token
View awslogin
if [ $# -lt 1 ]; then
cat << EOF
usage: awslogin <profile>
Utility script for logging into AWS CLI named profile with an MFA token.
A session token will be requested and the "default" profile will be updated
with the valid session data. Make sure you have a named profile configured
as described below, including the "mfa" arn:
sgdan /
Created May 11, 2019
Test the ".dockerignore" file to ensure the build context doesn't contain unwanted files
# Based on BMitch's answer from:
# Note: will create and delete temporary file ""
# 1. Copy to project folder where image is being built
# 2. Run script
# 3. You should see list of files in build context
sgdan / rds-create-db-user-example.sql
Created Oct 19, 2018
Create database and user login for AWS SQL Server RDS database
View rds-create-db-user-example.sql
Example for AWS SQL Server RDS instance:
- create database
- create login with basic permissions
Since RDS is managed there are some restrictions when creating users and assigning
permissions. This procedure shows how to create a database and login with combinations
of ddl, read and write permissions.
create procedure #createdbuser (
sgdan /
Created Aug 13, 2018
For local dev purposes, create a self-signed certificate and start Rancher 2 server container
# The Rancher 2 server container generates its own certificate but for some reason
# my browser wouldn't accept it, and didn't give me the option to override. Here's
# a way to generate a self-signed cert and use it to start the container.
# Note: I ran this on Git Bash shell in Windows 10, format for Linux may differ
# Generate certificate and key
openssl req -x509 -newkey rsa:4096 \
-keyout key.pem -out cert.pem \
-days 1000 -nodes \
sgdan /
Last active Aug 12, 2018
Use Kubernetes Dashboard with docker-for-desktop
# I've installed Docker for Windows and enabled the Kubernetes cluster
# My kubectl context is "docker-for-desktop" (right-click on docker tray icon > Kubernetes > docker-for-desktop)
# Docker should have updated my ~/.kube/config file for kubectl access
# Install the dashboard as per by running:
kubectl create -f
# Using git bash shell on windows:
grep 'client-certificate-data' ~/.kube/config | awk '{print $2}' | base64 -d >> kubecfg.crt
grep 'client-key-data' ~/.kube/config | awk '{print $2}' | base64 -d >> kubecfg.key
sgdan / Vagrantfile
Created Aug 7, 2018
Create single node kubernetes cluster with kubeadm using vagrant and ubuntu
View Vagrantfile
$script = <<-SCRIPT
set -ex
apt-get update && apt-get install -y apt-transport-https
curl -s | apt-key add -
echo "deb kubernetes-xenial main" | sudo tee > /etc/apt/sources.list.d/kubernetes.list
apt-get update && apt-get install -y kubeadm
swapoff -a
sudo sed -i.bak '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
sgdan / KeepInList.elm
Created Nov 5, 2017
Iterate through an Elm list and compare each element against all the others
View KeepInList.elm
Iterate through a list and compare each element to all the others to decide what to keep
Run at
import Html exposing (text, div, br)
import String exposing (..)
initial = ["a", "ab", "c", "cdb", "cd"]
sgdan / DictIterators.elm
Created Oct 29, 2017
Iterating over a map in Elm
View DictIterators.elm
Some Elm code for various ways to iterate over a map
Run at
import Html exposing (text, div, br)
import Dict exposing (Dict)
import String exposing (toUpper)
sgdan / DictOfSets.elm
Last active Oct 29, 2017
Create a map of sets in Elm
View DictOfSets.elm
Some Elm code for a map of sets. This maps prices to the set of items
with that price.
Run at
import Html exposing (text, div, br)
import Dict exposing (Dict)
import Set exposing (Set)
sgdan / loadResource.kts
Last active Oct 10, 2017
Compare loading a text resource via classpath or file
View loadResource.kts
// Assume folder containing script is in the classpath
// To append current folder to classpath can pass: -Xbootclasspath/a:.
// load from file system
val fileContent ="loadResource.kts").readText()
println("file content length: ${fileContent.length}")
// load via class path (can also use javaClass.getResource method but seems more reliable to go via class loader)
val urlContent = javaClass.classLoader.getResource("loadResource.kts").readText()
println("url content length: ${urlContent.length}")
You can’t perform that action at this time.