Skip to content

Instantly share code, notes, and snippets.

View JPRuskin's full-sized avatar

James Ruskin JPRuskin

View GitHub Profile
@Jaykul
Jaykul / SubscriptionNameCompleterAttribute.ps1
Last active September 14, 2020 10:55
Bonus Argument Completers For Azure
using namespace Microsoft.Azure.Commands.Common.Authentication.Abstractions
using namespace System.Management.Automation.Language
using namespace System.Management.Automation
using namespace System.Collections.Generic
using namespace System.Collections
[AttributeUsage("Property,Field")]
class SubscriptionNameCompleter : ArgumentCompleterAttribute {
# PowerShell expects you to write IArgumentCompleter and register them with this syntax:
# [ArgumentCompleter([MyIArgumentCompleter])]
@Jaykul
Jaykul / About OutWithOut.md
Last active August 25, 2020 06:46
You can redirect the other output streams like *>&1 | Out-String.ps1 and these commands will capture them labelled (and optionally, in color), e.g. for | more or | less

PowerShell has a problem with it's extra output streams. The actual content of the Warning, Verbose, Debug, Information, and even Error streams doesn't have the label text like "WARNING: " or "VERBOSE: " that we're used to seeing in the host. That label is actually added by the host (hopefully, in a culture-aware way). However, this means that when you attempt to redirect all of this output, for example by redirecting all output streams to stdout, with *>&1, you don't get labels on them at all, which is confusing, and can make the output difficult to comprehend.

Take for example a function that writes in a loop:

if ($i % 5 -eq 0) {
    Write-Output $i
} else {
    Write-Verbose $i
}
@elupus
elupus / smsl_ir_codes.md
Last active October 12, 2024 19:33
SMSL IR Codes NEC32

SMSL - NEC Extended Format

The SMSL lines of products uses these NEC32 extended format ir codes.

Remote Address Address (rev)
A 3412h 482Ch
B 3512h 48ACh
C 3612h 486Ch
#requires -module Az.Functions
function Write-CmdletError {
param($message, $cmdlet = $PSCmdlet)
$cmdlet.ThrowTerminatingError(
[Management.Automation.ErrorRecord]::new(
$message,
'CmdletError',
'InvalidArgument',
@emilyliu7321
emilyliu7321 / bluesky-comments.tsx
Created November 25, 2024 05:39
Integrate Bluesky replies as your blog's comment section
"use client";
/* eslint-disable @next/next/no-img-element */
import Link from "next/link";
import { useState, useEffect } from 'react';
import {
AppBskyFeedDefs,
AppBskyFeedPost,
type AppBskyFeedGetPostThread,
} from "@atproto/api";