Skip to content

Instantly share code, notes, and snippets.


John Smith solrevdev

View GitHub Profile
solrevdev /
Last active August 21, 2023 12:00
A blank empty git commit - generally used for testing ci etc.
# macos single chars are fine
git commit --allow-empty -m 'ci: empty commit for pr [skip ci]'
# windows needs double chars
git commit --allow-empty -m "ci: empty commit for pr [skip ci]"
solrevdev / HttpContextExtensions.cs
Last active August 16, 2023 10:46
Map Physical Paths with an HttpContext.MapPath() Extension Method in ASP.NET (via By Rick Strahl)
View HttpContextExtensions.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using System;
using System.IO;
/// <summary>
/// Provides extension methods for the HttpContext class.
/// </summary>
public static class HttpContextExtensions
solrevdev / DotnetAndProductVersion.cs
Created July 21, 2023 11:04
How to get the running .NET version and also the current Product version via <Version> element in csproj
View DotnetAndProductVersion.cs
using System;
using System.Reflection;
var dotnetVersion = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
Console.WriteLine($"🌄 .NET Version: {dotnetVersion}");
var productVersion = Assembly.GetEntryAssembly().GetCustomAttribute<System.Reflection.AssemblyInformationalVersionAttribute>().InformationalVersion;
Console.WriteLine($"🌄 Product Version : {productVersion}");
solrevdev / DotnetVersion.cs
Created July 20, 2023 09:14
Gets the version of .net version running this code
View DotnetVersion.cs
using System;
var dotnetVersion = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
Console.WriteLine($"🌄 .NET Version: {dotnetVersion}");
solrevdev / DateOnly.HowOldIsPerson.cs
Created July 20, 2023 09:06
Using DateOnly and Record's is C# to work out how old someone is
View DateOnly.HowOldIsPerson.cs
using System;
Console.WriteLine("No static void main");
var p = new Person(Guid.NewGuid(), "John", new DateOnly(1975, 1, 1));
public record Person(Guid Id, string Name, DateOnly DateOfBirth)
public override string ToString()
solrevdev / slugify.js
Created July 7, 2023 14:00
vanilla javascript method to slugify a string
View slugify.js
function slugify(input) {
if (!input)
return '';
// make lower case and trim
var slug = input.toLowerCase().trim();
// remove accents from charaters
slug = slug.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
solrevdev / omnisharp.json
Last active July 4, 2023 08:59
An updated omnisharp.json to try out see #omnisharp tag in for more info
View omnisharp.json
"RoslynExtensionsOptions": {
"EnableAnalyzersSupport": true,
"EnableDecompilationSupport": true,
"EnableImportCompletion": true
"FormattingOptions": {
"EnableEditorConfigSupport": true,
"OrganizeImports": true
solrevdev / download-all-images.js
Last active June 29, 2023 11:09
A browser devtools snippet to download all images on a webpage.
View download-all-images.js
$$('img').forEach(async (img) => {
try {
const src = img.src;
// Fetch the image as a blob.
const fetchResponse = await fetch(src);
const blob = await fetchResponse.blob();
const mimeType = blob.type;
// Figure out a name for it from the src and the mime-type.
const start = src.lastIndexOf('/') + 1;
const end = src.indexOf('.', start);
solrevdev / Money.cs
Last active June 26, 2023 20:02
A Money value object class/record and a generic result class/record wrapper to return it
View Money.cs
public record Money
private static readonly IReadOnlyCollection<string> SupportedCurrencies = new[] { "GBP", "EUR" };
public decimal Amount { get; }
public string Currency { get; }
private Money(decimal amount, string currency)
Amount = amount;
solrevdev / settings.json
Created June 22, 2023 15:16
micro text editor settings json file stored at ~/.config/micro/settings.json
View settings.json
"colorscheme": "bubblegum",
"fontFace": "IntelOne Mono"