Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / boxstarter-dev-install
Last active August 29, 2015 14:05
Development Machine Boxstarter Script
# command to run: (if IE is not your default browser, open the URL below in IE)
# START http://boxstarter.org/package/nr/url?https://gist.github.com/active-low/2d9a126ccfdaa67bb291/raw/boxstarter-dev-install
# or if you install boxstarter first you can run:
# Install-BoxstarterPackage -PackageName https://gist.github.com/active-low/2d9a126ccfdaa67bb291/raw/boxstarter-dev-install
#$Boxstarter.RebootOk=$true # Allow reboots?
#$Boxstarter.NoPassword=$false # Is this a machine with no login password?
#$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
Update-ExecutionPolicy Unrestricted
# command to run: (if IE is not your default browser, open the URL below in IE)
# START http://boxstarter.org/package/nr/url?https://gist.github.com/active-low/d2a2528019e35595255f/raw/boxstarter-dev-azure-vm
# or if you install boxstarter first you can run:
# Install-BoxstarterPackage -PackageName https://gist.github.com/active-low/d2a2528019e35595255f/raw/boxstarter-dev-azure-vm
Update-ExecutionPolicy Unrestricted
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
Enable-MicrosoftUpdate
Enable-RemoteDesktop
@gregjhogan
gregjhogan / azure-cli-storage
Last active August 29, 2015 14:22
Azure X-Platform CLI Examples
export HTTP_PROXY=[http://example.com:8080]
azure storage account connectionstring show [storage-account-name]
export AZURE_STORAGE_CONNECTION_STRING='[connection-string-from-previous-command]'
azure storage blob list --account-name [storage-account-name] --container [container-name]
@gregjhogan
gregjhogan / azure-ps-storage
Last active August 29, 2015 14:22
Azure Powershell Examples
[System.Net.WebRequest]::DefaultWebProxy = new-object System.Net.WebProxy("http://exmaple.com:8080")
Add-AzureAccount
Set-AzureSubscription -CurrentStorageAccountName '[storage-account-name]' -SubscriptionName '[subscription-name]'
Get-AzureStorageContainer
@gregjhogan
gregjhogan / jenkins-groovy-job-run
Created June 16, 2015 04:05
Jenkins Groovy Examples
def job = Jenkins.getInstance().getItem("build name")
def build = job.getBuildByNumber(12345)
@gregjhogan
gregjhogan / script.sh
Last active August 29, 2015 14:26
azure elasticsearch cluster
# azure vm list|grep LTS (to find latest ubuntu server image)
azure vm create es-cluster b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_2-LTS-amd64-server-20150706-en-us-30GB --location "Central US" --vm-name es-node-0 --vm-size ExtraSmall --ssh 22 --userName <username>
ssh es-cluster.cloudapp.net
# install java8
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
@gregjhogan
gregjhogan / azure-arm-api-through-jump-server
Last active September 25, 2015 05:33
Azure ARM management API through jump server
# add alias for lo0
sudo ifconfig lo0 alias 127.0.1.1 up
sudo ifconfig lo0 alias 127.0.1.2 up
# /etc/hosts alias
127.0.1.1 login.microsoftonline.com
127.0.1.2 management.azure.com
# ssh tunnel
sudo ssh -N -L 127.0.1.1:443:login.microsoftonline.com:443 <user>@<jump-server>
sudo ssh -N -L 127.0.1.2:443:management.azure.com:443 <user>@<jump-server>
@gregjhogan
gregjhogan / azure-cli-copy-blob
Last active September 25, 2015 16:07
Azure X-Platform CLI Examples
azure storage container create --connection-string '<dest-cxn>' <dest-container>
azure storage blob copy start --connection-string '<source-cxn>' --source-container <source-container> --source-blob <disk.vhd> --dest-connection-string '<dest-cxn>' --dest-container <dest-container> --dest-blob <disk.vhd>
# watch copy progress
azure storage blob copy show --connection-string '<dest-cxn>' --container <dest-container> --blob <disk.vhd>
@gregjhogan
gregjhogan / azure-cli-blob-sas-token-url.ps1
Last active September 27, 2015 13:45
Generate blob SAS URL
$cxn = (azure storage account connectionstring show --json --resource-group <resource-group> <storage-account>) | Out-String | ConvertFrom-Json
$sas = (azure storage blob sas create --json -c $cxn.string <container> <blob> r (Get-Date).AddHours(1).ToUniversalTime().ToString("s")) | Out-String | ConvertFrom-Json
$sas.url
@gregjhogan
gregjhogan / user-setup.sh
Last active September 30, 2015 20:20
user setup script
NEW_USER=
sudo useradd $NEW_USER
sudo mkdir /home/$NEW_USER/.ssh
sudo chown $NEW_USER:$NEW_USER /home/$NEW_USER/.ssh
sudo chmod 700 /home/$NEW_USER/.ssh
sudo touch /home/$NEW_USER/.ssh/authorized_keys
sudo chown $NEW_USER:$NEW_USER /home/$NEW_USER/.ssh/authorized_keys
sudo chmod 600 /home/$NEW_USER/.ssh/authorized_keys