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 map { | |
param( | |
$func, | |
[Parameter(ValueFromRemainingArguments = $true)] | |
$arrays | |
) | |
$arrays | ForEach-Object { | |
if ($arrays[0].Length -ne $_.Length) { | |
throw "All arrays must be of the same length" |
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
$text1 = Read-Host "Enter text" | |
Set-Clipboard -Value $text1 | |
$text2 = Get-Clipboard | |
$text2 |
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
$data = ConvertFrom-Csv @" | |
Name,UnitsSold | |
John,100 | |
Jane,200 | |
Tom,120 | |
Jane,300 | |
Jim,150 | |
Mary,250 | |
"@ |
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
$prompt = "capital of france?" | |
$model = "gpt-4o-mini" | |
# $model = "o1-preview" | |
$headers = @{ | |
"Content-Type" = "application/json" | |
"Authorization" = "Bearer $($env:GITHUB_TOKEN)" | |
} | |
$body = @{ |
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( | |
$daysOld = 7 | |
) | |
$targetDir = $( | |
'D:\mygit\GPTIdeas\Experiments\Livestream-GPT\' | |
'D:\mygit\PowerShellAIAssistant-ScratchPad' | |
'D:\mygit\PSAI' | |
'D:\mygit\PSAIAgent-Stealth-2\' | |
'D:\temp\Camtasia\scratch\' |
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
$sumData = ConvertFrom-Csv @" | |
ProductName, VendorName, TotalSales | |
Macbook, Apple | |
Desktop, DELL | |
RAM, Lenovo | |
HDD, HCL | |
Laptop, IBM | |
Mouse, Acer | |
"@ |
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
# Git-like Diff Tool in PowerShell | |
function Compare-Files { | |
param ( | |
[string]$OldFilePath, | |
[string]$NewFilePath, | |
[int]$ContextLines = 3 | |
) | |
$oldFile = Get-Content -Path $OldFilePath |
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
# Install-module PSAI | |
# Get OpenAI API key from https://platform.openai.com/account/api-keys | |
# Set $env:OpenAIKey | |
function Compare-PicsUsingAI { | |
param( | |
$pic1, | |
$pic2 | |
) |
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
<# | |
This PowerShell script is powered by my PSAI and PSAIAgent modules. | |
PSAI - Is a port of the OpenAI Python SDK | |
PSAIAgent - Is a PowerShell module that allows you turn an OpenAI LLM into an AI Assistant with memory and tools | |
Register-Tool - Takes PowerShell functions signatures and creates the JSON to be used by OpenAI | |
New-Agent - Creates an AI Agent that can be used to interact with OpenAI | |
Get-AgentResponse - Takes the agent and prompt, calls the OpenAI model, runs the functions if needed and returns the response | |
#> |
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
# Singleton | |
class Product { | |
$Name | |
Product($name) { | |
$this.Name = $name | |
} | |
} |
NewerOlder