Skip to content

Instantly share code, notes, and snippets.

View Invoke-ParameterisedSqlQuery.ps1
function Invoke-ParameterisedSqlQuery {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string] $ConnectionString,
[Parameter(Mandatory)]
[string] $Query,
[Parameter(ValueFromPipeline)]
[PSCustomObject[]] $QueryArgs
)
@nbarnwell
nbarnwell / GitVersionIncrement.ps1
Last active Aug 9, 2021
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 {
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(Mandatory=$true)]
[string] $Tag)
process {
View VIM Cheatsheet.md

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
nbarnwell / Update-ConnectionString.ps1
Last active Aug 29, 2015
Update-ConnectionString
View Update-ConnectionString.ps1
function Update-ConnectionString {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string[]] $ConnectionString,
[Parameter(Mandatory = $true)]
[string] $PropertyName,
[Parameter(Mandatory = $true)]
[string] $Value)
begin {
@nbarnwell
nbarnwell / Invoke-PackageUpdate
Last active Aug 8, 2018
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 $_)).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') }