Skip to content

Instantly share code, notes, and snippets.

View Timberfang's full-sized avatar

Timberfang

View GitHub Profile
@Timberfang
Timberfang / ListTest.cs
Created October 23, 2024 21:06
Get index from list using Spectre.Console
using Spectre.Console;
namespace ListTest
{
internal class Program
{
static void Main(string[] args)
{
List<string> TestList = [ "Test1", "Test 2", "Test Three", "TestFour"];
int Index = AnsiConsole.Prompt(
@Timberfang
Timberfang / PromptForEmail.cs
Created October 21, 2024 18:02
Get and validate an email address
using System.Net.Mail;
using Spectre.Console;
namespace PromptForEmail
{
internal class Program
{
static void Main(string[] args)
{
PromptForEmail("Enter your email address:");
@Timberfang
Timberfang / Add-ToPath.ps1
Last active June 29, 2024 01:38
Add and remove variables from a user's PATH
function Add-ToPath {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$Path
)
begin {
$UserPath = [Environment]::GetEnvironmentVariable('Path', 'User')
@Timberfang
Timberfang / Move-Save.ps1
Created May 30, 2024 00:15
Move a game's save folder to your "Saved Games" folder, and create a link to the original
[CmdletBinding()]
param (
[Parameter()]
[string]
$Source,
[Parameter()]
[bool]
$SymbolicLink = $false,
@Timberfang
Timberfang / book.css
Created April 22, 2024 00:53
The CSS I use for formatting my fiction writing.
/* CC0 1.0 License (https://creativecommons.org/publicdomain/zero/1.0) */
body {
margin: auto;
padding-right: 1em;
padding-left: 1em;
max-width: 44em;
color: black;
font-family: Verdana, sans-serif;
font-size: 100%;
@Timberfang
Timberfang / Get-RandomString.ps1
Last active April 17, 2024 17:28
Create a random string using PowerShell
# MIT License
#
# Copyright (c) 2024 Timberfang
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@Timberfang
Timberfang / replace.js
Created February 28, 2024 01:33
Obsidian Longform plugin - replace text using regular expressions
// MIT License
//
// Copyright (c) 2024 Timberfang
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@Timberfang
Timberfang / Wait-Disc.ps1
Created August 12, 2023 13:53
Wait for optical media to be inserted (DVD, Blu-Ray, CD, etc.), then end the function.
function Wait-Disc {
[CmdletBinding()]
param (
[Parameter()]
[int]
$DriveIndex = 0
)
# Derive drive letter
$DriveLetter = ($DriveInfo | Select-Object -ExpandProperty Drive)[$DriveIndex]
@Timberfang
Timberfang / Get-PerformanceStats.ps1
Last active May 29, 2023 12:08
Get the the CPU usage, RAM usage, and disk usage of the currently running computer.
<#
.SYNOPSIS
Get the the CPU usage, RAM usage, and disk usage of the currently running computer.
.DESCRIPTION
Retrieve the CPU, RAM, and disk usage of the current system.
Get-PerformanceStats assumes Megabytes as the default units, but it will switch to gigabytes if the megabyte values exceed 1,000.
.NOTES
Currently this script only supports Microsoft Windows.
.EXAMPLE
Get-PerformanceStats.ps1
<#
.SYNOPSIS
List basic information about the computer.
.DESCRIPTION
Lists the computer name, user account, OS, CPU model, GPU model, currently installed RAM, motherboard model, currently running antivirus,
local IP address, and public IP address.
This script currently runs only on Windows due to the lack of the Get-ComputerInfo, Get-PnpDevice, and Get-CimInstance cmdlets on MacOS and Linux.
.EXAMPLE
PS C:\>.\Get-SystemInfo.ps1