Skip to content

Instantly share code, notes, and snippets.

@esell
esell / backup.ps1
Created December 13, 2017 16:35
Backup a blob from one sa to another
Write-Output "PowerShell Timer trigger function executed at:$(get-date)";
# Create src/dest contexts
# DEST_KEY & SRC_KEY are set as environment variables in app settings
$DestContext = New-AzureStorageContext -StorageAccountName "destStorageAccountName" -StorageAccountKey $env:DEST_KEY
$SrcContext = New-AzureStorageContext -StorageAccountName "srcStorageAccountName" -StorageAccountKey $env:SRC_KEY
# Get timestamp
$timestamp = Get-Date -Format o | foreach {$_ -replace ":", "."}
@esell
esell / ethlab.md
Last active December 7, 2017 04:11
Setup a multi-node private etherum cluster

PRE-REQs

  • VMs should be ubuntu
  • your boot node should have the hostnamne "bootnode".
  • create at least 3 VMs, one boot node, one member node and one miner node

Setup boot node

The boot node will be the brains and what the other nodes talk to in order to find members of your cluster. The below steps will set it up so that you can use it later.

@esell
esell / main.go
Created September 20, 2017 21:53
dh stuff
package main
import (
"fmt"
"math/rand"
"time"
"github.com/monnand/dhkx"
)
#!/bin/bash
# appears azure doesn't like to update
# their agent during setup so we'll hold it
apt-mark hold walinuxagent
# get Ubuntu updates
apt-get update
if [ $? -ne 0 ]; then
echo "update failed"
#!/bin/bash
# install docker-machine
curl -L https://github.com/docker/machine/releases/download/v0.12.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine && chmod +x /tmp/docker-machine && sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
# clone repo
cd /home/esell && git clone https://github.com/esell/ethcluster.git
type MyTemplate struct {
ContentVersion string `json:"contentVersion"`
// Resources could be other types outside of Resource1, hence the []string
Resources []string `json:"resources"`
}
type Resource1 struct {
ResourceType string `json:"-"`
APIVersion string `json:"apiVersion"`
Comments string `json:"comments"`
@esell
esell / blah.json
Created April 14, 2017 21:41
blah.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"region_name": {
"defaultValue": "westus",
"type": "String"
},
"apptier_nsg_name": {
"defaultValue": "apptier",
req, _ = http.NewRequest("POST", "", body)
req.Header.Add("Content-Type", writer.FormDataContentType())
w = httptest.NewRecorder()
router.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Errorf("uploadHandler POST returned %v, should be %v", w.Code, http.StatusOK)
}
err = deleteTestImage(sampleImgPath)
if err != nil {
fmt.Println("unable to delete test image")
#!/bin/sh
dmesg | awk '
/sd[a-z].*logical blocks/ {
gsub(/\[|\]/, "", $5)
gsub(/[aA-zZ]/, "", $11)
gsub(/\//, "", $11)
print $5, "-", $11
}
'
#!/bin/bash
# get list of VMs
VMLIST=`azure vm list --json |jq '. | .[].name'`
for v in $VMLIST
do
v=`echo $v | sed 's/"//g'`
echo "looking up $v..."