Skip to content

Instantly share code, notes, and snippets.

Alex Brown alexjamesbrown

Block or report user

Report or block alexjamesbrown

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

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 Jun 30, 2019
Example response from Sheety for MattMarshEvents api
View MattMarshEventsApi-GoogleSheet-SheetyDemo.json
[
{
"title": "PURE ELITE",
"date": "27-Apr-2019",
"beforeEventPrice": "£40.00",
"afterEventPrice": "£50.00",
"": null,
"key": "#NAME"
},
{
View MattMarshEventsApi-GoogleSheet-ClearCache.js
function ClearCache() {
UrlFetchApp.fetch("https://api.mattmarshevents.co.uk/events/cache", {method: "delete"});
}
@alexjamesbrown
alexjamesbrown / MattMarshEventsApi-DeleteCache.cs
Created Jun 30, 2019
DeleteCache function for MattMarshEvents API
View MattMarshEventsApi-DeleteCache.cs
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 Jun 30, 2019
Clear an item from the Cloudflare cache using curl
View Cloudflare-CleareCacheCurl.sh
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"}}]}'
View MattMarshEventsApi-GoogleSheet-Slugify.js
function Slugify(title, date) {
if (!title)
return "";
if(!date)
return "";
slug = '';
@alexjamesbrown
alexjamesbrown / applicationConfig.xdt
Created Mar 14, 2019
disable urlCompression for Azure Functions via xdt transform
View applicationConfig.xdt
<?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>
@alexjamesbrown
alexjamesbrown / TopicProcessorWithRetry.cs
Created Feb 23, 2019
Example of retrying messages by re-queuing
View TopicProcessorWithRetry.cs
[FunctionName("TopicProcessor")]
public static async Task Run(
[ServiceBusTrigger("%topic-name%", "%subscription-name%", AccessRights.Manage, Connection = "connection")] BrokeredMessage msg,
[ServiceBus("%topic-name%", AccessRights.Manage, Connection = "connection", EntityType = EntityType.Topic)] IAsyncCollector<BrokeredMessage> outputTopic,
ILogger log)
{
var thing = msg.GetBody<Thing>();
try {
var apiClient = new ApiClient();
@alexjamesbrown
alexjamesbrown / ServiceBusTriggerExample.cs
Created Feb 23, 2019
Example of ServiceBusTrigger function runtime
View ServiceBusTriggerExample.cs
var message = ReceiveMessageFromTopic();
try {
//run the code within your function, passing the message as a parameter
RunFunctionCode(message);
}
catch() {
message.Abandon();
}
message.Complete();
@alexjamesbrown
alexjamesbrown / TopicProcessorDeadletter.cs
Created Feb 23, 2019
Try deadletter message on exception
View TopicProcessorDeadletter.cs
[FunctionName("TopicProcessor")]
public static async Task Run(
[ServiceBusTrigger("%topic-name%", "%subscription-name%", AccessRights.Manage, Connection = "connection")] BrokeredMessage msg,
ILogger log)
{
var thing = msg.GetBody<Thing>();
var apiClient = new ApiClient();
try {
await apiClient.PostAsync(thing);
}
You can’t perform that action at this time.