Skip to content

Instantly share code, notes, and snippets.

View chrisfcarroll's full-sized avatar
🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼

Chris F Carroll chrisfcarroll

🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼
View GitHub Profile
@chrisfcarroll
chrisfcarroll / strings.cs
Last active February 3, 2024 13:16
C# string.MaskStart(), .MaskEnd(), string.Chop() string.ToWikiWords(), PascalCaseToWords() string.WithWhiteSpaceRemoved() and similar
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text.RegularExpressions;
public static class StringExtensions
{
/// <summary>Trim one occurrence of <paramref name="terminator"/> string from
/// the end of <paramref name="str"/>, if there is one.
@chrisfcarroll
chrisfcarroll / EFCoreAndDomainModels.cs
Last active November 7, 2023 12:39
Minimal EFCore Demo for Domain-Application-Infrastructure DDD structure
using System.Diagnostics;
using EFCoreAndDomainModels.Application;
using EFCoreAndDomainModels.Domain;
using EFCoreAndDomainModels.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using TestBase;
using Xunit.Abstractions;
namespace EFCoreAndDomainModels
@chrisfcarroll
chrisfcarroll / azcommandlineexamples.sh
Created January 28, 2023 16:42
Show some example az cli commands to create and delete a VM
#! /usr/bin/env sh
cat << 'EOF'
Get pricing:
location.href="https://prices.azure.com/api/retail/prices?$skip=0&currencyCode='GBP'&$filter=location eq 'UK South' and serviceName eq 'Virtual Machines' and priceType eq 'Consumption'"
Create Spot VM
az vm create -g VM --name VM --admin-username azureuser --image CentOS --generate-ssh-keys --public-ip-sku Standard --priority Spot --eviction-policy Delete
Destroy VM
@chrisfcarroll
chrisfcarroll / AzBlobStorageReader.cs
Last active January 29, 2023 19:23
Azure Blob Storage parallel downloads of 1000s files
//
// Dependency: dotnet add package Azure.Storage.Blobs
// #r "nuget:Azure.Storage.Blobs"
//
// Parallel download blobs from an Azure Blob Storage container, and report speed and bandwidth metrics
// As is, this code searches for blobs by index tag. To download by virtual folder instead,
// replace blobItems = containerClient.FindBlobsByTags(indexTagFilter) with
// blobItemsUntagged = containerClient.GetBlobs();
//
using System.Diagnostics;
# This is Git's per-user configuration file.
# [user]
[alias]
root = rev-parse --show-toplevel
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
[merge]
tool = p4merge
[color]
ui = true
[color "status"]
@chrisfcarroll
chrisfcarroll / MacKeyboardOnPc.ahk
Last active January 15, 2024 11:18
MacKeyboardOnPc Minimal.ahk
#Requires AutoHotkey v2.0
;
; AutoHotKey 2.0 typographic relief for Mac keyboard users on Windows, whether
; — plugging a Mac Keyboard into a PC
; — or just missing the extended typographic symbols that the Mac puts on the Alt keys.
;
; Set these Switches to true/false to match your preferences.
;
openCharMapOnWinShiftDot := true
addCommonMacOSisms := true
@chrisfcarroll
chrisfcarroll / Microsoft.PowerShell_profile.ps1
Last active March 28, 2024 14:57
Common Aliases and Paths for PowerShell Profile Microsoft.PowerShell_profile.ps1
# https://gist.github.com/chrisfcarroll/f3ecb2892f996149ee039d48abb57101
# Aliases and Paths for PowerShell Profile ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
#
# -----------------------------------------------------
# For machines where you have no privileges you should be able to enable scripts for yourself only with:
#
# `Set-ExecutionPolicy RemoteSigned -Scope CurrentUser`
# -----------------------------------------------------
#
# Sections: Paths, Editors, Tab Completion, Git abbreviations, Docker abbreviations, other prefs, firstRun
#nullable enable
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic;
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace LogAssert
{
@chrisfcarroll
chrisfcarroll / LowerCaseIdentifiersForAppDbOnPostgres.cs
Last active May 16, 2022 22:06
.Net DbContext for Postgres that lowercases identifiers so that quotes are not needed everywhere
public class AppDbOnPostgres : DbContext
{
public AppDbOnPostgres(NpgsqlConnection dbConnection):base(dbConnection){}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseNpgsql(dbConnection)
.ReplaceService<ISqlGenerationHelper,NpgsqlSqlGenerationLowercasingHelper>();
}
@chrisfcarroll
chrisfcarroll / bootstrap-macOs.zsh
Last active March 16, 2022 12:51
Bootstrap macOs fresh install. Part 1
#! /bin/zsh
#
# Manual Install packages
open https://www.sublimetext.com
open https://www.perforce.com/downloads/visual-merge-tool
open https://dotnet.microsoft.com
open https://code.visualstudio.com
open https://my.parallels.com
open https://brew.sh
open https://www.wolfram.com/mathematica/