Skip to content

Instantly share code, notes, and snippets.

View kemchenj's full-sized avatar
😵
拖延癌末期,不爱回复

Kem Chen kemchenj

😵
拖延癌末期,不爱回复
View GitHub Profile
@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

@kieber-emmons
kieber-emmons / ParallelRadixSort.metal
Last active February 6, 2024 10:24
This gist is for an article I wrote on Medium (https://medium.com/p/4f4590cfd5d3).
//
// ParallelRadixSort.metal
//
// Created by Matthew Kieber-Emmons on 08/29/22.
// Copyright © 2022 Matthew Kieber-Emmons. All rights reserved.
// This work is for educational purposes only and cannot be used without consent.
//
#include <metal_stdlib>
using namespace metal;
@glessard
glessard / NNNN-UP-and-URP-improvements.md
Last active October 23, 2021 17:03
NNNN Pointer API usability improvements

Pointer API Usability Improvements

  • Proposal: [SE-NNNN full proposal draft][proposal]
  • Authors: Guillaume Lessard, Andrew Trick
  • Review Manager: TBD
  • Status: [Draft pull request][draft-pr]
  • Implementation: pending
  • Bugs: rdar://64342031, SR-11156 (rdar://53272880), rdar://22541346
  • Previous Revision: none
@filip-sakel
filip-sakel / TaskRacing.swift
Last active December 6, 2021 07:55
A Swift implementation concurrency structure safely racing two tasks against each other. This structure is useful for implementing operators like `debounce` for `AsyncSequence`.
//
// TaskRacing.swift
//
// Created by Filip Sakel on 21/6/21.
//
import Dispatch
// MARK: - Utilities
@ethanhuang13
ethanhuang13 / VirtualKeyboard.swift
Last active February 7, 2024 05:58
MacBook Air M1 Zhuyin Keyboard written with SwiftUI ~=300 LOC, < 4hrs
//
// VirtualKeyboard.swift
// MacBook Air M1 Zhuyin Keyboard
// Written with SwiftUI ~=300 LOC, < 4hrs
// Created by Ethan Huang on 2021/1/13.
// Twitter: @ethanhuang13
import SwiftUI
struct VirtualKeyboard: View {
@warrenm
warrenm / CommonProfile.metal
Created November 14, 2019 01:29
SceneKit's CommonProfile Shader v2 (macOS 10.15)
////////////////////////////////////////////////
// CommonProfile Shader v2
#import <metal_stdlib>
using namespace metal;
#ifndef __SCNMetalDefines__
#define __SCNMetalDefines__
@milseman
milseman / offset_bound_proposal.md
Last active October 6, 2019 06:16
Offset-Based Access to Indices, Elements, and Slices

Changes in v2

  • Removed .start and .end, now all OffsetBounds are built from .first and .last.
    • Simplifies usage and learnability. .last + 1 representing the end is mostly only relevant to documentation.
    • Better delineates OffsetBound abstraction and terminology from indices.
  • Added RangeReplaceableCollection convenience overloads, as well as subscript setters.
    • .insert(at:), .remove(at:), etc.,
@tayloraswift
tayloraswift / vectormanifesto.md
Last active June 28, 2020 01:54
the vector manifesto

Vector manifesto

Vectors, understood as 2, 3, or 4-component numerical aggregates, are a fundamental currency type across many domains of programming. This document seeks to lay out a cohesive vision for adding standard vector support to the Swift language, with consideration for relevant long-term goals for the language type system.

Past discussions: 1 2, 3, 4, 5

Past pitches: 1

Vectors and fixed-size arrays

@igorkulman
igorkulman / CompareTools.plist
Last active November 7, 2020 07:06
Visual Studio Code as a merge tool for Git Tower. Place both files to ~/Library/Application Support/com.fournova.Tower2/CompareTools/ and restart Git Tower
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>ApplicationIdentifier</key>
<string>com.microsoft.VSCode</string>
<key>ApplicationName</key>
<string>Visual Studio Code</string>
@JoshuaSullivan
JoshuaSullivan / CapturedImageSampler.swift
Created October 1, 2017 01:38
The source code for an object that helps you sample RGB values from ARFrames.
//
// CapturedImageSampler.swift
// ARKitTest
//
// Created by Joshua Sullivan on 9/22/17.
// Copyright © 2017 Joshua Sullivan. All rights reserved.
//
import UIKit
import ARKit