Skip to content

Instantly share code, notes, and snippets.

View quonic's full-sized avatar

Spyingwind quonic

  • Dallas
View GitHub Profile
@quonic
quonic / Get-TMI.ps1
Last active May 24, 2024 03:12
Randy Marsh's TMI formula in PowerShell
function Get-TMI {
<#
.SYNOPSIS
Calculates the TMI of a given object.
.DESCRIPTION
Calculates the TMI of a given object.
.PARAMETER Length
The length of the object
.PARAMETER Diameter
The diameter of the object
@quonic
quonic / Spells.txt
Created May 18, 2024 23:58
Arcane Assembly spells
"Magic Missile":
3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D227574662D3136223F3E0D0A3C5370656C6C54656D706C61746520786D6C6E733A7873643D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D612220786D6C6E733A7873693D22687474703A2F2F7777772E77332E6F72672F323030312F584D4C536368656D612D696E7374616E6365223E0D0A20203C546F6B656E733E0D0A202020203C546F6B656E3E0D0A2020202020203C547970653E496E737472756374696F6E3C2F547970653E0D0A2020202020203C4576616C7561746564547970653E4E756D6265723C2F4576616C7561746564547970653E0D0A2020202020203C4B65793E5265706561743C2F4B65793E0D0A2020202020203C44617461202F3E0D0A2020202020203C4368696C6472656E3E0D0A20202020202020203C546F6B656E3E0D0A202020202020202020203C547970653E436F6E7374616E743C2F547970653E0D0A202020202020202020203C4576616C7561746564547970653E4E756D6265723C2F4576616C7561746564547970653E0D0A202020202020202020203C4B6579202F3E0D0A202020202020202020203C446174613E333C2F446174613E0D0A202020202020202020203C4368696C6472656E202F3E0D0A20202020202020203C2F546F6B656E3E0D0
@quonic
quonic / CheckMiniAudioResult.odin
Last active April 6, 2024 02:06
Helper function to check if the result from miniaudio functions where successful or not. Logs to raylib's TraceLog.
package main
// License: Do what ever you want with this.
// Example use case
// audioengineConfig = miniaudio.engine_config_init()
// result: miniaudio.result = miniaudio.engine_init(&audioengineConfig, &audioEngine)
// assert(checkAudioResult(result), "Failed to initialize audio engine")
import "vendor:miniaudio"
@quonic
quonic / checkAudioResult.odin
Created April 2, 2024 15:20
A helper function to trace errors when calling miniaudio functions in odin
package main
import "vendor:miniaudio"
import "vendor:raylib"
// Example use case:
// result: miniaudio.result = miniaudio.engine_init(&audioengineConfig, &audioEngine)
// assert(checkAudioResult(result), "Failed to initialize audio engine")
checkAudioResult :: proc(result: miniaudio.result) -> bool {
@quonic
quonic / Get-PackageUpdates.sh
Last active March 11, 2024 23:37
Get a list linux of packages ( apt, dnf, yum ) and containers ( flatpak, snap ) that have packages available to be updated and save them to custom fields. Mainly used with NinjaRMM.
#!/usr/bin/env bash
# Licence: MIT or use how you like
# Description:
# This script is used to get a list of system packages that can be updated and save them to a Custom Field.
# It also gets a list of snaps and flatpaks that can be updated and saves them to a Custom Field.
# Create the following Script Variables:
#
# packagesCustomField as a text field
@quonic
quonic / Get-ProgramBit.ps1
Last active January 18, 2024 22:27
Get the bittness of an exe or dll.
function Get-ProgramBit {
[CmdletBinding()]
param ([string]$Path)
process {
if (-not $(Test-Path -Path $Path -ErrorAction SilentlyContinue)) {
Write-Error "Invalid Path"
return
}
$re32 = [regex]::new('PE\W\WL')
Get-Content -Path $Path -ReadCount 1 | ForEach-Object {
@quonic
quonic / Preseed Debian 12
Created November 22, 2023 20:03
Preseed Provisioning Template in Forman for Debian 12. This fixes one deployment issue where the installer gets stuck trying to install python.
<%#
kind: provision
name: Preseed default
model: ProvisioningTemplate
oses:
- Debian
- Ubuntu
test_on:
- debian4dhcp
- ubuntu4dhcp
@quonic
quonic / GetNewClosure.ps1
Created August 28, 2023 16:05
Understanding GetNewClosure. Assuming you have Pester installed, but not required. Remove Should parts.
# No GetNewClosure - print $a as what ever it is before printing
& {
$a = 10
$myScript = {
$a
}
& $myScript
$a = 20
& $myScript
@quonic
quonic / Get-Parameters.ps1
Created July 20, 2023 04:22
Get a PowerShell script's parameters and output certain aspects of each parameters. Utilizes the AST to get all its data.
function Get-Parameters {
param(
# Path to a .ps1 script
[string]$Path
)
begin {}
process {
$ScriptPath = Get-Item -Path $Path
$ScriptCommand = Get-Command $ScriptPath
$ScriptBlock = $ScriptCommand.ScriptBlock
@quonic
quonic / IsDiskSpaceLow.sh
Last active July 19, 2023 21:26
MacOS Condition on Low Disk Space. Pass a number such as 90 as an argument, and if the exit code is 1, then a drive is over 90%.
#!/usr/bin/env bash
# MacOS Condition on Low Disk Space. Pass a number such as 90 as an argument, and if the exit code is 1, then a drive is over 90%.
# This exludes any mounted dmg's, USB drives, or cdrom/dvd.
Percentage=$1
IsOver=$(df -H | grep -vE '^Filesystem|tmpfs|cdrom|loop|devfs|map| \/Volumes' | awk '{ print substr($5,1,length($5)-1) }' | awk -v p=$Percentage -F: '{if($1>p){print 1}else{print 0}}' | grep 1 | tail -n1)
exit "$IsOver"