Skip to content

Instantly share code, notes, and snippets.

View edblackburn's full-sized avatar

Ed Blackburn edblackburn

View GitHub Profile
@edblackburn
edblackburn / prune_branches.sh
Created September 19, 2023 17:40
Uses git branch -d to remove all branches except for trunk (default is "develop") for a given git repo
#!/bin/bash
# ./prune_branches.sh /path/to/your/repo
# Check if a repository directory parameter is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <repository_directory>"
exit 1
fi
import pytest
from datetime import datetime
from typing import Callable, Any
from cloudevents.sdk.event import v1 as cloud_event
def handle_new_file_event(event: cloud_event.Event, storage_client: Callable[[Callable[[Any], None]], None],
checksum_calculator: Callable[[str], str], writer: Callable[[Any, str], None]) -> None:
file_path = event.data
try:
@edblackburn
edblackburn / electron-meet.sh
Created December 8, 2021 17:02
Electron Meet
# Just bought my wife an artificial leg for Christmas.
# It’s not her main present just a stocking filler.
git clone git@github.com:Urban82/electron-google-meet.git
cd electron-google-meet/src/app/
npm install --save-dev electron
npm start
@edblackburn
edblackburn / vbox-6-0-16.rb
Last active September 9, 2021 13:58
Homebrew cask for Virtual Box version 6.0.16
# Hello, world!
cask 'vbox-6-0-16' do
version '6.0.16-135675-OSX'
sha256 '414a7b8ac37510b2a8db4c624718b1bef397d1374e5baf48417733464c7adc99'
url "https://download.virtualbox.org/virtualbox/6.0.16/VirtualBox-6.0.16-135675-OSX.dmg"
name 'Oracle VirtualBox'
homepage 'https://www.virtualbox.org/'
conflicts_with cask: 'virtualbox-beta'
@edblackburn
edblackburn / MyApiBootstrapper.cs
Last active October 17, 2017 12:54
Containerless Nancy bootstrapper
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Configuration;
using Nancy.Conventions;
@edblackburn
edblackburn / simple_projector.cs
Last active January 16, 2017 23:12
Simplest projector
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
namespace left_fold_projector
{
class Program
{
@edblackburn
edblackburn / combguid.cs
Created September 25, 2015 12:59
combined / sequential guid - targeted at ms sql server
byte[] destinationArray = Guid.NewGuid().ToByteArray();
DateTime time = new DateTime(0x76c, 1, 1);
DateTime now = DateTime.Now;
TimeSpan span = new TimeSpan(now.Ticks - time.Ticks);
TimeSpan timeOfDay = now.TimeOfDay;
byte[] bytes = BitConverter.GetBytes(span.Days);
byte[] array = BitConverter.GetBytes((long) (timeOfDay.TotalMilliseconds / 3.333333));
Array.Reverse(bytes);
Array.Reverse(array);
Array.Copy(bytes, bytes.Length - 2, destinationArray, destinationArray.Length - 6, 2);
@edblackburn
edblackburn / AssignableExtensions.cs
Created September 15, 2015 10:23
Can type be assigned from a generic contract?
public static class AssignableExtensions
{
/// <summary>
/// Determines whether the <paramref name="genericType" /> is assignable from
/// <paramref name="givenType" /> taking into account generic definitions
/// </summary>
public static bool IsAssignableToGenericType(this Type givenType, Type genericType)
{
if (givenType == null || genericType == null)
{
internal class Employee
{
public string NationalInsuranceNumber { get; set; }
}
@edblackburn
edblackburn / gist:3707895
Created September 12, 2012 16:29
Custom TestCaseSourceAttribute example
public class DocumentFileNameExamplesAttribute : TestCaseSourceAttribute
{
public DocumentFileNameExamplesAttribute()
: base(typeof(DocumentFileNameExamplesAttribute), "FileNameExamples")
{
}
// ReSharper disable UnusedMethodReturnValue.Local
private static IEnumerable<TestCaseData> FileNameExamples
{