This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |