Skip to content

Instantly share code, notes, and snippets.

Lorenz Lo Sauer lsauer

Block or report user

Report or block lsauer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View nginx-docker-config(user_dustywusty).sh
#!/bin/bash
cat << EOF
_
_ _ __ _(_)_ _ __ __ ___ _ _ _ __
| ' \/ _\` | | ' \\\ \ / |___| | '_| '_ \\
|_||_\__, |_|_||_/_\_\ |_| | .__/
|___/ |_|
EOF
@lsauer
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
#load
gunzip -c mycontainer.tgz | docker load
@lsauer
lsauer / running_win10_ec2_amazon_web_services.md
Created Oct 7, 2017
Notes: Running Windows 10 on AWS EC2
View running_win10_ec2_amazon_web_services.md

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 Sep 10, 2017
Amazon AWS Shut Down All EC2 Instances
View ec2-terminate-all-ec2.sh
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 Sep 7, 2017
Amazon AWS Cloudwatch report memory metric bash script
View awscloudwatch_reportmemory.sh
#!/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 Jul 8, 2017
Fast JavaScript 0-5 Stars Ratings HTML Generator
View stars.html
<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 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": ')
.replace(/,\s*\}/,'}')
.trim();
@lsauer
lsauer / moneyformat.js
Created Apr 3, 2015
JavaScript: money-string format with thousands separator
View moneyformat.js
//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 Feb 5, 2015
find and set the globalObject in JavaScript
View global-scope-finding-setting.js
"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{
@lsauer
lsauer / left-flexible-right-fixed.css
Created Feb 5, 2015
css: fixed width column to the right and flexible full-width left-column
View left-flexible-right-fixed.css
/* lsauer.com, 2015 */
.left-flexible-right-fixed .container {
height: auto;
overflow: hidden;
}
.left-flexible-right-fixed .left-inner{
width: 100%;
}
.left-flexible-right-fixed .right {
width: 180px;
You can’t perform that action at this time.