Skip to content

Instantly share code, notes, and snippets.

View irwinwilliams's full-sized avatar

Irwin irwinwilliams

View GitHub Profile
@irwinwilliams
irwinwilliams / create-azure-storage-accounts-with-keys.sh
Created October 12, 2017 04:19
Creates a list of azure storage accounts, output their name and keys in bash
for number in {1..20}
do
account=comp69052017a2
account+=$number
az storage account create --name $account --resource-group COMP6905A2Storage --location eastus --sku Standard_LRS --encryption blob | jq ".name"
az storage account keys list --account-name $account --resource-group COMP6905A2Storage | jq '.[].value' | tr -s '\n' ','
done
@irwinwilliams
irwinwilliams / create-azure-resource-group-with-contributors.ps1
Created November 9, 2017 13:19
Create azure resource group and assign contributors
#Clear-Host
$classlist - ".\class-list.tsv" #contains a tab-delimited list of object ids, resource group names and locations
$tenant = "guid"
$app_id = "guid"
$app_key = ConvertTo-SecureString "key" -AsPlainText -Force
$cred = New-Object -TypeName pscredential -ArgumentList $app_id, $app_key
Login-AzureRmAccount -Credential $cred -ServicePrincipal -TenantId $tenant
Get-Content $classlist | ForEach-Object {
$tokens = $_ -split "\t"
@irwinwilliams
irwinwilliams / Function.cs
Created December 2, 2018 22:36
Function - Webhook to enqueue a message
[FunctionName("GoogleActions")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
[Queue("changevmstate")] out string state,
ILogger log)
{
state = null;
try
@irwinwilliams
irwinwilliams / VMManagement.cs
Created December 2, 2018 22:44
An example of toggling VM state using Azure's Fluent SDK
public Tuple<string,string> SetState(string state)
{
var vmName = VirtualMachineName;
var client = AzureClientId;
var key = AzureClientKey;
var tenant = AzureTenantId;
var creds = new AzureCredentialsFactory()
.FromServicePrincipal(client, key, tenant, AzureEnvironment.AzureGlobalCloud);
var subscriptionId = AzureSubscriptionId;
var azure = Microsoft.Azure.Management.Fluent.Azure.Authenticate(creds).WithSubscription(subscriptionId);
@irwinwilliams
irwinwilliams / SMPPMessage.cs
Created April 7, 2019 12:12
A class full of SMPP fields
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Text;
namespace TSharkConsumer
{
[System.Runtime.Serialization.DataContractAttribute(Name = "SMPPMessage",
Namespace = "http://schemas.datacontract.org/2004/07/teleios.messaging.smpp.Models")]
@irwinwilliams
irwinwilliams / Program.cs
Created April 22, 2019 09:55
Simple listener to confirm a networking question I had on StackOverflow
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
namespace ListenOnAny
{
class Program
{
static void Main(string[] args)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
import logging
import gkeepapi
import jsonpickle
import os
import azure.functions as func
class KeepNote(object):
label = ""
text = ""
category = ""
@irwinwilliams
irwinwilliams / ImgToBase64.ps1
Created October 29, 2019 19:15 — forked from colinMac/ImgToBase64.ps1
Powershell script to convert an image to base64 data uri format and store in a text file
function ImageToBase64 {
Param([String]$path)
[bool]$valid = ($path -ne "")
if ($valid) {
[String[]]$elements = $path.split(".")
[int]$max = $elements.Count - 1
[String]$ext = $elements[$max]
[String]$uri = "data:image/$($ext);base64,"
$elements[$max] = "txt"
/// <summary>
/// Transform NV12 to bmp image so we can view how is it looks like. Note it's not NV12 to RBG conversion.
/// </summary>
/// <param name="data">NV12 sample data.</param>
/// <param name="width">Image width.</param>
/// <param name="height">Image height.</param>
/// <param name="logger">Log instance.</param>
/// <returns>The <see cref="Bitmap"/>.</returns>
public static Bitmap TransformNv12ToBmpFaster(byte[] data, int width, int height, IGraphLogger logger)
{