Skip to content

Instantly share code, notes, and snippets.

View danielmackay's full-sized avatar

Daniel Mackay [SSW] danielmackay

View GitHub Profile
@thoemmi
thoemmi / AnsiConsoleExtensions.cs
Created June 13, 2022 20:44
Extension method for Spectre.Console to write JSON with syntax highlighting
public static class AnsiConsoleExtensions
{
public static IAnsiConsole WriteJson(this IAnsiConsole console, JsonElement node, JsonStyle? jsonStyle = null)
{
ArgumentNullException.ThrowIfNull(console);
ArgumentNullException.ThrowIfNull(node);
console.WriteJson(node, jsonStyle ?? JsonStyle.Default, 0);
return console;
}
@timotgl
timotgl / uninstall-logitech-ghub.sh
Created April 4, 2022 12:15
How to fully uninstall Logitech G HUB on macOS via terminal/command line
# How to fully uninstall Logitech G HUB on macOS via terminal/command line
# Tested on macOS version 12.3.1 (21E258) Monterey in April 2022
# with Logitech G HUB version 2022.3.242300 (released on 2022-03-22) installed.
# 1. Make sure "Logitech G HUB" itself is not running. If it is, quit it.
# 2. Open "Activity Monitor" and force-quit all processes named "lghub*".
# 3. Delete system-wide files
sudo rm -rf /Applications/lghub.app
@benmccallum
benmccallum / HC_ResolverScopedService
Last active April 2, 2021 14:43
Resolver scoping middleware (MediatR) for HotChocolate
A middleware to provide resolvers with their own, scoped instance, of a service. Example here is IMediator, but this could be made generic.
@SQLAdrian
SQLAdrian / drawbrent.sql
Last active June 21, 2024 00:19
Let's draw Brent
/*Adrian Sullivan - 2019/11/15 Fun with polygons.*/
/*Thanks to Michael J Swart for all the awesome work on color
https://michaeljswart.com/
*/
DECLARE @tt table(id int identity(0,1), label VARCHAR(50), gg GEOMETRY)
SET NOCOUNT ON
DECLARE @g geometry = 'POLYGON((-121.97087 37.372518,-121.97087 37.372518,-121.970863 37.372517,-121.970845 37.372515,-121.97087 37.372518))'
@jbogard
jbogard / Featurefolders.cs
Created October 3, 2013 15:55
Feature folders
public class FeatureViewLocationRazorViewEngine : RazorViewEngine
{
public FeatureViewLocationRazorViewEngine()
{
ViewLocationFormats = new[]
{
"~/Features/{1}/{0}.cshtml",
"~/Features/{1}/{0}.vbhtml",
"~/Features/Shared/{0}.cshtml",
"~/Features/Shared/{0}.vbhtml",
@ducas
ducas / TodoApiController.cs
Created February 27, 2012 02:55
Validating your model with Web API
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Data;
public class TodoApiController : ApiController
{
private BetterMobileSpaContext db = new BetterMobileSpaContext();
// GET /api/todoapi
@jferguson
jferguson / gist:1681480
Created January 26, 2012 07:12
SqlBulkCopy Generic List<T>
public static void BulkInsert<T>(string connection, string tableName, IList<T> list)
{
using (var bulkCopy = new SqlBulkCopy(connection))
{
bulkCopy.BatchSize = list.Count;
bulkCopy.DestinationTableName = tableName;
var table = new DataTable();
var props = TypeDescriptor.GetProperties(typeof(T))
//Dirty hack to make sure we only have system data types