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
class CPU { | |
freeze() { "$this freezing" | Out-Host } | |
jump($position) { "$this jump to $position" | Out-Host } | |
execute() { "$this execute" | Out-Host } | |
} | |
class Memory { | |
load($position, $data) { | |
"$this load $position $data" | Out-Host |
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
{ | |
"store": { | |
"book": [ | |
{ | |
"category": "reference", | |
"author": "Nigel Rees", | |
"title": "Sayings of the Century", | |
"price": 8.95 | |
}, { | |
"category": "fiction", |
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
class ReportTemplate { | |
hidden $data | |
GenerateReport() { | |
$this.RetrieveFinancialData() | |
$this.FormatReport() | |
$this.SendToStakeholders() | |
} | |
RetrieveFinancialData() { |
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
class Command { | |
execute() { | |
"[$(get-date)] Logging execute of command [$this]" | Out-Host # Logs the execution of the command | |
} | |
} | |
class Loony : Command { | |
execute() { | |
([Command]$this).execute() # Calls the execute method of the base class (Command) | |
"You're a loony." | Out-Host # Outputs "You're a loony." |
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
class Logger { | |
log($message) { # Define a method called "log" that takes a message as input | |
$message | Out-Host # Output the message to the console | |
} | |
} | |
class TimeStampingLogger : Logger { # Define a class called "TimeStampingLogger" that inherits from "Logger" | |
$logger # Declare a variable called "logger" | |
TimeStampingLogger($logger) { # Define a constructor that takes a "logger" as input |
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
class Subject { | |
hidden [System.Collections.ArrayList]$observers | |
Subject() { | |
$this.observers = New-Object System.Collections.ArrayList | |
} | |
Attach([Observer]$o) { $this.observers.Add($o) } |
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
. .\Employee.ps1 | |
$CEO = [Employee]::new("John","CEO", 30000) | |
$HeadSales = [Employee]::new("Robert","Head Sales", 20000) | |
$HeadMarketing = [Employee]::new("Michel","Head Marketing", 20000) | |
$clerk1 = [Employee]::new("Laura","Marketing", 10000) | |
$clerk2 = [Employee]::new("Bob","Marketing", 10000) | |
$salesExecutive1 = [Employee]::new("Richard","Sales", 10000) | |
$salesExecutive2 = [Employee]::new("Rob","Sales", 10000) |
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
<# | |
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 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 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 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
<# | |
.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 |