Skip to content

Instantly share code, notes, and snippets.

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

Kem Chen kemchenj

😵
拖延癌末期,不爱回复
View GitHub Profile

Requesting Default Values

Many Cocoa and Cocoa Touch calls are boilerplate. They use common argument values with nearly every call. Why not take advantage of Swift's default system instead? We'd like to simplify calls like this:

dismissViewControllerAnimated(flag: true, completion: nil)

to calls like this:

SIL Opaque Values

Introduction

A SIL type is either loadable or address-only. A loadable type is one whose object size and layout can be determined by the compiler and whose values are not "pinned" to a memory address. Types are most commonly address-only because their layout is opaque by abstraction. Generic type parameters are address-only because their concrete type not statically identified. Resilient types are

@ddunbar
ddunbar / xcbuild-debugging-tricks.md
Last active April 13, 2024 15:41
Xcode new build system debugging tricks

New Build System Tricks

Command Line

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
# THIS DOESNT WORK YET: xcbuild openIDEConsole  # … then switch to Xcode ➡️
xcbuild showSpecs
xcbuild build <foo.pif> [—target <target>]
@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
@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>
@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

@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.,
@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__
@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 {
@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