This file contains hidden or 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 Save-JsonToExcel { | |
| <# | |
| .SYNOPSIS | |
| Saves a JSON string to an Excel file. | |
| .PARAMETER Json | |
| The JSON string to save. | |
| .PARAMETER Path | |
| The path to save the Excel file to. | |
| #> | |
| param( |
This file contains hidden or 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
| $config = @{ | |
| Preferences = @{ | |
| defaultAgent = "StockAgent" | |
| } | |
| WebSearchAgent = @{ | |
| Name = "WebSearch" | |
| LLM = New-OpenAIChat 'gpt-4o-mini' | |
| Instructions = "Today is $(Get-Date)" |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | |
| ) |