Skip to content

Instantly share code, notes, and snippets.

@neonichu
neonichu / yolo.sh
Created May 15, 2015 16:33
Mentions of `wireless` in the Xcode 6.3.1 runtime headers
$ grep -ri wireless *
DTDeviceKitBase/DTDKRemoteDeviceConnection.h: _Bool _wireless;
DTDeviceKitBase/DTDKRemoteDeviceConnection.h:@property(readonly, getter=isWireless) _Bool wireless; // @synthesize wireless=_wireless;
DTDeviceKitBase/DTDKRemoteDeviceToken.h: DTDKRemoteDeviceConnection *_primaryWirelessConection;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:+ (id)keyPathsForValuesAffectingHasWirelessConnection;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:@property(retain, nonatomic) DTDKRemoteDeviceConnection *primaryWirelessConection; // @synthesize primaryWirelessConection=_primaryWirelessConection;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:- (id)takeWirelessPowerAssertionWithName:(id)arg1 deatils:(id)arg2 andTimeout:(double)arg3;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:- (id)wirelessInstrumentsServer;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:- (void)disableWireless;
DTDeviceKitBase/DTDKRemoteDeviceToken.h:- (id)enableWireless;
@radex
radex / wwdc2015.md
Last active August 29, 2015 14:22
WWDC (iOS 9, OS X 10.11, Swift 2.0, Xcode 7) hopes&wishes

iOS 9:

  1. Stability, stability, stability. Things should just work. Especially networking/cloud related stuff: AirDrop, Handoff, syncing, etc…
  2. Notification center that's actually useful. Instead of grouping them by apps, and failing to intelligently show the notifications I'm interested in, show the chronological stream/feed of all notifications. Don't remove anything from that feed, only gray out notifications you've tapped on/seen. So, just like Facebook notifications. Much better model.
  3. Presence awareness for more intelligent notifications. Don't give me the cacophony of notifications of all 4 devices. Devices within each other's BTLE range should have awareness of each other and know that if I'm actively using my Mac, I want notifications to only show up there.
  4. Better app folders. The 3x3 grid is bullshit design, and even worse on the iPad. Make the folder zoom in and expand into a scrolling list of apps, not a paged interface. Kinda like on the Mac
  5. Allow people to choose default a
enum Result<A,B> {
case Left(A)
case Right(B)
}
extension Result {
func reduce<R>(f: A -> R, g: B -> R) -> R {
switch self {
case .Left(let a): return f(a)
case .Right(let b): return g(b)
@twostraws
twostraws / gist:3d673d4eba36de173f6f
Last active August 29, 2015 14:23
Love Wins in Swift
//
// loveWins(): a simple function that accepts a UIImage and
// returns the same image blended with the rainbow flag
// of the LGBT pride movement.
//
// This is released for pedagogical reasons (I've tried to make
// the code as easy to follow as possible!) but you're welcome
// to use it for any purpose – consider the code yours.
//
// If you're using Xcode 7 / Swift 2, you need to make a tiny
private extension GeneratorType {
mutating func any(@noescape pred: Element -> Bool) -> Bool {
return next().map { el in pred(el) || any(pred) } ?? false
}
mutating func all(@noescape pred: Element -> Bool) -> Bool {
return next().map { el in pred(el) && all(pred) } ?? true
}
}
public extension SequenceType {
@emreberge
emreberge / KeyPath.h
Last active September 3, 2015 12:15
Compiler help for keyPaths!
#define KeyPath(keyPath)\
^NSString *(void) {\
__unused __typeof__(keyPath) x;\
return [@#keyPath substringFromIndex:([@#keyPath rangeOfString:@"."].location + 1)];\
}()
// http://blog.krzyzanowskim.com
import Cocoa
struct ChunkSequence<Element>: SequenceType {
let chunkSize: Array<Element>.Index
let collection: Array<Element>
func generate() -> AnyGenerator<ArraySlice<Element>> {
var offset:Array<Element>.Index = collection.startIndex
@radex
radex / optional-assignment.swift
Last active February 29, 2016 13:29
Optional assignment operator implementation. `foo ??= bar` will evaluate and assign bar to foo if and only if foo is nil. Equivalent to `||=` in Ruby and other languages.
infix operator ??= {
associativity right
precedence 90
assignment
}
func ??= <T>(inout variable: T?, expr: @autoclosure () -> T) {
if variable == nil {
variable = expr()
}
@pietbrauer
pietbrauer / 1README.md
Last active September 9, 2016 20:44
Universal CLI for automated iOS deploys and tests

Steps

  1. Download the cli.sh and move it into a scripts/ directory and execute chmod 755 scripts/cli.sh, this will make the script executable.
  2. Export your iOS Distribution private key from your Keychain into the scripts/ folder and name it ios_distribution.p12 make sure to note down the password as we will need it later. It is highly recommended to give it a very strong password.
  3. Download your Distribution provisioning profile from the Member Center
  4. Rename the provisioning profile to Release.mobilprovision
  5. At the top of the script you may need to adjust a few values:
SCHEME="" # Your scheme
@andymatuschak
andymatuschak / gist:2b311461caf740f5726f
Created December 28, 2014 18:17
A pragmatic and intentionally non-abstract solution to JSON decoding / initialization that doesn't require learning about five new operators.
struct User {
let id: Int
let name: String
let email: String?
}
extension User: JSONDecodable {
static func create(id: Int, name: String, email: String?) -> User {
return User(id: id, name: name, email: email)
}