Skip to content

Instantly share code, notes, and snippets.

View nickGermi's full-sized avatar

nickGermi

  • Sydney, Australia
View GitHub Profile
var stockPrices = [10, 7, 5, 8, 11, 9];
/*
Takes an array of stock prices and returns the best profit could have been made from 1 purchase and 1 sale of 1 stock
*/
function getProfit(inputArray){
//find minimum of first 2 items of the array
var min = inputArray[0] < inputArray[1] ? inputArray[0] : inputArray[1];
//find difference of second item minus first
var diff = inputArray[1] - inputArray[0];
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] “Administrator”))
{
$arguments = “& ‘” + $myinvocation.mycommand.definition + “‘”
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
#Set-Location "C:\Program Files (x86)\Windows Kits\10\Tools\x64"
#$audioId = (./devcon listclass media).split(":")[1]
#$displayId = (./devcon listclass display).split(":")[1]
@nickGermi
nickGermi / bash_aws_jq_cheatsheet.sh
Created March 1, 2019 01:09 — forked from lukeplausin/bash_aws_jq_cheatsheet.sh
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account