This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See http://stackoverflow.com/a/257424/283482 | |
// Normally a "do {…} while (0)" is used to prevent the problem described in the linked answer, | |
// but this would prevent us from using "continue" or "break" in the block parameter. | |
// The problem is fixed thanks to the "if (1) {…}", doing the same as the "do {…} while (0)". | |
#define AssertTrueOrRunBlock(condition, block, description, ...)\ | |
if (1) {\ | |
__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS\ | |
BOOL check = !!(condition);\ | |
NSCAssert(check, (description), ##__VA_ARGS__);\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
struct Builder { | |
typealias Attributes = Dictionary<String, AnyObject> | |
typealias Block = () -> () | |
typealias Visitor = (Node) -> () | |
class Node { | |
var name : String | |
var parent: Node? { didSet { level = parent!.level + 1} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Takes in a function that transform T to U and | |
* a callback that takes arguments of type T and U | |
* and returns a function that performs f but calls | |
* the callback before returning | |
*/ | |
func callback<T,U>(f: T -> U, c: (T, U) -> ()) -> T -> U{ | |
return { x in | |
let r = f(x) | |
c(x,r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)writeData:(NSData *)data toOutputStream:(NSOutputStream *)stream { | |
dispatch_async(dispatch_get_current_queue(), ^(void){ | |
BOOL sent = NO; | |
do { | |
if (outputStreamReady) { | |
outputStreamReady = NO; | |
uint8_t *readBytes = (uint8_t *)[data bytes]; | |
int data_len = [data length]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// YMKeyboardLayoutHelperView.m | |
// ios-chat | |
// | |
// Created by Steven Hepting on 7/17/13. | |
// Copyright (c) 2013 Yammer. All rights reserved. | |
// | |
#import "YMKeyboardLayoutHelperView.h" | |
#import "UIView+LayoutAdditions.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
//## iOS:ファイルシステム ##### | |
//標準ディレクトリ ( Documents/, Library/, tmp/ ... ) | |
//## OS X:ファイルシステム ##### | |
//ローカルドメイン ( Applications/Utilities, Developer/, Library/ ) | |
//ユーザードメイン ( Users/user1, ... ) | |
//ファイルまたはディレクトリのパス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - Transparent Modal View | |
-(void) presentTransparentModalViewController: (UIViewController *) aViewController | |
animated: (BOOL) isAnimated | |
withAlpha: (CGFloat) anAlpha{ | |
self.transparentModalViewController = aViewController; | |
UIView *view = aViewController.view; | |
view.opaque = NO; | |
view.alpha = anAlpha; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import CoreData | |
/** | |
Query: this is a Swift Query API for CodeData. | |
Usage example: | |
// fetch multiple rows | |
let people = Query("Person").whereEqual( "lastName", lastName ).sort( "name" ).fetch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct S0<V> { | |
typealias F = () -> V | |
} | |
struct S1<T1,V>{ | |
typealias F = (T1) -> V | |
} | |
//0, 0 | |
func curry<T1, V>(f: S1<T1, V>.F, a1:T1) -> S0<V>.F { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Firebase from 'firebase'; | |
import Promise from 'bluebird'; | |
import {ValidationError} from './lib/validation'; | |
import {firebaseCursor} from './state'; | |
// if (!process.env.IS_BROWSER) { | |
// // TODO: Set Firebase for server. | |
// } | |
export const TIMESTAMP = Firebase.ServerValue.TIMESTAMP; |