Skip to content

Instantly share code, notes, and snippets.

View crshnbrn66's full-sized avatar

Thom Schumacher crshnbrn66

View GitHub Profile
@szampardi
szampardi / cortex.sh
Last active September 21, 2023 17:33
use a json file for shell vars
#!/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 ;;
*)

ZSH CheatSheet

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.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@IISResetMe
IISResetMe / MagicNumber.class.ps1
Created December 19, 2020 21:18
ECMA-335 SpecialName-based operator overloading in PowerShell classes
class MagicNumber
{
hidden [int] $_value
MagicNumber([int]$value)
{
$this._value = $value
}
# ECMA-335 I.10.3.2
@ScriptingPro
ScriptingPro / find_it.ps1
Last active September 18, 2020 13:01
Search your PS1 files and open in ISE
# 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}
@Jaykul
Jaykul / Convert-CodeCoverage.ps1
Last active June 11, 2018 07:11
How we "compile" modules from source .ps1 files
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.
@olih
olih / jq-cheetsheet.md
Last active May 2, 2024 00:42
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@guitarrapc
guitarrapc / WebPlatformInstaller.ps1
Last active June 15, 2016 22:40
PowerShell WebPlatformInstaller Module (rough)
#region Initializer
function New-WebPlatformInstaller
{
[OutputType([Void])]
[CmdletBinding()]
param()
try
{