Skip to content

Instantly share code, notes, and snippets.

View tkersey's full-sized avatar
:octocat:

Tim Kersey tkersey

:octocat:
View GitHub Profile
@tkersey
tkersey / cron-agent-effection.ts
Last active May 31, 2025 22:59
Agents with Algebraic Effects
import {
Operation,
Resource,
Context,
action,
resource,
spawn,
sleep,
main,
suspend as effectionSuspend,

MCP's client-server architecture: Technical design for AI integration

The Model Context Protocol (MCP) represents a fundamental shift in how AI applications connect to external systems. Introduced by Anthropic in November 2024, MCP chose a client-server architecture over alternatives like peer-to-peer or monolithic designs to solve the "M×N problem" - where M AI applications need to integrate with N data sources, traditionally requiring M×N custom integrations. The client-server model transforms this into an M+N solution through standardized, secure, and scalable connections.

This architectural decision reflects deep technical considerations: security isolation between components, modular extensibility for diverse integrations, and protocol standardization that enables any MCP client to work with any MCP server regardless of implementation language or platform. The design philosophy prioritizes developer simplicity while maintaining enterprise-grade security boundaries - what Anthropic calls "

// Deep Dive: Prompts as Delimited Continuations in TypeScript
// =============================================================================
// 1. PROMPTS AS INITIAL CONTINUATIONS
// =============================================================================
/**
* Prompts as Initial Continuations treats the prompt itself as the starting
* continuation that establishes the computational context. The prompt becomes
* a first-class continuation that can be captured, modified, and resumed.
@tkersey
tkersey / a2a.swift
Created April 30, 2025 17:39
Claude implementation of A2A in Swift
// A2A Protocol Implementation Example in Swift using Hummingbird
//
// This is a Swift implementation of Google's Agent-to-Agent (A2A) protocol using Hummingbird 2.
// The example demonstrates two components:
// 1. An A2A Server: An agent that exposes an HTTP endpoint implementing A2A protocol methods
// 2. An A2A Client: An application that consumes A2A services
import Foundation
import Hummingbird
import NIOCore
@tkersey
tkersey / streamlit_app.py
Created January 31, 2025 17:23 — forked from tvst/streamlit_app.py
Simple way to run heavy computations without slowing down other Streamlit users
import streamlit as st
import concurrent.futures # We'll do computations in separate processes!
import mymodule # This is where you'll do the computation
# Your st calls must go inside this IF block.
if __name__ == '__main__':
st.write("Starting a long computation on another process")
# Pick max number of concurrent processes. Depends on how heavy your computation is, and how
# powerful your machine is.
@tkersey
tkersey / FAQ.md
Created January 28, 2025 14:06 — forked from ngxson/FAQ.md
convert ARM NEON to WASM SIMD prompt

What is your setup?

Just chat.deepseek.com with prompts adapted from this gist.

Does it work in one-shot or I have to prompt it multiple times?

  • For the qX_0 variants, they are actually quite straight-forward so deepseek can come up with a correct result in 1 shot.
  • For the qX_K it's more complicated, I would say most of the time I need to re-prompt it 4 to 8 more times.
  • The most difficult was q6_K, the code never works until I ask it to only optimize one specific part, while leaving the rest intact (so it does not mess up everything)
@tkersey
tkersey / Mutex.swift
Created November 14, 2024 18:38 — forked from swhitty/Mutex.swift
Backports the Swift 6 type Mutex<Value> to all Apple platforms that support OSAllocatedUnfairLock
// Backports the Swift 6 type Mutex<Value> to Swift 5 and all Darwin platforms via OSAllocatedUnfairLock.
// Lightweight version of https://github.com/swhitty/swift-mutex
// Feel free to use any part of this gist.
// Note: ~Copyable are not supported
#if compiler(>=6)
@available(iOS, introduced: 16.0, deprecated: 18.0, message: "use Mutex from Synchronization module included with Swift 6")
@available(macOS, introduced: 13.0, deprecated: 15.0, message: "use Mutex from Synchronization module included with Swift 6")
public struct Mutex<Value>: @unchecked Sendable {
@tkersey
tkersey / CancellingContinuation.swift
Created October 26, 2024 16:44 — forked from NikolaiRuhe/CancellingContinuation.swift
A continuation that resumes automatically when the suspended task is cancelled.
import os.lock
/// `CancellingContinuation` is built on top of `CheckedContinuation` and
/// provides some additional features. It can be used as a drop-in replacement,
/// providing a similar API.
///
/// ## Automatic cancellation
/// When the suspended task is cancelled the continuation is automatically
/// resumed with a `CancellationError`. After that, normally resuming the
/// continuation from client is silently ignored.
@tkersey
tkersey / TMNT Symbols
Created September 11, 2024 03:19 — forked from harlanhaskins/TMNT Symbols
All the iOS 14/macOS 11/tvOS 14/watchOS 7 symbols that are singable to the TMNT theme song
AACustomByteStreamOpen
AAEntryACLBlob
AAEntryXATBlob
AAFieldKeySetGetKeyCount
AAHeaderGetKeyIndex
ABMultiValueGetCount
ABPersonViewController
ADCommonDefinitions
ADErrorAdUnloaded
ADErrorLoadingThrottled