jq is useful to slice, filter, map and transform structured json data.
brew install jq
#region Initializer | |
function New-WebPlatformInstaller | |
{ | |
[OutputType([Void])] | |
[CmdletBinding()] | |
param() | |
try | |
{ |
function Convert-CodeCoverage { | |
<# | |
.SYNOPSIS | |
Convert the file name and line numbers from Pester code coverage of "optimized" modules to the source | |
.EXAMPLE | |
Invoke-Pester .\Tests -CodeCoverage (Get-ChildItem .\Output -Filter *.psm1).FullName -PassThru | | |
Convert-CodeCoverage -SourceRoot .\Source -Relative | |
Runs pester tests from a "Tests" subfolder against an optimized module in the "Output" folder, | |
piping the results through Convert-CodeCoverage to render the code coverage misses with the source paths. |
# Find PowerShell Code Snippets Function | |
function findit | |
{ | |
param | |
( | |
[Parameter(Mandatory=$True,Position=0)][string]$SearchString, | |
[Parameter(Mandatory=$False)]$Path = "$env:USERPROFILE\Documents", | |
[Parameter(Mandatory=$False)]$Filter = "*.ps1" | |
) | |
Get-ChildItem -Path $Path -Filter $Filter -Recurse | Select-String $SearchString | select path, @{n="MatchingLines";e={"$($_.LineNumber.tostring("000")): $($_.Line -replace "^[ \t]*",'')"}} | group path | select name, @{n="Matches";e={$_.Group.MatchingLines | Out-String}} | Out-GridView -PassThru | %{psedit -filenames $_.name} |
class MagicNumber | |
{ | |
hidden [int] $_value | |
MagicNumber([int]$value) | |
{ | |
$this._value = $value | |
} | |
# ECMA-335 I.10.3.2 |
This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.
Description | Syntax |
---|---|
Get the length of a string | ${#VARNAME} |
Get a single character | ${VARNAME[index]} |
#!/usr/bin/env bash | |
CORTEX_CRYPTO="aes-256-cbc" | |
_cortex_logger() { printf '{%s}[%s](%s):%s\t%s\n' "$(date -u '+%FT%TZ')" "${1}" "$(caller)" "${2}" "${@:3}" 1>&2; } | |
_cortex_io() { | |
case "${CORTEX_FILE}" in | |
"") _cortex_logger "$(caller)" ERR "CORTEX_FILE environment variable is empty/unset" && return 127 ;; | |
*) |