Skip to content

Instantly share code, notes, and snippets.

View lsauer's full-sized avatar
🎯
Focusing

Lorenz Lo Sauer lsauer

🎯
Focusing
View GitHub Profile
@lsauer
lsauer / k8UpdateRollback.sh
Created October 2, 2020 06:47 — forked from joshy91/k8UpdateRollback.sh
Deployments, Rolling Update, Rollback
#!/bin/bash
#Deployments, Rolling Update, Rollback
#Nginx deployment yaml
echo “apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
spec:
#!/bin/bash
cat << EOF
_
_ _ __ _(_)_ _ __ __ ___ _ _ _ __
| ' \/ _\` | | ' \\\ \ / |___| | '_| '_ \\
|_||_\__, |_|_||_/_\_\ |_| | .__/
|___/ |_|
EOF
@lsauer
lsauer / Docker: save_load_compressed_container.bash
Created March 25, 2019 11:37
Docker: save/load container using tgz file (tar.gz)
#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
#load
gunzip -c mycontainer.tgz | docker load
@lsauer
lsauer / running_win10_ec2_amazon_web_services.md
Created October 7, 2017 08:47
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
lsauer / ec2-terminate-all-ec2.sh
Created September 10, 2017 14:45
Amazon AWS Shut Down All EC2 Instances
aws ec2 terminate-instances
--instance-ids
$(
aws ec2 describe-instances
| grep InstanceId
| awk {'print $2'}
| sed 's/[",]//g'
)
@lsauer
lsauer / awscloudwatch_reportmemory.sh
Last active September 7, 2017 21:16
Amazon AWS Cloudwatch report memory metric bash script
#!/bin/bash
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
lsauer / stars.html
Last active July 8, 2017 17:52
Fast JavaScript 0-5 Stars Ratings HTML Generator
<style>
.stars-sup {
font-size: 75%;
position: relative;
top: -6px;
left: 6px;
}
</style>
<ul class="used-technologies">
<li>Design UX<span class="stars-sup" data-stars="4"></span></li>
@lsauer
lsauer / css2json.js
Created August 28, 2015 08:58
JavaScript: convert css string to JSON
//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": ')
.replace(/,\s*\}/,'}')
.trim();
@lsauer
lsauer / moneyformat.js
Created April 3, 2015 09:01
JavaScript: money-string format with thousands separator
//lsauer.com, 2015
var thousandSeparator = ',';
var inputNumber = 234234;
var fixedLength = 2
parseFloat(inputNumber)
.toFixed(fixedLength)
.toString()
.split(/(.{3})/gm)
.filter(Boolean)
.join(thousandSeparator)
@lsauer
lsauer / global-scope-finding-setting.js
Created February 5, 2015 10:12
find and set the globalObject in JavaScript
"use strict";
if(!this.hasOwnProperty('globalScope')){
var globalScope;
try {
globalScope = Function('return this')();
}catch(ex){
//extend else-if cases for other globalObject-names as needed...
if(this && this.hasOwnProperty && this.hasOwnProperty('window')){
globalScope = window;
}else{