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;
@pietbrauer
pietbrauer / Makefile
Created April 26, 2015 10:03
Shutdown and reset all iOS Simulators
erase_sim:
./reset_sim.sh 2>/dev/null; true
@kristopherjohnson
kristopherjohnson / SystemLog.swift
Last active November 6, 2020 05:59
Demo of using the Apple System Log (ASL) API from Swift
// Note: This must be used in an Xcode project that contains a bridging header
// that includes <asl.h>
import Foundation
/// Provides high-level methods to access the raw data in
/// an ASL message.
struct SystemLogEntry {
/// Key-value pairs read from ASL message
let data: [String : String]
@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)
}
@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()
}
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>