Skip to content

Instantly share code, notes, and snippets.

View lantrix's full-sized avatar
:octocat:
always coding and merging

Ted B lantrix

:octocat:
always coding and merging
View GitHub Profile
@lantrix
lantrix / deserialise_json.ps1
Last active January 27, 2016 16:22
Deserialise JSON object larger than 2MB with Powershell
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions")
$json = (New-Object -TypeName System.Web.Script.Serialization.JavaScriptSerializer `
-Property @{MaxJsonLength=67108864}).DeserializeObject($(Get-Content -Raw 'myfile.json'))
@lantrix
lantrix / count_aws_types.ps1
Created June 1, 2015 08:02
Count number of AWS Resource Types with specific Tag Value in Powershell
$tagKey="Stream"
$tagValue="se"
$data = (Get-EC2Tag -Filter @{name="tag:${tagKey}"; Value=$tagValue})
$gps = @()
foreach ($t in $data.ResourceType | ? { $_.Key -eq $groupkey} ) {
$gps += $t.Value
}
$gps | group | Sort Count -Descending | Select Count, Name
@lantrix
lantrix / as_cli_scale_ASG.sh
Last active August 29, 2015 14:23
Scale Down/Up an AWS ASG permanently
#No instances
aws autoscaling update-auto-scaling-group --region ap-southeast-2 --max-size 0 --min-size 0 \
--auto-scaling-group-name myASGgroup
aws autoscaling set-desired-capacity --region ap-southeast-2 --desired-capacity 0 \
--auto-scaling-group-name myASGgroup
#Desired Instances
aws autoscaling update-auto-scaling-group --region ap-southeast-2 --max-size 2 --min-size 1 \
--auto-scaling-group-name myASGgroup
aws autoscaling set-desired-capacity --region ap-southeast-2 --desired-capacity 1 \
@lantrix
lantrix / aws_cli_asg_tags.sh
Created June 23, 2015 05:08
AWS CLI add tags to ASG - propagate to instances
aws autoscaling create-or-update-tags --region ap-southeast-2 \
--tags "ResourceId=myASGgroup,ResourceType=auto-scaling-group,Key=MyTagKey,Value='Tag Value',PropagateAtLaunch=true"
@lantrix
lantrix / tail.ps1
Created August 7, 2015 05:23
Powershell Pseudo Tail
Get-ChildItem -Path 'C:\AppLogs\customresources\20150807\' -Filter 'exe*' `
-Recurse | % {Get-Content -Path $_.FullName -Tail 50 | Select-String -Pattern 'MockServer-1'}
Get-Content -Path 'C:\AppLogs\customresources\20150807\exe*.log' `
-Tail 3000 | Select-String 'MockServer-1'
@lantrix
lantrix / README.md
Last active September 10, 2015 04:03 — forked from jasonberanek/README.md
Enabling VNC support in the VMware ESXi 5.x Firewall - Used by Packer for vmware-iso on ESXi HyperVisor

VMware ESXi includes a built in VNC server that can be used to access a VMs console for manipulation via automated tools (e.g., veewee) or by users on platforms where the vSphere Client is not supported. In ESXi 5.x, the built-in firewall does not allow VNC traffic to be received by the VNC server, even when an individual VM is configured to support this configuration. To complete this activity, the firewall has to be modified to allow the appropriate ports.

The below script can be run via the ESXi command line to setup the firewall rules necessary to run VNC. A few items to note:

  • Scripts assumes the firewall rules file is the default provided as by 5.0.0 update 2 build 914586 and/or 5.1.0 build 799733 (may work in other versions)
  • In order to persist settings after a reboot, it is necessary to copy the firewall settings to either a specific datastore mapped to the host, or the local persistent storage linked under the /store directory. Further, the either the /etc/rc.local (ESXi 5.0) or `/etc/rc.local
@lantrix
lantrix / configure-winrm.ps1
Last active August 29, 2015 14:27 — forked from sneal/configure-winrm.ps1
Configure WinRM for Vagrant
winrm quickconfig -q
winrm quickconfig -transport:http
winrm set winrm/config '@{MaxTimeoutms="7200000"}'
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}'
winrm set winrm/config/winrs '@{MaxProcessesPerShell="0"}'
winrm set winrm/config/winrs '@{MaxShellsPerUser="0"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/client/auth '@{Basic="true"}'
winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"} '
#!/usr/bin/env bash
function execute_after_confirm {
read -p "$1 ($2) ? [y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
shift
for var in "$@"
do
@lantrix
lantrix / packer-vmware-iso_config.json
Created August 25, 2015 07:53
vmware-iso packer build
{
"builders": [
{
"type": "vmware-iso",
"vm_name": "packer_windows_2012_r2",
"output_directory": "{{user `output_directoryName`}}",
"iso_url": "iso/en_windows_server_2012_r2_vl_with_update_x64_dvd_6052766.iso",
"iso_checksum_type": "md5",
"iso_checksum": "9a00defab26a046045d939086df78460",
"headless": true,
@lantrix
lantrix / osx-10.10-setup.md
Last active August 26, 2015 01:46 — forked from kevinelliott/osx-10.10-setup.md
Mac OS X 10.10 Yosemite Setup

Mac OS X 10.10 Yosemite

Custom recipe to get OS X 10.10 Yosemite running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

Install Software