Skip to content

Instantly share code, notes, and snippets.

View adonoho's full-sized avatar

Andrew W. Donoho adonoho

View GitHub Profile
//
// UnwrapOrTrap.swift
//
infix operator ?! : NilCoalescingPrecedence
/// Performs a nil-coalescing operation, returning the wrapped value of an
/// `Optional` instance or uses the rhs function to stop the program.
///
/// - Parameters:
@orta
orta / _SQL.sql
Last active November 8, 2016 12:12
Top 300 Pods by Application Integrations
SELECT pods.name, stats_metrics.download_total, stats_metrics.download_week, stats_metrics.app_total, stats_metrics.app_week FROM stats_metrics JOIN pods ON stats_metrics.pod_id = pods.id ORDER BY app_total DESC LIMIT 300;
@hooman
hooman / EquatableClass.swift
Last active January 26, 2018 05:47
Sample code on how to correctly implement `Equatable` protocol for class types.
// The correct implementation of `Equatable` (and `Comparable`) can be tricky for class
// hierarchies. To make it easier, it is better to follow a well-defined pattern. Here
// is my suggestion on how to do it:
// 1. Define a protocol for polymorphic test function for equality (or comparison):
// Note: operators are not polymorphic (not virtual in C++ terms)). The function to
// call is determined and hard-coded at compile time.
/// A protocol to ammend `Equatable` for use with `class` types.
@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>
@durden
durden / references.md
Last active September 11, 2017 18:17
References for Python Science apps talk from Pycon 2013, PyTexas 2013, and PyArkansas 2012
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active April 23, 2024 02:53
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S