Skip to content

Instantly share code, notes, and snippets.

View jafin's full-sized avatar
🏠
Brisbane, AU

Jason Finch jafin

🏠
Brisbane, AU
  • Brisbane, Australia
  • 16:46 (UTC +10:00)
View GitHub Profile
@SolidAlloy
SolidAlloy / SpanExtensions.cs
Created January 18, 2021 13:39
ReadOnlySpan Split
using System;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
// Reduced-down and slightly refactored version of https://gist.github.com/LordJZ/92b7decebe52178a445a0b82f63e585a
// It exposes only (T separator) overload of the Split method which was enough for my needs.
public static class SpanExtensions
{
public readonly ref struct Enumerable<T>
where T : IEquatable<T>
@detunized
detunized / nunut2xunit.cs
Created March 12, 2019 23:23
Convert NUnit to xUnit
// Copyright (C) 2019 Dmitry Yakimenko ([email protected]).
// Licensed under the terms of the MIT license. See LICENCE for details.
using System;
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@LordJZ
LordJZ / SpanSplitExtensions.cs
Created August 9, 2018 18:04
Split for Span
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
public static class SpanSplitExtensions
{
public ref struct Enumerable1<T> where T : IEquatable<T>
{
public Enumerable1(ReadOnlySpan<T> span, T separator)
{
@dcode
dcode / GitHub Flavored Asciidoc (GFA).adoc
Last active March 20, 2025 13:24
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)

@pvdz
pvdz / gist:26473dd35c9ebd04d8a089fc0cd319d3
Created August 20, 2016 07:33
mass steam confirmation clicking in gmail (through console)
var e = document.createElement('div');
e.innerHTML = Array.from(document.body.querySelectorAll('a[href^="https://steamcommunity.com/market/confirmlisting/"]'))
.filter(e => e.href.indexOf('cancel') < 0)
.map(e => '<a href="'+e.href+'" onclick="p=this.parentNode;p.removeChild(this.nextElementSibling);p.removeChild(this);if(!p.children.length)p.parentNode.removeChild(p);">'+e.href+'</a><br>')
.join('\n');
document.body.appendChild(e);
e.style.position = 'absolute';
e.style.top = 0;
e.style.backgroundColor='white';
e.style.border='1px solid black';
@zihotki
zihotki / LogRequestModule.cs
Created April 6, 2016 12:40
Autofac module to write to debug output component resolve and activation messages
public class LogRequestModule : Module
{
public int depth = 0;
protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry,
IComponentRegistration registration)
{
registration.Preparing += RegistrationOnPreparing;
registration.Activating += RegistrationOnActivating;
//registration.Activated += RegistrationOnActivated;
@vkhorikov
vkhorikov / CustomerController.cs
Last active April 20, 2025 09:15
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(
@EdCharbeneau
EdCharbeneau / Enable-Transformations.md
Last active May 6, 2024 11:44
How to enable transformations on build with Visual Studio

#Transform web.config on build

  1. Unload the project
  2. Edit .csproj
  3. Append figure 1 to the end of the file just before </Project>; v12.0 my change depending on your version of Visual Studio
  4. Save .csproj and reload
  5. Open configuration manager
  6. Add a new Configuration Name: Base. Copy settings from: Release
  7. Copy the contents of your web.config
  8. Right click Web.Config > Add Config Transformation
@lukevenediger
lukevenediger / BetterExpando.cs
Last active April 7, 2023 06:11
BetterExpando is a better Expando object because you can: 1) test for the presence of a property 2) return String.Empty for all properties that aren't found 3) control whether property names are case-sensitive or not 4) augment two BetterExpando objects together to get a union of their properties.
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace statsd.net.shared
{
public class BetterExpando : DynamicObject
@anth-3
anth-3 / passThruProxy.cs
Last active April 24, 2019 11:18
Defines a simple pass-through proxy interface for C#.NET (IIS) Server applications and web sites.
<%@ WebHandler Language="C#" Class="PassThruProxy" Debug="true" %>
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Web;
/**
* <summary><c>PassThruProxy</c> is a simple pass-through proxy interface for C#.NET (IIS Servers).</summary>