Skip to content

Instantly share code, notes, and snippets.

@nbarnwell
nbarnwell / GitVersionIncrement.ps1
Last active August 4, 2023 15:38
Simple PowerShell script to create the appropriate next tag on a git repo
function Get-Version {
# TODO: Implement a call to GitVersion on the command line to find the current version from the repo
}
function New-Tag {
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(Mandatory=$true)]
[string] $Tag)
process {
// 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
function Invoke-ParameterisedSqlQuery {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string] $ConnectionString,
[Parameter(Mandatory)]
[string] $Query,
[Parameter(ValueFromPipeline)]
[PSCustomObject[]] $QueryArgs
)
@nbarnwell
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. :)
gci -r -inc packages.config |
%{
([xml](get-content $_)).packages.package.id |
Add-Member -NotePropertyName 'PackageConfigFile' -NotePropertyValue $_ -PassThru
} |
?{ $_ -like 'MyCompany.*' } |
%{ nuget.exe update $_.PackageConfigFile -Id $_ -RepositoryPath (join-path (split-path (Split-Path $_.PackageConfigFile)) 'packages') }

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
public interface Event
{
public Guid Id;
public Guid CausationId;
public CorrelationId;
public Guid [AggregateName]Id;
public int Version;
}
@nbarnwell
nbarnwell / Update-ConnectionString.ps1
Last active August 29, 2015 14:17
Update-ConnectionString
function Update-ConnectionString {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string[]] $ConnectionString,
[Parameter(Mandatory = $true)]
[string] $PropertyName,
[Parameter(Mandatory = $true)]
[string] $Value)
begin {