Skip to content

Instantly share code, notes, and snippets.

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

Chris F Carroll chrisfcarroll

🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼
View GitHub Profile
@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
@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 / 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 / AutoHotKey for a Mac User with PC keyboard on Windows.ahk
Last active January 11, 2024 11:19
A Pair of AutoHotKey Scripts for they who, being Mac Users, yet still insist on using Windows. One for an Apple keyboard, one for a PC keyboard. Also some arrange-windows-on-a-big-screen keys . Takes a similar approach as Parallels to keyboard mapping: rather than a wholesale swap of Cmd <-> Ctrl, instead duplicate favourite ctrl-key shortcuts t…
; Language: English
; Uses unicode. Save this file as utf-8 with BOM.
; Else it shall not work.
;
#NoEnv ; Recommended
SendMode Event
SetWorkingDir %userprofile% ; Ensures a consistent starting directory.
; === autotexts ========================================================
;
# 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 / 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 / Bash-or-PowerShell-with-Param.ps1
Last active August 23, 2023 11:41
Hold both bash and PowerShell code in a single script file and/or make a PowerShell.ps1 script executable on all platforms. For Windows, *nix, linux and macOs. See Comments below
` # \
# PowerShell Param statement : every line must end in #\ except the last line must with <#\
# And, you can't use backticks in this section #\
param( [ValidateSet('A','B')]$tabCompletionWorksHere, #\
[switch]$andHere #\
) <#\
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `
#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# Bash Start ------------------------------------------------------------
@chrisfcarroll
chrisfcarroll / tmMakeImage
Last active May 2, 2023 11:43
A commandline script for MacOS, to create a TimeMachine Backup Volume on a non-Apple formatted disk
#!/bin/bash
# 2015 Updates to sunkid's script. chrisfcarroll
# - added more quote marks to cope with e.g. spaces in volume names.
# - get machine UUID from ioreg instead of parsing and system report.
# - added steps to tell Time Machine to use your new backup drive.
# - renamed.
# Make it executable with e.g. chmod a+x tmMakeImage && mv tmMakeImage /usr/local/bin.
#
# A bash script to create a time machine disk image suitable for
# backups with OS X 10.6 (Snow Leopard) and later.
@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;
@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