Skip to content

Instantly share code, notes, and snippets.

View sebreh's full-sized avatar

Sebastian Rehnby sebreh

  • Copenhagen, Denmark
View GitHub Profile
@sebreh
sebreh / UIApplication+SRFirstResponder.m
Created October 16, 2012 07:27
UIApplication category for resigning the current first responder
//
// UIApplication+SRFirstResponder.m
//
// Copyright (C) 2012 Sebastian Rehnby
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
@sebreh
sebreh / WeakMacros.h
Last active December 11, 2015 21:39
Shorthand macros for creating weak references.
#define SR_WEAK(obj) __typeof__(obj) __weak
#define SR_WEAK_SELF SR_WEAK(self)
// Usage:
// SR_WEAK_SELF weakSelf = self;
@sebreh
sebreh / NSManagedObjectContext+SRFetchAsync.h
Created May 20, 2013 20:07
Category for executing a Core Data fetch request in the background
#import <CoreData/CoreData.h>
@interface NSManagedObjectContext (SRFetchAsync)
- (void)sr_executeFetchRequest:(NSFetchRequest *)request completion:(void (^)(NSArray *objects, NSError *error))completion;
@end
@sebreh
sebreh / bowling_scores.rb
Last active August 9, 2017 07:43 — forked from RSpace/bowling_scores.rb
Bowling Kata tests
[
[0, [0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0]],
[20, [1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1]],
[6, [1,1, 1,1, 1,1]], # incomplete
[18, [1,1, 6,4, 3]], # incomplete w/ spare
[150, [5,5, 5,5, 5,5, 5,5, 5,5, 5,5, 5,5, 5,5, 5,5, 5,5, 5]],
[47, [1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 10, 10 ,9]],
[173, [7,3, 7,3, 7,3, 7,3, 7,3, 7,3, 7,3, 7,3, 7,3, 7,3, 10]],
[300, [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]],
[280, [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5]], # incomplete
@sebreh
sebreh / iOS8ReadinessChecklist.md
Created July 25, 2014 07:52
iOS 8 Readiness Checklist

iOS 8 Readiness Checklist

UIKit

  • Adopt size classes and be aware of the old derecated rotation APIs. Test your app on the resizable simulator.
  • Push Notifications: The API to register for push notifications has changed on iOS 8 with new methods on UIApplication.
  • If you use app icon badges, you need to ask for user permission in order to do so.

Foundation

@sebreh
sebreh / PodioKitExtensions.swift
Created November 5, 2014 21:22
A set of extensions to PodioKit to make it easier to work with in Swift.
extension PKTAsyncTask {
func onSuccess<ResultType>(successBlock: ResultType! -> Void) {
onSuccess { obj in
let typedObj = obj as? ResultType
successBlock(typedObj)
}
}
func onComplete<ResultType>(completeBlock: (ResultType?, NSError?) -> Void) {
@sebreh
sebreh / keybase.md
Created December 29, 2014 08:09
keybase.md

Keybase proof

I hereby claim:

  • I am sebreh on github.
  • I am sebreh (https://keybase.io/sebreh) on keybase.
  • I have a public key whose fingerprint is 2B14 F778 D7BD 6DD3 8189 B22E 7402 37CD 9BDD 32A0

To claim this, I am signing this object:

@sebreh
sebreh / RACSupport.swift
Last active August 29, 2015 14:13
Swift extensions to ReactiveCocoa to make it easier to work with from Swift.
import Foundation
extension RACSignal {
func subscribeNextAs<T>(nextClosure: (T?) -> Void) {
self.subscribeNext {
(next: AnyObject!) -> () in
let nextAsT = next as? T
nextClosure(nextAsT)
}