Skip to content

Instantly share code, notes, and snippets.

View paulyoung's full-sized avatar
💭
Type check and prove things

Paul Young paulyoung

💭
Type check and prove things
View GitHub Profile
@mbrandonw
mbrandonw / tuples.swift
Created December 24, 2014 16:49
Named tuples in Swift
func minmax (a: Int, b: Int) -> (min: Int, max: Int) {
return (min(a, b), max(a, b))
}
minmax(10, -2) //=> (.0 -2, .1 10)
minmax(10, -2).min //=> -2
minmax(10, -2).max //=> 10
@tuxfight3r
tuxfight3r / 01.bash_shortcuts_v2.md
Last active November 1, 2025 03:59
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
* Rules
* Selectors and rules
* Variables and constraints
* Dimensions and positions (right, bottom)
* Intrinsic values
* Scope and virtuals
* Grids
* Selectors in grids
@kongtomorrow
kongtomorrow / gist:9a8530528cac708a7b48
Created December 3, 2014 01:06
Swift options for use with -Xllvm
% swiftc -Xllvm -help-hidden /tmp/foo.swift
USAGE: swift (LLVM option parsing) [options]
OPTIONS:
-a9-754319-workaround - Enable workarounds for A9 HW bugs #754319
-a9-754320-workaround - Enable workarounds for A9 HW bugs #754320
-aarch64-use-tbi - Assume that top byte of an address is ignored
-agg-antidep-debugdiv=<int> - Debug control for aggressive anti-dep breaker
-agg-antidep-debugmod=<int> - Debug control for aggressive anti-dep breaker
-aggressive-ext-opt - Aggressive extension optimization
anonymous
anonymous / confusingperformance.swift
Created November 28, 2014 22:24
import Cocoa
func isSorted(a:[Int]) -> Bool {
for i in indices(a) {
if i == 0 { continue }
if (a[i] < a[i-1]) { return false }
}
return true
}
@airspeedswift
airspeedswift / WeirdInference.swift
Last active August 29, 2015 14:10
Weird 1-liner type inference behavior
infix operator |> {
associativity left
}
func |><T,U>(t: T, f: T->U) -> U {
return f(t)
}
// this ought to be enough...
func reverse<T: CollectionType>(source: LazyRandomAccessCollection<T>) -> LazyBidirectionalCollection<RandomAccessReverseView<T>> {
@mattt
mattt / nshipster-new-years-2015.md
Created November 25, 2014 19:38
NSHipster New Year's 2015

Season's Greetings, NSHipsters!

As the year winds down, and we take a moment to reflect on our experiences over the past months, one thing is clear: 2014 has been an incredible year professionally for Apple developers. So much has happened in such a short timespan, and yet it's hard to remember our relationship to Objective-C before Swift, or what APIs could have captivated our imagination as much as iOS 8 or WatchKit.

It's an NSHipster tradition to ask you, dear readers, to send in your favorite tips and tricks from the past year for publication over the New Year's holiday. This year, with the deluge of new developments—both from Cupertino and the community at large—there should be no shortage of interesting tidbits to share.

Submit your favorite piece of Swift or Objective-C trivia, framework arcana, hidden Xcode feature, or anything else you think is cool, and you could have it featured in the year-end blowout article. Just comment on this gist below!

If you're wondering about what to post, look to

@mbbischoff
mbbischoff / LCKIndexedFetchedResultsController.h
Last active August 29, 2015 14:10
LCKIndexedFetchedResultsController is a NSFetchedResultsController subclass that attempts to solve the problem of sorting a fetched collection into correctly alphabetized sections for every locale. It does things like making sure that the `#` character shows up at the bottom instead of the top of the section index titles.
//
// LCKIndexedFetchedResultsController.h
// Quotebook
//
// Created by Andrew Harrison on 7/26/14.
// Copyright (c) 2014 Lickability. All rights reserved.
//
@import CoreData;
@0xced
0xced / copy-reveal-dylib.sh
Last active March 15, 2016 15:11
Copy and codesign libReveal.dylib in Debug configuration (for use in a run script build phase)
#!/bin/bash -e
if [ "${CONFIGURATION}" != "Debug" ]; then
exit 0
fi
REVEAL_APP_PATH=$(mdfind -onlyin / "kMDItemCFBundleIdentifier == com.ittybittyapps.Reveal" | head -n 1)
if [ ! -d "${REVEAL_APP_PATH}" ]; then
echo "warning: Reveal.app not found."
exit 0
//
// ViewController.swift
// Tetris
//
// Created by Julius Parishy on 11/19/14.
// Copyright (c) 2014 Julius Parishy. All rights reserved.
//
import UIKit