Skip to content

Instantly share code, notes, and snippets.

Chris Dzombak cdzombak

Block or report user

Report or block cdzombak

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
View gist:598fa75e22bdfa44cf47

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

myell0w / externalKeyboard.m
Last active Nov 20, 2019
Detect if there's an external keyboard attached (iOS)
View externalKeyboard.m
// direct check for external keyboard
+ (BOOL)_isExternalKeyboardAttached
BOOL externalKeyboardAttached = NO;
@try {
NSString *keyboardClassName = [@[@"UI", @"Key", @"boa", @"rd", @"Im", @"pl"] componentsJoinedByString:@""];
Class c = NSClassFromString(keyboardClassName);
SEL sharedInstanceSEL = NSSelectorFromString(@"sharedInstance");
if (c == Nil || ![c respondsToSelector:sharedInstanceSEL]) {
jspahrsummers / GHRunLoopWatchdog.h
Created Jan 28, 2015
A class for logging excessive blocking on the main thread
View GHRunLoopWatchdog.h
/// Observes a run loop to detect any stalling or blocking that occurs.
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
rentzsch / OmniFocus Selected Mail Messages.applescript
Created Jan 6, 2015
OmniFocus Selected Mail Messages.applescript
View OmniFocus Selected Mail Messages.applescript
OmniFocus Selected Mail Messages.applescript
Copyright (c) 2015 Jonathan 'Wolf' Rentzsch:
Some rights reserved:
Pure AppleScript reimplementation of OmniGroup's Clip-o-Tron for OmniFocus.
Hopefully this implementation will be more resilient against OS X, Mail, and OmniFocus updates.
Successfully tested against OS X 10.10.1, OmniFocus 1.10.6, and OmniFocus 2.0.4.
mattbischoff / LCKIndexedFetchedResultsController.h
Last active Aug 29, 2015
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.
View LCKIndexedFetchedResultsController.h
// LCKIndexedFetchedResultsController.h
// Quotebook
// Created by Andrew Harrison on 7/26/14.
// Copyright (c) 2014 Lickability. All rights reserved.
@import CoreData;
tomlokhorst / Optional+Unwrap.swift
Last active Dec 26, 2017
Unwrap multiple optionals in Swift 1.0
View Optional+Unwrap.swift
func unwrap<T1, T2>(optional1: T1?, optional2: T2?) -> (T1, T2)? {
switch (optional1, optional2) {
case let (.Some(value1), .Some(value2)):
return (value1, value2)
return nil
func unwrap<T1, T2, T3>(optional1: T1?, optional2: T2?, optional3: T3?) -> (T1, T2, T3)? {
pyrtsa / Managing-optionals-in-Swift.swift
Last active Mar 7, 2017
Managing optionals in Swift
View Managing-optionals-in-Swift.swift
// Hello, fellow Swift programmer!
// Here's a demonstration of a few ways of cleaning up the unwrapping of
// optionals in Swift.
// Swift is known to have both OO and functional background. Thus, there is
// probably some middle ground programming style that is *more* functional than
// Objective-C, and probably less so than Haskell. This playground tries to
// compare their differences in the pretty common scenario of dealing with
// errors or missing input.
kristopherjohnson / pipe-forward-optional.swift
Last active Nov 28, 2015
F#-style pipe-forward chaining operators for Swift that unwrap Optional values
View pipe-forward-optional.swift
// Pipe-forward operators that unwrap Optional values
operator infix |>! { precedence 50 associativity left }
operator infix |>& { precedence 50 associativity left }
// Unwrap the optional value on the left-hand side and apply the right-hand-side function
public func |>! <T,U>(lhs: T?, rhs: T -> U) -> U {
return rhs(lhs!)
// If optional value is nil, return nil; otherwise unwrap it and
peeblesjs / gist:9288f79322ed3119ece4
Last active Feb 11, 2016
A naive "valueForKey:" operator in Swift
View gist:9288f79322ed3119ece4
operator infix --> {}
func --> (instance: Any, key: String) -> Any? {
let mirror = reflect(instance)
for index in 0 ..< mirror.count {
let (childKey, childMirror) = mirror[index]
if childKey == key {
return childMirror.value
kristopherjohnson / pipe-forward.swift
Last active Jul 8, 2019
Swift: define F#-style pipe-forward (|>) operator that evaluates from left to right.
View pipe-forward.swift
// F#'s "pipe-forward" |> operator
// Also "Optional-chaining" operators |>! and |>&
// And adapters for standard library map/filter/sorted
infix operator |> { precedence 50 associativity left }
infix operator |>! { precedence 50 associativity left }
infix operator |>& { precedence 50 associativity left }
infix operator |>* { precedence 50 associativity left }
You can’t perform that action at this time.