Skip to content

Instantly share code, notes, and snippets.


Lorenz Lo Sauer lsauer

View GitHub Profile
lsauer /
Created Oct 2, 2020 — forked from joshy91/
Deployments, Rolling Update, Rollback
#Deployments, Rolling Update, Rollback
#Nginx deployment yaml
echo “apiVersion: apps/v1beta2
kind: Deployment
name: nginx-deployment
namespace: default
View nginx-docker-config(user_dustywusty).sh
cat << EOF
_ _ __ _(_)_ _ __ __ ___ _ _ _ __
| ' \/ _\` | | ' \\\ \ / |___| | '_| '_ \\
|_||_\__, |_|_||_/_\_\ |_| | .__/
|___/ |_|
lsauer / Docker: save_load_compressed_container.bash
Created Mar 25, 2019
Docker: save/load container using tgz file (tar.gz)
View Docker: save_load_compressed_container.bash
#for an image ("not running container") use save:
docker save <dockernameortag> | gzip > mycontainer.tgz
#for running or paused docker, use export:
docker export <dockernameortag> | gzip > mycontainer.tgz
gunzip -c mycontainer.tgz | docker load
lsauer /
Created Oct 7, 2017
Notes: Running Windows 10 on AWS EC2

Getting Windows 10 on EC2 isn't difficult, but perusing the documentation can lead to confusion.

You can't mount an ISO to an empty VM the way you might do in VirtualBox, so this process requires a local copy of the VM to be created, then using the aws ec2 import-image command to create the AMI. When done, not only will the image be ready for EC2, but it will be detected as Windows by AWS and be configured such that it has many of the same AWS-specific features as other Windows AMIs provided by Amazon.

  • Create a new Windows VM using VirtualBox

    • Make sure to choose VHD as the disk image format
  • Install Windows 10 within the VirtualBox VM as normal. Note that a fresh install will format the VHD as MBR, which is the only partition format supported on AWS

  • Shut down the VM and upload the vhd file to an S3 bucket

  • Create a json file describing the VHD. This usually looks something like this: 

lsauer /
Created Sep 10, 2017
Amazon AWS Shut Down All EC2 Instances
aws ec2 terminate-instances
aws ec2 describe-instances
| grep InstanceId
| awk {'print $2'}
| sed 's/[",]//g'
lsauer /
Last active Sep 7, 2017
Amazon AWS Cloudwatch report memory metric bash script
memory=$(cat /proc/meminfo | grep MemFree: | awk '{print $2}')
memory=$(echo $memory/1000 | bc)
echo memory is: $memory
aws cloudwatch put-metric-data --metric-name Memory\
--namespace WebServer\
--unit Bytes \
--value $memory\
--dimensions InstanceID=i-093beb71f2d7647ce,InstanceType=m1.small\
--region eu-west-1
lsauer / stars.html
Last active Jul 8, 2017
Fast JavaScript 0-5 Stars Ratings HTML Generator
View stars.html
.stars-sup {
font-size: 75%;
position: relative;
top: -6px;
left: 6px;
<ul class="used-technologies">
<li>Design UX<span class="stars-sup" data-stars="4"></span></li>
lsauer / css2json.js
Created Aug 28, 2015
JavaScript: convert css string to JSON
View css2json.js
//converts a css string to json
var css2json = function(str){
return str
.replace(/(\w*:)/g, '$1"') //create json format
.replace(/[;]/g, '";')
.replace(/(\'{2,})/g, '"')
.replace(/;/g, ',')
.replace(/(['"])?([a-zA-Z0-9_-]+)(['"])?:/g, '"$2": ')
lsauer / moneyformat.js
Created Apr 3, 2015
JavaScript: money-string format with thousands separator
View moneyformat.js
//, 2015
var thousandSeparator = ',';
var inputNumber = 234234;
var fixedLength = 2
lsauer / global-scope-finding-setting.js
Created Feb 5, 2015
find and set the globalObject in JavaScript
View global-scope-finding-setting.js
"use strict";
var globalScope;
try {
globalScope = Function('return this')();
//extend else-if cases for other globalObject-names as needed...
if(this && this.hasOwnProperty && this.hasOwnProperty('window')){
globalScope = window;