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
// 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 |
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
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. |
Just chat.deepseek.com with prompts adapted from this gist.
- 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)
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
// 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 { |
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
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. |
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
AACustomByteStreamOpen | |
AAEntryACLBlob | |
AAEntryXATBlob | |
AAFieldKeySetGetKeyCount | |
AAHeaderGetKeyIndex | |
ABMultiValueGetCount | |
ABPersonViewController | |
ADCommonDefinitions | |
ADErrorAdUnloaded | |
ADErrorLoadingThrottled |
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
-- A concrete use case for the type which is to '(->)' as 'Day' is to '(,)'. | |
-- I call it "FunDay", but I don't know what its proper name is. I've been | |
-- trying to find a use for 'FunDay', and I think I've found a pretty neat one. | |
{-# LANGUAGE FlexibleContexts, FlexibleInstances, PolyKinds, RankNTypes, TypeSynonymInstances #-} | |
module Main where | |
import Test.DocTest | |
import Control.Monad.Except | |
import Control.Monad.Reader |
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
import Combine | |
import Foundation | |
import os | |
@MainActor public final class PollingDataModel<DataModels: Sendable> { | |
private let logger = Logger(subsystem: "Polling", category: "PollingDataModel") | |
private var pollingTask: Task<Void, Never>? | |
private var currentlyPolling = false |
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
import Foundation | |
extension Task { | |
static func sleep(until target: Date) async throws where Success == Never, Failure == Never { | |
let duration = target.timeIntervalSinceNow | |
try await Self.sleep(for: .seconds(duration)) | |
} | |
} | |
print("Waiting for 1s...") |
NewerOlder