Skip to content

Instantly share code, notes, and snippets.

View dfinke's full-sized avatar

Doug Finke dfinke

View GitHub Profile
@dfinke
dfinke / run.ps1
Created September 29, 2026 14:34
A few lines of PowerShell can turn a seed into a shareable little universe: glowing moon, scattered stars, and a new constellation every time you change the seed.
#requires -Version 7.0
# Pick a fixed seed so the cloud validation output stays reproducible.
$seed = 2718
$outputPath = Join-Path $PSScriptRoot 'night-sky.svg'
# Create a shareable SVG file using the generated PowerShell script.
& (Join-Path $PSScriptRoot 'solution.ps1') -Seed $seed -OutputPath $outputPath | Format-List
@dfinke
dfinke / run.ps1
Last active September 29, 2026 14:39
Use Jev’s typed score to sort a tiny idea queue, then let a plain PowerShell rule decide what moves up and what needs a human look.
#requires -Version 7.0
# Add the Jev module before running; mock mode below makes no API request.
Import-Module Jev -ErrorAction Stop
# Prepare fictional feature ideas that cover low, medium, and high urgency.
$items = @(
[pscustomobject]@{ Id = 'IDEA-14'; Description = 'Routine color cleanup for a future demo.' }
[pscustomobject]@{ Id = 'IDEA-28'; Description = 'The login flow has an error blocking a few testers today.' }
[pscustomobject]@{ Id = 'IDEA-37'; Description = 'Critical checkout outage is blocking customers right now.' }
)
[CmdletBinding()]
param(
[ValidateSet('init', 'ingest', 'index', 'query', 'lint', 'help')]
[string]$Operation = 'help',
[string]$Path,
[string]$Question,
[string]$Root = (Split-Path -Parent $PSScriptRoot)
)
Set-StrictMode -Version Latest
# Install-Module PSAISuite -Force
$prompt = @"
read and understand llm-wiki.md
show a plan only for excuting and implementing the steps in llm-wiki.md
"@
$iccParams = @{
model = "openai:gpt-5.6-luna"
effortLevel = "high"
@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