Skip to content

Instantly share code, notes, and snippets.

@rezamt
rezamt / vm-deploy-azure
Created March 12, 2018 13:25
Deploying Windows VM to Azure
$resourceGroup = "rg-demo"
$location = "westus"
$vmName = "myVM"
$cred= Get-Credential -Message "Enter your vm username and passwords"
tester
Secure$@P1234
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
@rezamt
rezamt / vm-deploy-azure
Last active March 12, 2018 13:38
Deploying Windows VM to Azure
$resourceGroup = "rg-demo"
$location = "westus"
$vmName = "myVM"
$cred= Get-Credential -Message "Enter your vm username and passwords"
tester
Secure$@P1234
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
# run the following step - if its for the first time.
brew tap caskroom/cask
brew cask install powershell
# then install the azure core module (the same as linux)
pwsh
> Install-Module AzureRM.Netcore
> Import-Module AzureRM.Netcore
@rezamt
rezamt / ps_session_remote
Created March 14, 2018 09:48
Using WinRM () and Powershell Remote Exec Feature
# In order to run this, we need to open up NSG to WinRM (9586) and makesure the windows firewall (internally) is also open)
$dnsname = $env:COMPUTERNAME
Enable-PSRemoting -Force
New-NetFirewallRule -Name "WinRM HTTPS" -Enabled True -Action Allow -Direction Inbound -LocalPort 5986 -Protocol "TCP"
$thumbprint = (New-SelfSignedCertificate -DnsName $dnsname -CertStoreLocation Cert:\LocalMachine\My).Thumbprint
@rezamt
rezamt / multiworkspace
Created April 5, 2018 14:00
How to manage Multiple Workspace in Terraform
## TF and Workspace
```
terraformer COMMAND -repo GitURL -env BRANCH-NAME [-tag GitTAG | -revision GitRev]
```
Note: State is stored remotely
```
git clone GitURL # if branch or tag specified it should get them as well
```
checks the S3 bucket if {env}-{tag | revision} exist ?
@rezamt
rezamt / hashtable-example.ps1
Created June 1, 2018 01:34
Powershell HashTable Iteration
How to Iterate and find the keys and values inside: System.Collection.Hashtable
# System.Collections.Hashtable
# Accessing Keys and Values using Enumerator
(Get-AzureKeyVaultSecret -VaultName $KeyVaultName | Where 'ContentType' -eq 'Wrapped BEK').Tags | foreach {
foreach ($tag in $_.GetEnumerator())
{
if ($tag.Key -eq 'MachineName' -and $tag.Value -eq $VMName) {
Write-Host "$($tag.Key) = $($tag.Value)"
@rezamt
rezamt / blockchain_software.sh
Last active June 3, 2018 10:35
Blockchain software
# Browser
Google Chrome
# Plugins
## MetaMask
https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn
# Terminal
https://iterm2.com/downloads/stable/iTerm2-3_1_6.zip
@rezamt
rezamt / greeting.sol
Created June 28, 2018 12:45
Sample Smart Contract
pragma solidity ^0.4.15;
contract Greeter {
address owner;
string greeting;
/*
function Greeter (string _greeting) public {
@rezamt
rezamt / Incrementer.sol
Created June 28, 2018 12:54
Incrementer Smart Contract
pragma solidity ^0.4.24;
contract Incrementer {
address creator;
uint iteration;
function Incrementer() public
{
creator = msg.sender;
@rezamt
rezamt / Incrementer.sol
Created June 28, 2018 12:54
Incrementer Smart Contract
pragma solidity ^0.4.24;
contract Incrementer {
address creator;
uint iteration;
function Incrementer() public
{
creator = msg.sender;