Skip to content

Instantly share code, notes, and snippets.

View martincostello's full-sized avatar
🚀
Coding stuff

Martin Costello martincostello

🚀
Coding stuff
View GitHub Profile
@davidfowl
davidfowl / MinimalAPIs.md
Last active April 10, 2024 04:24
Minimal APIs at a glance
@NickCraver
NickCraver / Microsoft.PowerShell_profile.ps1
Last active March 18, 2024 13:25
Craver's oh-my-posh profile
# This goes in your Microsoft.PowerShell_profile.ps1 (can find the path via $PROFILE in your prompt)
Import-Module -Name posh-git,oh-my-posh,Terminal-Icons
Set-PoshPrompt -Theme craver
using System;
using System.Threading.Tasks;
namespace System.Collections.Concurrent
{
public static class ConcurrentDictionaryExtensions
{
/// <summary>
/// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>.
/// </summary>
@blowdart
blowdart / UpdateIISExpressSSLForChome.ps1
Last active October 7, 2021 10:59
IIS Express certs (for now) don't contain SAN strings. This makes Chrome unhappy. Make Chrome happy again with a new organic, artisanal, gluten free HTTPS certificate.
# Create a new self signed HTTPS Certificate for IIS Express
# Crafted with all organic, GMO, gluten free ingreditations
# with an artisinal SAN to make Chrome 58 onwards happy.
#
# See https://bugs.chromium.org/p/chromium/issues/detail?id=308330
#
# Run this at an administrative PowerShell prompt.
#
# You will be prompted to trust a new certificate via a windows dialog.
# Click yes otherwise Visual Studio will not be able to determine your
@jchandra74
jchandra74 / openssl.MD
Last active February 16, 2024 21:23
HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window

Overview

My main development workstation is a Windows 10 machine, so we'll approach this from that viewpoint.

Recently, Google Chrome started giving me a warning when I open a site that uses https and self-signed certificate on my local development machine due to some SSL certificate issues like the one below:

Self-Signed SSL Issue in Chrome

@jseed
jseed / gist:5d022570ea52ee09a8f43913214496f1
Last active February 7, 2024 10:01
PowerShell command to delete all branches except master
git checkout master; git branch -D @(git branch | select-string -NotMatch "master" | Foreach {$_.Line.Trim()})
@NickCraver
NickCraver / ExampleUsage.cs
Last active November 27, 2021 04:24
Code to mark a SQL string before it's passed to Dapper.
public static List<T> Query<T>(this DataContext db, string sql, object param = null, int? commandTimeout = null, IDbTransaction transaction = null, [CallerFilePath]string fromFile = null, [CallerLineNumber]int onLine = 0, string comment = null)
{
using (db.Connection.EnsureOpen())
{
try
{
return db.Connection.Query<T>(MarkSqlString(sql, fromFile, onLine, comment), param, transaction ?? db.Transaction, true, commandTimeout).AsDapperList();
}
catch (SqlException ex) when (ex.Is(SqlErrorCode.DatabaseReadOnly_3906))
{
@AlbertoMonteiro
AlbertoMonteiro / 01.md
Last active January 23, 2024 10:11
Migration from Moq to NSubstitute
@hofmannsven
hofmannsven / README.md
Last active April 19, 2024 13:17
Git CLI Cheatsheet
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");