Skip to content

Instantly share code, notes, and snippets.

View CrystDragon's full-sized avatar

Lincoln Wu CrystDragon

View GitHub Profile
@nevan
nevan / gist:3e1174f27e753db4731e
Last active January 9, 2022 19:04
WWDC 2015 Session Videos
https://developer.apple.com/videos/wwdc/2015/?id=101 101 Keynote
https://developer.apple.com/videos/wwdc/2015/?id=102 102 Platforms State of the Union
https://developer.apple.com/videos/wwdc/2015/?id=103 103 Apple Design Awards
https://developer.apple.com/videos/wwdc/2015/?id=104 104 What's New in Xcode
https://developer.apple.com/videos/wwdc/2015/?id=105 105 Introducing WatchKit for watchOS 2
https://developer.apple.com/videos/wwdc/2015/?id=106 106 What's New in Swift
https://developer.apple.com/videos/wwdc/2015/?id=107 107 What's New in Cocoa Touch
https://developer.apple.com/videos/wwdc/2015/?id=108 108 Building Watch Apps
https://developer.apple.com/videos/wwdc/2015/?id=112 112 Think Audacious
https://developer.apple.com/videos/wwdc/2015/?id=201 201 iOS Accessibility
@ole
ole / UIAlertController+TextField.swift
Last active September 13, 2022 14:20
A UIAlertController with a text field and the ability to perform validation on the text the user has entered while the alert is on screen. The OK button is only enabled when the entered text passes validation. More info: https://oleb.net/2018/uialertcontroller-textfield/
import UIKit
/// A validation rule for text input.
public enum TextValidationRule {
/// Any input is valid, including an empty string.
case noRestriction
/// The input must not be empty.
case nonEmpty
/// The enitre input must match a regular expression. A matching substring is not enough.
case regularExpression(NSRegularExpression)
@DougGregor
DougGregor / macros.md
Last active October 24, 2023 16:42
A possible vision for macros in Swift

A Possible Vision for Macros in Swift

As Swift evolves, it gains new language features and capabilities. There are different categories of features: some fill in gaps, taking existing syntax that is not permitted and giving it a semantics that fit well with the existing language, with features like conditional conformance or allowing existential values for protocols with Self or associated type requirements. Others introduce new capabilities or paradigms to the language, such as the addition of concurrency or comprehensive reflection.

There is another large category of language features that provide syntactic sugar to eliminate common boilerplate, taking something that can be written out in long-form and making it more concise. Such features don't technically add any expressive power to the language, because you can always write the long-form version, but their effect can be transformational if it enables use cases that would otherwise have been unwieldy. The synthesis of Codable conformances, for ex

@brennanMKE
brennanMKE / README.md
Last active October 25, 2023 10:52
LLDB customization with additional commands

LLDB Custom Commands

[LLDB] can be customized with ~/.lldbinit to run commands and to load more commands from shell and python scripts. One option is [Chisel] which provides several commands which can be used to debug an software running in Xcode.

It is critical that LLDB can process the commands in ~/.lldbinit successfully as a failure can cause the debugger to fail or run in an undefined way. The configuration listed in this Gist prints a message at the start and end so that when the debugger is run it is clear if any errors are shown in the Xcode console they are related to LLDB.

Motivation

Swift’s type system supports a number of different ways of taking a function or type and abstracting it. Usually, this is done by adding a generic parameter and an associated set of constraints. Similarly, a function that takes a particular type of argument can be abstracted to any number of those arguments by making it variadic with triple-dot (...) syntax. Today, both of these features are permitted separately: you can define a generic function that takes a variable number of arguments, such as

func debugPrint<T>(_ items: T...) 
  where T: CustomDebugStringConvertible
{   
  for (item: T) in items {
    stdout.write(item.debugDescription)
@objc func _needsDoubleUpdateConstraintsPass() -> Bool {
return true
}
override var intrinsicContentSize: CGSize {
  return attributedText?.size(forWidth: (engineBounds ?? bounds).width) ?? .zero
}
var engineBounds: CGRect? {
let objcSelector = "_nsis_compatibleBoundsInEngine:")
@DougGregor
DougGregor / SwiftConcurrencyDependencies.svg
Created December 2, 2020 00:39
Swift Concurrency Proposal Dependencies
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DougGregor
DougGregor / parallel_map.swift
Created December 24, 2020 01:10
Swift async/await implementation of a parallel map
extension Collection {
func parallelMap<T>(
parallelism requestedParallelism: Int? = nil,
_ transform: @escaping (Element) async throws -> T
) async throws -> [T] {
let defaultParallelism = 2
let parallelism = requestedParallelism ?? defaultParallelism
let n = self.count
if n == 0 {
@IsaacXen
IsaacXen / README.md
Last active April 16, 2024 15:54
(Almost) Every WWDC videos download links for aria2c.