Skip to content

Instantly share code, notes, and snippets.

View theoknock's full-sized avatar

James Alan Bush theoknock

View GitHub Profile
@theoknock
theoknock / ChatGPT 5 Simple Prompt and Response via curl
Created July 29, 2025 20:39
A simple prompt and response via curl using ChatGPT 5
# Save in "payload.json"
{
"model": "chatgpt-5",
"messages": [
{
"role": "system",
"content": "Your instructions:\n When prompted with a specific psalm (e.g., \"Psalm 23\" or \"23\"), you will write a six-paragraph abstract of psalm \\(abstract.psalmNumber) by following the $
},
{
@theoknock
theoknock / Run a Local Chat Completion with System Instructions Using DeepSeek.sh
Last active July 29, 2025 20:21
A prompt to a locally hosted deepseek-coder-v2-lite-instruct-mlx and ChatGPT 5 models via LM Studio’s OpenAI-compatible API.
# Prompt
curl http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-coder-v2-lite-instruct-mlx",
"messages": [
{ "role": "system", "content": "Answer all English questions in Spanish" },
{ "role": "user", "content": "How are you?" }
],
@theoknock
theoknock / Query OpenAI Chat Model and Print Clean Assistant Reply (Python).swift
Created July 29, 2025 19:29
Sends a user prompt to the GPT-4 API with a system role defining assistant behavior. It extracts and prints only the assistant’s response, omitting all metadata and token usage details. Clean and ready for direct terminal output or integration into larger apps.
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4-1106-preview",
messages=[
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "List 3 countries and their capitals."}
],
@theoknock
theoknock / Stream and Assemble OpenAI Chat Response in Python.swift
Last active July 29, 2025 19:14
Sends a chat prompt to the OpenAI API using streaming mode and reconstructs the full response by concatenating incoming chunks.
from openai import OpenAI
client = OpenAI()
stream = client.chat.completions.create(
model="gpt-4-1106-preview", # or "gpt-4.1" if that's valid in your setup
messages=[
{
"role": "user",
"content": "Say 'double bubble bath' ten times fast.",
@theoknock
theoknock / Use a Local LLM to Create a Custom GPT with Custom Instructions and Prompt.sh
Last active July 29, 2025 18:43
Send custom instructions and a prompt to a local LLM to create a fully customized GPT-style response using a single API call.
curl -s -X POST http://192.168.12.135:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-coder-v2-lite-instruct-mlx",
"messages": [
{"role": "system", "content": "You are an expert programmer."},
{"role": "user", "content": "Write a bash script"}
]
}' | jq -r '.choices[0].message.content'
@theoknock
theoknock / response_streamer.swift
Last active July 17, 2025 23:35
Hosts the function that streams the response from a chat model to the client submitting a prompt
//
// ContentView.swift
// ChatGPTCoreModel_playground
//
// Created by Xcode Developer on 7/15/25.
//
import SwiftUI
import FoundationModels
@theoknock
theoknock / Custom SwiftUI Stepper Control.swift
Last active July 16, 2025 17:08
A compact stepper control featuring accelerating increment/decrement buttons and editable text input. Provides immediate response on touch with progressive speed increase during prolonged presses, plus direct keyboard editing with automatic validation. Clean rounded rectangle design with dual data bindings.
import SwiftUI
struct ContentTestView: View {
@State private var psalmValue: Int = 1
@State private var psalmStringValue: String = "1"
@FocusState private var isTextFieldFocused: Bool
var body: some View {
VStack(spacing: 20) {
Text("PSALM")
@theoknock
theoknock / SwiftSyntaxHighlighting.swift
Created June 15, 2025 13:58
Displays Swift code with syntax highlighting
import SwiftUI
import HighlightSwift
struct SwiftSyntaxHighlighting: View {
@State private var code: String = """
struct Example {
var text = "Hello, world!"
func greet() {
print(text)
}
@theoknock
theoknock / Xcode .git
Created November 26, 2024 20:27
ZSH for deleting the existing local repo for an Xcode project, creating a new repo (locally and remotely), and then performing the setup and initial commit
cd ~/Desktop / PlanetaryHoursSwift
sudo ls -l
sudo rm -rf .git
sudo ls -a
git init
git add .
git commit -m "Initial commit"
git remote add origin https: // github.com/theoknock/PlanetaryHoursSwift.git
git push -u origin main
@theoknock
theoknock / ContentView.swift
Last active November 26, 2024 02:39
Sunrise Sunset Calculator
import SwiftUI
import CoreLocation
struct ContentView: View {
@StateObject private var locationManager = LocationManager()
@State private var sunrise: Date = Date().addingTimeInterval(TimeInterval(TimeZone.current.secondsFromGMT(for: Date())))
@State private var sunset: Date = Date().addingTimeInterval(TimeInterval(TimeZone.current.secondsFromGMT(for: Date())))
@State private var nextDaySunrise: Date = Date().addingTimeInterval(TimeInterval(TimeZone.current.secondsFromGMT(for: Date())))
@State private var hours: [PlanetaryHourSegmenter.PlanetaryHourSegment] = []
@State private var longitudes: [LongitudeSegmenter.Segment] = []