Skip to content

Instantly share code, notes, and snippets.

View CQRS.cs
// This is not CQRS:
public interface IRobotService
void Walk();
void Sleep();
int GetBatteryLevel();
void GoOutAndComeBackInAgain();
// This is CQRS. You can "level-up" from here, but this is all it is, really
View Invoke-ParameterisedSqlQuery.ps1
function Invoke-ParameterisedSqlQuery {
param (
[string] $ConnectionString,
[string] $Query,
[PSCustomObject[]] $QueryArgs
nbarnwell / GitVersionIncrement.ps1
Last active August 4, 2023 15:38
Simple PowerShell script to create the appropriate next tag on a git repo
View GitVersionIncrement.ps1
function Get-Version {
# TODO: Implement a call to GitVersion on the command line to find the current version from the repo
function New-Tag {
[string] $Tag)
process {
View VIM

Moving around

Action Keys Notes
Down, Up, Left, Right h, j, k, l
Start/end of line ^/$
Beginning of next word/non-whitespace w/W
End of word/non-whitespace e/E
Move until "x" tx
View EventSourcedSalesOrderExample.cs
public interface Event
public Guid Id;
public Guid CausationId;
public CorrelationId;
public Guid [AggregateName]Id;
public int Version;
nbarnwell / Update-ConnectionString.ps1
Last active August 29, 2015 14:17
View Update-ConnectionString.ps1
function Update-ConnectionString {
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string[]] $ConnectionString,
[Parameter(Mandatory = $true)]
[string] $PropertyName,
[Parameter(Mandatory = $true)]
[string] $Value)
begin {
nbarnwell / Invoke-PackageUpdate
Last active August 8, 2018 14:51
Update specific packages based on wildcard (or regex pattern) using PowerShell outside the Visual Studio Package Manager Console. Caveat: I'm not a PowerShell expert and I'm pretty sure there must be terser ways to accomplish the same, but the command-line argument requirements of nuget.exe required this to be more complex than I'd have liked. :)
View Invoke-PackageUpdate
gci -r -inc packages.config |
([xml](get-content $_)) |
Add-Member -NotePropertyName 'PackageConfigFile' -NotePropertyValue $_ -PassThru
} |
?{ $_ -like 'MyCompany.*' } |
%{ nuget.exe update $_.PackageConfigFile -Id $_ -RepositoryPath (join-path (split-path (Split-Path $_.PackageConfigFile)) 'packages') }