Tutorial and tips for GitHub Actions workflows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <Configuration> | |
| <ViewDefinitions> | |
| <View> | |
| <Name>MatchInfo</Name> | |
| <ViewSelectedBy> | |
| <TypeName>Microsoft.PowerShell.Commands.MatchInfo</TypeName> | |
| </ViewSelectedBy> | |
| <CustomControl> | |
| <CustomEntries> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires -Modules DynamicTitle | |
| $commandStartJob = Start-DTJobCommandPreExecutionCallback -ScriptBlock { | |
| param($command) | |
| (Get-Date), $command | |
| } | |
| $promptJob = Start-DTJobPromptCallback -ScriptBlock { | |
| (Get-Date) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Reference: | |
| # https://devblogs.microsoft.com/commandline/shell-integration-in-the-windows-terminal/ | |
| param | |
| ( | |
| [ValidateSet('WindowsTerminal', 'ITerm2')] | |
| [String]$TerminalProgram = 'WindowsTerminal' | |
| ) | |
| # Restore hooked functions in case this script is executed accidentally twice |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $sw = [Diagnostics.Stopwatch]::StartNew() | |
| Write-Host "Updating path..." -foregroundColor DarkGreen | |
| if(!($env:path).contains((Split-Path $PROFILE))) { | |
| $env:path += ";" + (Split-Path $PROFILE) | |
| } | |
| if(!($env:path).contains('D:\dNx\dnx-util;')) { | |
| $env:path += ";" + 'D:\dNx\dnx-util;' | |
| } | |
| if(!($env:path).contains('D:\dNx\dnx-util\test;')) { | |
| $env:path += ";" + 'D:\dNx\dnx-util\test;' |
Credit: Mark Kraus
Website: https://get-powershellblog.blogspot.com
- Use Arrays if you know the element types and have a fixed length and/or known-up-front collection size that will not change.
- Use ArrayList if you have an unkown collection size with either unknown or mixed type elements.
- Use a Generic List when know the type of the elements but not the size of the collection.
- Use a HashTable if you are going to do key based lookups on a collection and don't know the object type of the elements.
- Use a Dictionary<TKey, TValue> you are going to do key based lookups on a collection and you know the type of the elements.
- Use a HashSet when you know the type of elements and just want unique values and quick lookups and assignmnets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Notes on the act of developing with external repositories (i.e. submodules) in git and pester | |
| *To the reader:* If you are here looking for expert advice, please leave as swiftly as possible. No such advice is present here. This is purely a set of reminders for the physical(?) act of how I handle working with git submodules and pester tests. | |
| This assumes you are working in PowerShell. Version 5, if it matters, with git 2.10 (or later? It was what I had when I wrote this) and pester. | |
| *Downloading and using a repo with submodules* - When I was getting started with this, I NEVER developed submodules from the main module. I schlepped over to the submodule, branch, develop, merge back to master, and then come back here and update the submodule, and I still think that's a good policy for anything other than mass hotfixes. | |
| Clone the repo as normal. Here, the folder PesterNewFixtureModule will be created in the current folder: | |
| git clone https://github.com/sdoubleday/PesterNewFixtureModule.git PesterNewFixtureModu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Simple functions and aliases that don't rise to the level of a module that I like having in my PowerShell Profile | |
| function sudo {[CmdletBinding(<#PositionalBinding=$True#>)]PARAM([String]$CommandLine,[Switch]$RunPrior) IF($RunPrior.IsPresent) {$CommandLine = (Get-History | Select-Object -Last 1).CommandLine}; Write-Verbose "Running: $CommandLine"; start-process powershell -verb:Runas "$CommandLine"} | |
| function outlook {. 'C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE' /restore} | |
| function newdir {PARAM($Path) new-item -ItemType Directory -Path $Path } | |
| function ssms2008 {ls 'C:\Program Files\', 'C:\Program Files (x86)\' -Filter micro*Sql*server | ls -Filter '100' | ls -Recurse -Filter *ssms*exe | ii} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Classes do not always play well in the nested modules section of a manifest. I've had trouble with importing classes in multiple files. | |
| #My current approach is: Create a .ps1 file WITHOUT the standard clauses of BEGIN{} PROCESS{} END{} that uses invoke-expressions: | |
| $invocables = @() | |
| $invocables += $( get-content "$PSScriptRoot\MyFolder\MyClass.psm1" ) -join "`r`n" | |
| $invocables += $( get-content "$PSScriptRoot\MyOtherClassThatDepenedsOnTheFirstOne.psm1" ) -join "`r`n" | |
| foreach ($i in $invocables) { Invoke-Expression -Command $i } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Classes do not always play well in the nested modules section of a manifest. I've had trouble with importing classes in multiple files. | |
| #My current approach is: Create a .ps1 file WITHOUT the standard clauses of BEGIN{} PROCESS{} END{} that uses invoke-expressions: | |
| $invocables = @() | |
| $invocables += $( get-content "$PSScriptRoot\MyFolder\MyClass.psm1" ) -join "`r`n" | |
| $invocables += $( get-content "$PSScriptRoot\MyOtherClassThatDepenedsOnTheFirstOne.psm1" ) -join "`r`n" | |
| foreach ($i in $invocables) { Invoke-Expression -Command $i } |