Skip to content

Instantly share code, notes, and snippets.

View phatblat's full-sized avatar

Ben Chatelain phatblat

View GitHub Profile
@ddddxxx
ddddxxx / KeyPath+fieldName.swift
Last active April 28, 2023 10:24
KeyPath Introspection
// This file is based largely on the Runtime package - https://github.com/wickwirew/Runtime
extension KeyPath {
var fieldName: String? {
guard let offset = MemoryLayout<Root>.offset(of: self) else {
return nil
}
let typePtr = unsafeBitCast(Root.self, to: UnsafeMutableRawPointer.self)
let metadata = typePtr.assumingMemoryBound(to: StructMetadata.self)
//
// ContentView.swift
//
// Created by Chris Eidhof on 20.04.20.
// Copyright © 2020 objc.io. All rights reserved.
//
import SwiftUI
import UIKit
//
// Deduplicated.swift
// CountriesSwiftUI
//
// Created by Alexey Naumov on 17.12.2019.
// Copyright © 2019 Alexey Naumov. All rights reserved.
//
import Foundation
import Combine
source /home/ali/.sdkman/bin/sdkman-init.fis
#!/usr/bin/env fish
#
# Copyright 2017 Marco Vermeulen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@skabber
skabber / exportOptions.plist
Last active April 14, 2024 20:47
Export Options Plist Example
<?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">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>XXXXXXXXXX</string>
<key>uploadBitcode</key>
<true/>
@lattner
lattner / async_swift_proposal.md
Last active February 23, 2024 11:41 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

build.doLast() {
// Augmented from https://github.com/bascan/kotlin-js-example/blob/master/build.gradle
def jsFileFilter = { fileTreeElement ->
def path = fileTreeElement.path
path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
}
configurations.compile.each { File file ->
copy {

Aligning images

This is a guide for aligning images.

See the full Advanced Markdown doc for more tips and tricks

left alignment