Skip to content

Instantly share code, notes, and snippets.

@ninmonkey
ninmonkey / Power Query Fancy Docs with Html.md
Last active August 29, 2023 22:40
Some html formatting is used by Power Query's doc strings

Here's a random example to demonstrate html

Tips : Multiline strings

It can be messy writing a bunch of newlines in a multiline string. It's easier to use a list of strings that combine.

For Html newlines

= Text.Combine({ "Line1", "", "Line3" }, "<br>")
@ninmonkey
ninmonkey / Write-LogMessage.ps1.md
Created August 11, 2023 18:19
Write-LogMessage.ps1.md
Write-LogMessage Verbose -Message 'stuff' -Json @{ 'user' = 'bob'; id = 100 }
function New-SafeFileTimeNowString {
    <#
    .SYNOPSIS
        timenow for safe filepaths: "2022-08-17_12-46-47Z"
    .notes
@ninmonkey
ninmonkey / Pwsh Config i Vs Code - temp example.md
Last active August 2, 2023 23:46
Pwsh Config i Vs Code - temp example.ps1

settings.json

{
    "powershell.startAutomatically": true,
    "powershell.enableProfileLoading": true,
    "powershell.integratedConsole.showOnStartup": true,
    "powershell.integratedConsole.suppressStartupBanner": false,
    "powershell.promptToUpdatePackageManagement": false,
    "powershell.promptToUpdatePowerShell": false,
@ninmonkey
ninmonkey / format-predent-test.md
Last active July 1, 2023 19:53
format-predent-test.md
@ninmonkey
ninmonkey / power-query-null-coalesce.pq
Created July 6, 2022 20:52
power-query-null-coalesce.pq
let
joinText = (source as list, options as nullable record) as text =>
let
culture = options[Culture]? ?? "en-us",
sep = options[Separator]? ?? ", ",
asText = List.Transform(
source, each Text.From( _, culture ) ),
render = Text.Combine( asText, sep )
in
@ninmonkey
ninmonkey / comparing original.md
Last active June 7, 2023 00:44
Refactoring ArrayList with as a Modern Array Example

I call it modern, but it fully works on PS5.1 without changes!

tip: abbreviated version using namespaces

In the examples below, if you add a using namespace statement, you can remove Systems.Collections.Generic tip: System is always included, so you can omit that prefix anywhere as well.

using namespace system.collections.generic
[List[Object]]$users = @()
@ninmonkey
ninmonkey / generated_export.cs
Last active May 12, 2023 06:10
Generate-CodepointWidthsFromUCD.ps1 a tool from /Terminal
// Generated by Generate-CodepointWidthsFromUCD.ps1 -Pack:True -Full: -NoOverrides:False
// on 2023-05-12 05:07:14Z from Unicode 15.0.0.
// 321149 (0x4E67D) codepoints covered.
// 240 (0xF0) codepoints overridden.
// Override path: G:\my🍴\microsoft🧑\terminal\src\types\unicode_width_overrides.xml
static constexpr std::array<UnicodeRange, 297> s_wideAndAmbiguousTable{
UnicodeRange{ 0xa1, 0xa1, 1 },
UnicodeRange{ 0xa4, 0xa4, 1 },
UnicodeRange{ 0xa7, 0xa8, 1 },
UnicodeRange{ 0xaa, 0xaa, 1 },