Skip to content

Instantly share code, notes, and snippets.

View OliverLetterer's full-sized avatar
👨‍💻
Happy coding :)

Oliver Letterer OliverLetterer

👨‍💻
Happy coding :)
View GitHub Profile
# Install libxml2 using Homebrew
# If you don't have Homebrew, follow the instructions at:
# https://github.com/mxcl/homebrew/wiki/Installation
# -------------------------------------------------------
brew install libxml2
# Install libxslt from source code
# If you don't have wget, follow the instructions at:
# http://www.mactricksandtips.com/2008/07/installing-wget-on-your-mac-for-terminal.html
# Or use Homebrew:
// Taken from http://PSPDFKit.com. This snippet is under public domain.
#define UIKitVersionNumber_iOS_7_0 0xB57
BOOL PSPDFIsUIKitFlatMode(void) {
static BOOL isUIKitFlatMode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7.
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0;
}

When dismissing a view controller on top of a view controller with UIModalPresentationPageSheet or UIModalPresentationFormSheet, the presenting view controllers frame and transform can get miscomputed on iOS 7. Here is a fix I used in SPLSpeechBubblePopoverController:

@implementation UIViewController (SPLSpeechBubblePopoverControllerHack)

+ (void)load
{
    class_swizzleSelector(self, @selector(dismissViewControllerAnimated:completion:), @selector(__SPLSpeechBubblePopoverControllerDismissViewControllerAnimated:completion:));
}

Keybase proof

I hereby claim:

  • I am OliverLetterer on github.
  • I am oletterer (https://keybase.io/oletterer) on keybase.
  • I have a public key whose fingerprint is 9910 2A1F 6875 18FD DD01 24B0 A3CC E071 1958 9637

To claim this, I am signing this object:

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@implementation NSArray (BadThirdPartyImplementation)
- (id)firstObject
{
return self[0];
}
@end

Record a screencast with QuickTime Player

  1. Connect an iOS defice with a cable
  2. In QuickTime Player: Option-Cmd-N (New Movie Recording) -> Select your device from the recording menu:

http://cl.ly/image/1w0y3Y0H2g2X/record.png

Install gifify

@OliverLetterer
OliverLetterer / terminal
Created April 3, 2015 10:28
Count insertions / deletions in git repo
git log HEAD...3649b6a056d72524205b57791e7c78f3ac209f7e --numstat | grep ViewController.m | awk '{ INS += $1; DEL += $2 } END { print "+" INS " -" DEL }'
@OliverLetterer
OliverLetterer / xctest_finder.py
Created December 30, 2015 09:29 — forked from briancroom/xctest_finder.py
Script to assist with conforming to XCTestCaseProvider
#!/usr/bin/python
# Invoke this script with a Swift file containing an XCTestCase and it will
# generate an implementation for the `allTests` variable required for
# XCTestCaseProvider conformance on Linux
import sys
import re
inFile = open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin
//Given this:
NSArray *objects = @[@1, @2, @3]
//These are equivalent in behavior
NSNumber *first = [objects objectAtIndex:0]
NSNumber *second = (NSNumber *)CFArrayGetValueAtIndex(0)
//But is the code that runs the same? Not so much… in the first one we do…
objc_msgSend(objects, <selector reference>, 0)
-> http://sealiesoftware.com/msg/x86-mavericks.html