Skip to content

Instantly share code, notes, and snippets.

View dfinke's full-sized avatar

Doug Finke dfinke

View GitHub Profile
@dfinke
dfinke / README.md
Last active May 11, 2026 15:47
PowerShell example for chatting with the xAI Voice Agent API and hearing the reply as audio.

PowerShell xAI Voice Chat Demo

Tiny PowerShell example for chatting with the xAI Voice Agent API and hearing the reply as audio.

The script:

  • opens one realtime WebSocket
  • sends your typed messages as chat turns
  • receives the assistant transcript and audio chunks
  • writes the reply to a temp WAV file
@dfinke
dfinke / ask-projects.ps1
Last active April 24, 2026 23:32
Ask your project folders questions in plain English. This PowerShell script scans, reads .note files or README.md, and helps you recall
# ask-projects.ps1
# Scans top-level folders and lets you ask natural language questions about your projects.
# Requires PSAISuite module (Invoke-ChatCompletion).
#
# USAGE:
# .\ask-projects.ps1 -Root "C:\Dev" -Ask "what did I work on last week?"
# .\ask-projects.ps1 -Root "C:\Dev" -Ask "anything related to python scraping?"
# .\ask-projects.ps1 -Root "C:\Dev" -Ask "what did I create this month?" -Model "anthropic:claude-sonnet-4-20250514"
#
@dfinke
dfinke / Excel-VBA-GPT.vb
Created March 26, 2026 19:42
VBA function that calls OpenAI API directly from Excel cells. Pass any prompt, get AI responses inline.
Option Explicit
Function AskOpenAI(prompt As String, Optional model As String = "gpt-4o-mini") As String
On Error GoTo ErrorHandler
' Read API key from environment
Dim apiKey As String
apiKey = Environ("OPENAI_API_KEY")
@dfinke
dfinke / doLoop.ps1
Last active March 25, 2026 13:56
A PowerShell function mimicking Claude Code's /loop, repeatedly executing AI prompts at natural-language time intervals.
#Requires -Modules PSAISuite
function loop {
<#
.SYNOPSIS
Executes a prompt via Invoke-ChatCompletion multiple times with a specified time interval.
.DESCRIPTION
The loop function takes a natural language string containing a prompt and an optional time interval.
It runs the specified prompt using Invoke-ChatCompletion up to 5 times.
@dfinke
dfinke / space-invaders.ps1
Last active March 10, 2026 16:31
Using AI - built a standalone PowerShell arcade game at space-invaders.ps1
param(
[int]$DemoFrames = 0,
[int]$FrameDelayMs = 55,
[switch]$NoColor,
[switch]$Sound
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
@dfinke
dfinke / PSClaude-Transcript.md
Last active January 29, 2026 21:43
Invoke-PSClaudeCode -Prompt "create a fn greet, save to ps1, create tests, make sure they pass. create a privete repo on owner dfinke, push the code, show the link to the repo"
Invoke-PSClaudeCode -dangerouslySkipPermissions 'create a fn greet, save to ps1, create tests, make sure they pass. create a privete repo on owner dfinke, push the code, show the link to the repo'
[16:36:43] 🤖 Processing request...
[16:36:43] 🤖 Consulting Claude...
[16:36:52] 🤖 Response received, analyzing...

[16:36:53] 🔧 Write-File: {"path":"Greet.ps1","content":"function Greet {\n    <#\n    .SYNOPSIS\n    Greets a person with a friendly message.\n    \n    .DESCRIPTION\n    Takes a name as input and returns a greeting message.\n    \n    .PARAMETER Name\n    The name of the person to greet.\n    \n    .EXAMPLE\n    Greet -Name \"John\"\n    Returns \"Hello, John! Welcome!\"\n    #>\n    [CmdletBinding()]\n    param(\n        [Parameter(Mandatory=$true)]\n        [string]$Name\n    )\n    \n    return \"Hello, $Name! Welcome!\"\n}\n"}
[16:36:53]    → Successfully wrote to Greet.ps1...
[16:36:53] 🔧 Write-File: {"path":"Greet.Tests.ps1","content":"BeforeAll {\n    . $PSScriptRoot/Greet.ps1\n}\n\nDescribe
@dfinke
dfinke / ParseISPF.ps1
Created January 26, 2026 13:06
Reads and parses ISPF panel syntax from ISPFPanel.txt
# ParseISPF.ps1 - Reads and parses ISPF panel syntax from ISPFPanel.txt
# Then generates a PowerShell script that creates a WinForm based on the layout
$panelFile = "ISPFPanel.txt"
$content = Get-Content $panelFile -Raw
# Split into sections
$sections = @{}
$currentSection = $null
$lines = $content -split "`n"
@dfinke
dfinke / AssignCopilotToIssue.ps1
Created January 18, 2026 02:19
Triggering GitHub Coding Agent from the Windows Terminal
param(
[Parameter(Mandatory = $true)]
[string]$Title,
[Parameter(Mandatory = $true)]
[string]$Description
)
Write-Host "Starting issue creation and assignment process..." -ForegroundColor Green

Cyclomatic Complexity Analysis

Cyclomatic Complexity is a software metric used to indicate the complexity of a program. The metric measures the number of linearly independent paths through a program's source code. A higher value means the code is more complex and potentially harder to test and maintain. Values above 10 are generally considered a warning sign.


Analysis of .\Samples\ComplexSample.ps1

  • Total Complexity: 11 (Threshold is typically 10)
  • File: .\Samples\ComplexSample.ps1
@dfinke
dfinke / Get-TimeLineMarkers.ps1
Created December 17, 2025 18:25
PowerShell scrript to extract Timeline Markers from Camtasia project - the tscproj JSON
# 1. Load the project file
$project = Get-Content "YourProject.tscproj" -Raw | ConvertFrom-Json
# 2. Set the frame rate (editRate) from the project settings
$fps = $project.editRate
# 3. Extract markers and convert frame locations to timestamps
$project.timeline.parameters.toc.keyframes | Select-Object `
@{Name="Timestamp"; Expression={"{0:hh\:mm\:ss}" -f [timespan]::fromseconds($_.time / $fps)}}, `
@{Name="MarkerText"; Expression={$_.value}} |