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
import Alamofire
let configuration = URLSessionConfiguration.default
configuration.requestCachePolicy = URLRequest.CachePolicy.reloadIgnoringLocalCacheData
let proxyConfiguration: [AnyHashable : Any] = [
kCFNetworkProxiesHTTPEnable as AnyHashable: true,
kCFNetworkProxiesHTTPProxy as AnyHashable: host,
kCFNetworkProxiesHTTPPort as AnyHashable: port,
@OliverLetterer
OliverLetterer / encrypted-git-repo.md
Created January 22, 2017 17:21
Transparent Git Encryption

Transparent Git Encryption

This document has been modified from its [original format][m1], which was written by Ning Shang ([email protected]). It has been updated and reformatted into a [Markdown][m2] document by [Woody Gilk][m3] and [republished][m4].

Description

When working with a remote git repository which is hosted on a third-party storage server, data confidentiality sometimes becomes

// The trick is to copy the DeviceSupport folder from the beta to the stable version.
cp -r /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.0\ \(14A5261u\) /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/
// Then restart Xcode. You might need to do that for every beta of iOS 10/Xcode 8.
@OliverLetterer
OliverLetterer / sethack.m
Created March 11, 2016 08:45 — forked from Catfish-Man/sethack.m
Demonstrating the trick of using stack-allocated mimics and sets for lookup tables instead of heap allocated keys and dictionaries
// Compile with clang -framework Foundation sethack.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
/*
CFHashBytes from http://www.opensource.apple.com/source/CF/CF-1153.18/CFUtilities.c
*/
#define ELF_STEP(B) T1 = (H << 4) + B; T2 = T1 & 0xF0000000; if (T2) T1 ^= (T2 >> 24); T1 &= (~T2); H = T1;
//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
@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
@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 }'

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

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

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.