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: 

View ec2-terminate-all-ec2.sh
aws ec2 terminate-instances
--instance-ids
$(
aws ec2 describe-instances
| grep InstanceId
| awk {'print $2'}
| sed 's/[",]//g'
)
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
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>
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();
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)
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{
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;
View html-hex-color-name-aliases.js
var htmlColorsMap = (function(scope){
var htmlColorsMap = {};
var _colorAliases = [
'#F0F8FF aliceblue'
, '#FAEBD7 antiquewhite'
, '#00FFFF aqua'
, '#7FFFD4 aquamarine'
, '#F0FFFF azure'
, '#F5F5DC beige'
, '#FFE4C4 bisque'
View exception_handler.js
/**
* lsauer, 2013
* Lean handler for exception reporting; stdout is set by default to console.log
* @param {exc} exc an Exception instance of Error, containing a message and stack property
* @param {exc} stdOut A variadic function for error reporting. By default: console.log
* @return undefined
*/
var exceptionHandler = function(exc, stdOut){
var stdOut = stdOut || function() { console.log.apply(console, arguments) };
if(stdOut instanceof Function){