Skip to content

Instantly share code, notes, and snippets.

View alexjamesbrown's full-sized avatar

Alex Brown alexjamesbrown

View GitHub Profile
@alexjamesbrown
alexjamesbrown / get-my-azure-ad-princpal-id.ps1
Created October 6, 2023 13:46
Sometimes, you just need to get the currently logged in users Azure AD Principal ID. This command does just that, and pipes it straight to the clipboard
az ad signed-in-user show --query id -o tsv | clip
76133139c9a0edc998882c32e95affe22e10762aaf5c6c2eb6a17ab2c4c4f94b
@alexjamesbrown
alexjamesbrown / Startup.cs
Last active May 26, 2022 12:39
Using RegisterForDispose to do something after the response has been sent
public class Startup
{
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.Use
(
async (context, next) =>
{
Console.WriteLine("Hello from middleware");
await next.Invoke();

Keybase proof

I hereby claim:

  • I am alexjamesbrown on github.
  • I am alexjamesbrown (https://keybase.io/alexjamesbrown) on keybase.
  • I have a public key ASB0Gxr4M3LbZS9krOtmcde-dvUGs6WCzYukAf3R6RCp4go

To claim this, I am signing this object:

@alexjamesbrown
alexjamesbrown / MattMarshEventsApi-GoogleSheet-SheetyDemo.json
Created June 30, 2019 23:01
Example response from Sheety for MattMarshEvents api
[
{
"title": "PURE ELITE",
"date": "27-Apr-2019",
"beforeEventPrice": "£40.00",
"afterEventPrice": "£50.00",
"": null,
"key": "#NAME"
},
{
function ClearCache() {
UrlFetchApp.fetch("https://api.mattmarshevents.co.uk/events/cache", {method: "delete"});
}
@alexjamesbrown
alexjamesbrown / MattMarshEventsApi-DeleteCache.cs
Created June 30, 2019 22:44
DeleteCache function for MattMarshEvents API
public static class DeleteCache
{
private static readonly HttpClient HttpClient = new HttpClient();
[FunctionName("DeleteEventsCache")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "events/cache")] HttpRequest req,
ILogger log)
{
var zoneId = Environment.GetEnvironmentVariable("CloudflareZoneId");
@alexjamesbrown
alexjamesbrown / Cloudflare-CleareCacheCurl.sh
Created June 30, 2019 22:42
Clear an item from the Cloudflare cache using curl
curl -X POST "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/purge_cache" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json" \
--data '{"files":["http://www.example.com/css/styles.css",{"url":"http://www.example.com/cat_picture.jpg","headers":{"Origin":"cloudflare.com","CF-IPCountry":"US","CF-Device-Type":"desktop"}}]}'
@alexjamesbrown
alexjamesbrown / MattMarshEventsApi-GoogleSheet-Slugify.js
Last active June 30, 2019 21:57
Slugify function for Google Sheet
function Slugify(title, date) {
if (!title)
return "";
if(!date)
return "";
slug = '';
@alexjamesbrown
alexjamesbrown / applicationConfig.xdt
Created March 14, 2019 12:04
disable urlCompression for Azure Functions via xdt transform
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<urlCompression xdt:Transform="Remove" />
<urlCompression doStaticCompression="false" doDynamicCompression="false" xdt:Transform="InsertIfMissing" />
</system.webServer>
</configuration>