Skip to content

Instantly share code, notes, and snippets.

View BadgerCode's full-sized avatar
🦡

Michael Hawkins BadgerCode

🦡
View GitHub Profile
@BadgerCode
BadgerCode / service-fabric-update-rollback.ps1
Created August 14, 2019 09:29
Updates a service fabric upgrade that is in progress to use new settings
$endpoint = "myclustername.uksouth.cloudapp.azure.com:19000"
$thumbprint = "a132bd464564ffffff1651f1311f51321"
Connect-serviceFabricCluster `
-ConnectionEndpoint $endpoint `
-KeepAliveIntervalInSec 10 `
-X509Credential `
-ServerCertThumbprint $thumbprint `
-FindType FindByThumbprint `
-FindValue $thumbprint `
@BadgerCode
BadgerCode / api-m-debug-policy.xml
Last active May 23, 2019 08:59
Azure API Management debug response
<policies>
<inbound>
<base />
<return-response>
<set-status code="200" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
var response = new JObject();
@BadgerCode
BadgerCode / function-cli.ps1
Last active April 3, 2019 11:58
Powershell commands to use the azure functions CLI for things like syncing settings
# List commands and categories of commands
func
# List subscriptions
func azure subscriptions list
# Select active subscription
func azure subscriptions set guid-guid-guid
@BadgerCode
BadgerCode / TestConfiguration.cs
Last active April 2, 2019 08:51
Loads test configuration into environment variables. Useful for .net core apps. Call this once before all your tests run.
public static class Configuration
{
public static void Load()
{
var config = JObject.Parse(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "acceptance.settings.json")));
foreach (var configOption in config["Values"])
{
var option = (JProperty)configOption;
var key = option.Name;
var value = option.Value.ToString();
@BadgerCode
BadgerCode / shared.lua
Last active March 31, 2019 13:59
TTT jump canon modified (to behave mostly the same way it did on questionable ethics TTT)
-- Original addon
-- https://steamcommunity.com/sharedfiles/filedetails/?id=267785752
AddCSLuaFile("shared.lua")
SWEP.Author = "Delta7x"
SWEP.Instructions = "Shoot in the opposite direction of where you would like to be propelled."
SWEP.HoldType = "physgun"
@BadgerCode
BadgerCode / function.tf
Created February 26, 2019 22:52
Example azure function in terraform
resource "azurerm_storage_account" "myfunctionstorage" {
name = "myfunctionstorage1234"
resource_group_name = "MyResourceGroup"
location = "UK South"
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_app_service_plan" "myfunctionplan" {
name = "myfunctionappserviceplan"
@BadgerCode
BadgerCode / slack-theme.txt
Created February 18, 2019 18:19
Slack light, clean theme
#ffffff,#d1faff,#e8e8e8,#000000,#e8e8e8,#000000,#000000,#00a0b5
@BadgerCode
BadgerCode / Acceptance-Test-Config-Loader.cs
Created February 6, 2019 18:01
Loads local.settings.json into environment variables for acceptance testing functions
var config = JObject.Parse(File.ReadAllText(Path.Join(Directory.GetCurrentDirectory(), "local.settings.json")));
foreach (var configOption in config["Values"])
{
var option = (JProperty) configOption;
var key = option.Name;
var value = option.Value.ToString();
Environment.SetEnvironmentVariable(key, value);
}
@BadgerCode
BadgerCode / timings.js
Last active January 26, 2019 02:44
Some nice abstractions around timing events in front end JS
// Example
Timing.After(milliseconds(100))
.Do(() => console.log("100 millis!"))
.ThenAfter(milliseconds(100))
.Do(() => console.log("Followed by another 100 ms!"))
.ThenAfterEvery(milliseconds(200))
.Until((iteration, duration) => iteration >= 5)
.Do(() => console.log("looping every 200ms"));
@BadgerCode
BadgerCode / azure-function-servicebus-interop.md
Last active January 26, 2019 11:40
Azure function service bus interop
  • Old format: BrokeredMessage = .net Framework format (WindowsAzure.ServiceBus)
  • New format: Message = .net standard format (Microsoft.Azure.ServiceBus)

More info

Consuming

A BrokeredMessage was produced. I wish to consume it as a Message.

using Microsoft.Azure.ServiceBus;