Skip to content

Instantly share code, notes, and snippets.

View GFoley83's full-sized avatar
☘️
CTO @ Educa

Gavin Foley GFoley83

☘️
CTO @ Educa
View GitHub Profile
@GFoley83
GFoley83 / Azure DevOps - Delete Stale Branches.ps1
Created November 26, 2024 23:57
Delete all branches X number of commits behind master
# Define variables
$organization = ""
$project = ""
$repositoryName = ""
$masterBranch = "master"
$devBranch = "develop"
$maxCommitsBehind = 500
$apiKey = $env:AZURE_DEVOPS_API_KEY
# Validate API Key
@GFoley83
GFoley83 / CascadeDelete.sql
Last active May 20, 2024 02:36 — forked from lionofdezert/CasecadeDelete.sql
Cascade Delete in SQL Server
/*
Originally written by Daniel Crowther 16 Dec 2004.
Addresses the recursive deletion of child table entries, even those not directly related to the parent table, before ultimately attempting to delete from the parent table.
Passing 'Y' to @ExecuteDelete will run the deletion & wrap everything in a transaction
Passing 'Y' to @TrialRun rolls back the transaction after executing all the delete statements.
@GFoley83
GFoley83 / AwsV4SigningExample.cs
Created February 9, 2022 23:02
Full example showing how to sign AWS requests with Signature Version 4 using .NET
using System.Globalization;
using System.Net.Mime;
using System.Security.Cryptography;
using System.Text;
using Microsoft.AspNetCore.Mvc;
namespace EvaporateJSTest.Controllers;
[ApiController]
[Route("signAuth")]
@GFoley83
GFoley83 / mtls-policy.xml
Created April 20, 2020 23:43 — forked from nov/mtls-policy.xml
Azure API Management Policy for MTLS
<policies>
<inbound>
<base />
<!-- TODO: limit by client_id, not token itself -->
<rate-limit-by-key calls="30" renewal-period="10" counter-key="@(context.Request.Headers.GetValueOrDefault("Authorization",""))" />
<choose>
<when condition="@(context.Request.Certificate != null && context.Request.Certificate.NotAfter > DateTime.Now)">
<set-header name="Client-Certificate" exists-action="override">
<value>@(context.Request.Certificate.GetRawCertDataString())</value>
</set-header>
@GFoley83
GFoley83 / DbDeadlockRetryHandlerProcessor.cs
Last active January 29, 2021 17:24
MediatR pipeline for retrying Db deadlocks
using System;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
namespace Foo
{
public class DbDeadlockRetryHandlerProcessor<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
{
using System;
using System.Collections.Generic;
namespace builder
{
/// <summary>
/// MainApp startup class for .NET optimized
/// Builder Design Pattern.
/// </summary>
public class MainApp
@GFoley83
GFoley83 / AsyncConsoleAppWithCancellationTokenSupport-Legacy.cs
Last active May 30, 2019 08:39
Gracefully handle exiting an async ASP.NET console app with CancellationTokenSource support
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp
{
class Program
{
// Cancellation Tokens - https://docs.microsoft.com/en-us/previous-versions/dd997289(v=vs.110)
private static readonly CancellationTokenSource canToken = new CancellationTokenSource();
# POST method: $req
$requestBody = Get-Content $req -Raw | ConvertFrom-Json
$name = $requestBody.name
# GET method: each querystring parameter is its own variable
if ($req_query_name)
{
$name = $req_query_name
}
@GFoley83
GFoley83 / LinkedIn - Remove crap posts.js
Created September 30, 2018 22:52
Unlike facebook, LinkedIn creates entire posts just for likes and comments which fills up the feed with crap. This snippet removes those posts from the feed. Best used with an Chrome extension like "Custom JavaScript for Websites".
const removeCrap = () => {
const $crapSelector = $(`
span.ember-view span:contains(" likes this"),
span.ember-view span:contains(" commented on this"),
span.ember-view span:contains(" liked "),
span.ember-view span:contains("Short course you may like"),
div.feed-shared-text-view span:contains("Promoted")
`);
const crapCount = $crapSelector.length;
@GFoley83
GFoley83 / LinkedIn - Remove crap posts.js
Created September 30, 2018 22:52
Unlike facebook, LinkedIn creates entire posts just for likes and comments which fills up the feed with crap. This snippet removes posts from the feed that aren't proper content.
const removeCrap = () => {
const $crapSelector = $(`
span.ember-view span:contains(" likes this"),
span.ember-view span:contains(" commented on this"),
span.ember-view span:contains(" liked "),
span.ember-view span:contains("Short course you may like"),
div.feed-shared-text-view span:contains("Promoted")
`);
const crapCount = $crapSelector.length;