This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Allow an object to alter its behavior when its internal state changes. | |
The object will appear to change its class. | |
The State pattern puts each branch of the conditional in a separate class. | |
This lets you treat the object's state as an object in its own right | |
that can vary independently from other objects | |
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-ToolResources { | |
param ( | |
[Parameter(Mandatory = $true)] | |
[hashtable]$ToolResources | |
) | |
if ($ToolResources.ContainsKey('code_interpreter')) { | |
if ($ToolResources['code_interpreter'] -isnot [hashtable]) { | |
throw "code_interpreter must be a hashtable" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Concatenate a directory full of files into a single prompt for use with LLMs | |
.DESCRIPTION | |
Takes one or more paths to files or directories and outputs every file, recursively, each one preceded with its filename like this: | |
path/to/file.py | |
---- | |
Contents of file.py goes here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AI-enhanced PowerShell script using prompting for natural language and predictive insights | |
Import-Module PSAI | |
$assistant = New-OAIAssistant | |
# System Health Metrics | |
$metrics = @{ | |
CPU = (Get-Counter '\Processor(_Total)\% Processor Time').CounterSamples.CookedValue | |
Disk = (Get-WmiObject Win32_LogicalDisk | Measure-Object -Property FreeSpace -Average).Average | |
Memory = (Get-Counter '\Memory\% Committed Bytes In Use').CounterSamples.CookedValue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-ATMCashDispenser { | |
param([int]$AmountRequested) | |
class UnitOfWork { | |
hidden [int]$Amt | |
[int]$Request | |
[int]$NumberOf50 | |
[int]$NumberOf20 | |
[int]$NumberOf10 | |
[int]$NumberOf5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.EXAMPLE | |
llm "what is the capital of spain" -provider openai | |
.EXAMPLE | |
llm "what is the capital of spain" -provider anthropic | |
.EXAMPLE | |
llm "what is the capital of spain" -provider gemini | |
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
$Alive = 'O', | |
$Dead = ' ', | |
$SleepInSeconds = .5 | |
) | |
<# | |
Conway's Game of Life | |
The classic cellular automata simulation. Press Ctrl-C to stop. | |
More info at: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load necessary .NET libraries | |
Add-Type -AssemblyName PresentationFramework, WindowsBase | |
# XAML definition | |
[xml]$xaml = @" | |
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="Posh Runner" Height="300" Width="400"> | |
<Grid> | |
<Label Content="PS Cmd:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ChatCompletion { | |
param( | |
$messages, | |
$model = "gpt-3.5-turbo", | |
$functions, | |
$function_call, | |
$temperature = 0.7, | |
$max_tokens, | |
$stop, | |
$top_p = 1.0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$list1 = ConvertFrom-Csv @" | |
list1 | |
Gigi | |
Jo | |
Chin | |
Phil | |
Jojo | |
"@ | |
$list2 = ConvertFrom-Csv @" |
NewerOlder