Skip to content

Instantly share code, notes, and snippets.

@swillits
swillits / Keycodes.swift
Last active July 19, 2024 05:51
Swift Keyboard Keycodes
struct Keycode {
// Layout-independent Keys
// eg.These key codes are always the same key on all layouts.
static let returnKey : UInt16 = 0x24
static let enter : UInt16 = 0x4C
static let tab : UInt16 = 0x30
static let space : UInt16 = 0x31
static let delete : UInt16 = 0x33
static let escape : UInt16 = 0x35
@karwa
karwa / ConcurrentCollection.swift
Last active July 16, 2020 11:00
Concurrent collection wrapper
import Dispatch
// Import C11 for atomic_flag
// FIXME: SWIFT(canImport)
//#if canImport(Glibc)
// import Glibc.stdatomic
//#elseif canImport(Darwin)
import Darwin.C.stdatomic
//#endif
@FWEugene
FWEugene / SwiftConcurrency.md
Created January 10, 2019 17:37
All about concurrency

Threads

Foundation offers a Thread class, internally based on pthread, that can be used to create new threads and execute closures.

// Detaches a new thread and uses the specified selector as the thread entry point.
Thread.detachNewThreadSelector(selector: Selector>, toTarget: Any, with: Any)

// Subclass
class MyThread: Thread {
@dabrahams
dabrahams / ConcurrentMap.swift
Last active April 3, 2024 04:59
Concurrent Map Implementations, Benchmarked
// See commentary below this gist.
import Foundation
import QuartzCore
// Implementation from https://talk.objc.io/episodes/S01E90-concurrent-map
public final class ThreadSafe<A> {
var _value: A
let queue = DispatchQueue(label: "ThreadSafe")
init(_ value: A) { self._value = value }
@eonist
eonist / My_favorite_ai_coding_prompts.md
Last active July 29, 2024 21:22
My_favorite_ai_coding_prompts.md

The art of prompt coding 🦾

Visitors GitHub Gist stars

Apps used: Cursor.so / github copilot chat / Amazon Q / codeium

img

⚠️️ Before you disregard the idea of prompt coding ⚠️️ Don't! Because everyone will be prompt-coding soon enough.