Skip to content

Instantly share code, notes, and snippets.

Mattt mattt

Block or report user

Report or block mattt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattt
mattt / UIViewControllerPreview.swift
Last active Nov 14, 2019
Generic structures to host previews of UIView and UIViewController subclasses.
View UIViewControllerPreview.swift
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@keith
keith / simctl-commands.txt
Last active Nov 11, 2019
All the subcommands of `xcrun simctl` (including ones that aren't listed in `simctl help`) LC_SOURCE_VERSION 681.5.4
View simctl-commands.txt
delete
pbpaste
terminate
keyboard_set_language
erase
pbsync
diagnose
status_bar
openurl
get_app_container
@mxcl
mxcl / detweet.swift
Last active Jul 5, 2019
Delete all tweets and favorites older than two months ago. Instructions in comment.
View detweet.swift
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import Swifter // @mattdonnelly == b27a89
let swifter = Swifter(
consumerKey: "FILL",
consumerSecret: "ME",
oauthToken: "IN",
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html"
@mattt
mattt / bridge.swift
Last active Sep 2, 2019
Example usage of @mxcl's swift-sh
View bridge.swift
#!/usr/bin/swift sh
import DeckOfPlayingCards // @NSHipster ~> 4.0.0
import PlayingCard
import Cycle // @NSHipster == bb11e28
class Player {
var name: String
var hand: [PlayingCard] = []
@mluisbrown
mluisbrown / FixBTSound.applescript
Last active Jul 7, 2019
AppleScript to set macOS audio input device to "Internal Microphone"
View FixBTSound.applescript
-- Sets your audio input source to "Internal Microphone"
-- Frequently needed if you use bluetooth headpohones and
-- run the Xcode iOS simulator, which will often set your
-- headphones to be the input device, resulting in a drastic
-- decrease in sound quality, and making it mono
tell application "System Preferences" to activate
tell application "System Preferences"
reveal anchor "input" of pane id "com.apple.preference.sound"
end tell
View main.swift
let xs = [1, 2, 3, 4, 5]
for (element, index) in zip(xs, xs.indices) {
if index == xs.startIndex {
print("START")
}
print(element)
if index == xs.index(before: xs.endIndex) {
@rxwei
rxwei / ad-manifesto.md
Last active Nov 4, 2019
First-Class Automatic Differentiation in Swift: A Manifesto
@SlaunchaMan
SlaunchaMan / runGYB.bash
Last active Jul 17, 2018
Bash script to run Gyb on the given input files or file lists.
View runGYB.bash
GYB_PATH="${SRCROOT}/Vendor/gyb/gyb"
function gyb {
file=$1
if [ ${file: -4} == ".gyb" ]; then
"${GYB_PATH}" --line-directive '' -o "${file%.gyb}" "$file";
fi
}
if [ $SCRIPT_INPUT_FILE_COUNT -ne 0 ]; then
@milseman
milseman / Swift5StateOfString.md
Created Jan 10, 2018
State of String: ABI, Performance, Ergonomics, and You!
View Swift5StateOfString.md

State of String: ABI, Performance, Ergonomics, and You!

Hello, I’ve been working on implementing, optimizing, and improving String in preparation for ABI stability, and I thought I’d share the current status of String in Swift 5 and some potential directions to go. This is the product of conversations with open source contributors and my colleagues on the Swift standard library team at Apple.

The primary area of focus is stabilizing String’s ABI, but we’d be remiss if we couldn’t also fit in performance and ergonomic improvements. String’s ergonomics in particular is one area where we think the status quo is woefully inadequate, and over half of this email is devoted to that topic. At the end, there’s a section about a community initiative that we hope can help users of String as well as guide future development.

(Note: I’m sending this to swift-dev because much of the contents revolve around implementation concerns. I’ll also cross-reference on swift-evolution and swift-users. See also the [StringManife

You can’t perform that action at this time.