Skip to content

Instantly share code, notes, and snippets.

View JPRuskin's full-sized avatar

James Ruskin JPRuskin

View GitHub Profile
@elupus
elupus / smsl_ir_codes.md
Last active January 6, 2024 17:07
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
@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
}
@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])]
@steviecoaster
steviecoaster / Get-DadJokeSound.ps1
Created August 30, 2019 02:04
Get-DadJokes.....WITH SOUND!!!!
function Get-DadJoke {
[cmdletBinding()]
Param()
process {
$header = @{
Accept = "application/json"
}
$joke = Invoke-RestMethod -Uri "https://icanhazdadjoke.com/" -Method Get -Headers $header
@darrenjrobinson
darrenjrobinson / Get-Unifi-Details.ps1
Last active June 30, 2023 08:28
PowerShell Script to get Ubiquiti Unifi Sites, Devices and Active Clients. Associated blogpost https://blog.darrenjrobinson.com/accessing-your-ubiquiti-unifi-network-configuration-with-powershell/
# Unifi Controller Login Base URI
$uController = 'yourControllerIP' # e.g 'https://192.168.1.2:8443'
# Identifier of the site in UniFi. Set to default for the default site
$uSiteID = "default"
$uUsername = 'adminuser' # yourAdmin UserID
$uPassword = 'yourPassword' # yourAdmin User Password
$uAuthBody = @{"username" = $uUsername; "password" = $uPassword }
$uHeaders = @{"Content-Type" = "application/json" }
@48klocs
48klocs / voltron.txt
Last active October 27, 2021 20:36
48klocs gigant0r #dimwishlists dump file
This file has been truncated, but you can view the full file.
// Mercules' Erentil FR4 breakdown
// https://www.reddit.com/r/DestinyTheGame/comments/cbxao7/massive_breakdown_of_erentil_fr4_including_stats/
// Erentil FR4
dimwishlist:item=3027844941&perks=194952923,3868766766,280464955,1600092898
dimwishlist:item=3027844941&perks=194952922,3868766766,280464955,1600092898
dimwishlist:item=3027844941&perks=194952923,2969185026,280464955,1600092898
dimwishlist:item=3027844941&perks=194952922,2969185026,280464955,1600092898
dimwishlist:item=3027844941&perks=194952923,3868766766,1645158859,1600092898
dimwishlist:item=3027844941&perks=194952922,3868766766,1645158859,1600092898
@Jaykul
Jaykul / Counting Lines.md
Last active December 9, 2020 17:17
PowerShell Line Counting

Lines Of Code is a useful metric

How would you count the "Lines of Code" in HowManyLines.ps1 below? Go ahead and look, I'll wait here. 😉 Do you count lines that have nothing but braces on them? Do you count opening and closing braces? Do you count the "else" line?

Apparently, PowerShell AST doesn't support Allman style 😁

If we use the Language Parser to count lines, we can take every statement's begin and end line and then count how many unique lines have code on them. But suprisingly, the else keyword doesn't show up as a token, because it's just part of the IfStatementAst ...

$Ast = [System.Management.Automation.Language.Parser]::ParseFile((Convert-Path "HowManyLines.ps1"), [ref]$Null, [ref]$Null)
@fatherjack
fatherjack / PowerShell Prompt.ps1
Last active August 23, 2019 21:32
provides some useful information to your PowerShell prompt
function Prompt {
<#
.Synopsis
Your custom PowerShell prompt
# borrowing heavily from https://dbatools.io/prompt but formatting the execution time without using the DbaTimeSpanPretty C# type
.Description
Custom prompt that includes the following features:
@choco-bot
choco-bot / Update-AUPackages.md
Last active May 11, 2024 00:18
Update-AUPackages Report #powershell #chocolatey
@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active May 2, 2024 01:27
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r