This file contains hidden or 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
func ==<T:Feed>(lhs: T, rhs: T) -> Bool { | |
return lhs.link == rhs.link | |
} | |
protocol Feed : Equatable { | |
var link : String {get} | |
} | |
protocol Folder { | |
typealias FeedType: Feed |
This file contains hidden or 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
#include "scheduler.h" | |
#include <stddef.h> | |
#include <stdbool.h> | |
// | |
// Compatibility macros | |
// | |
// Missing from Arduino toolchain | |
#ifndef UINT16_MAX |
This file contains hidden or 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
def get_local_timezone_str | |
# Yes, this is actually a shell script… | |
olsontz = `if [ -f /etc/timezone ]; then | |
cat /etc/timezone | |
elif [ -h /etc/localtime ]; then | |
readlink /etc/localtime | sed "s/\\/usr\\/share\\/zoneinfo\\///" | |
else | |
checksum=\`md5sum /etc/localtime | cut -d' ' -f1\` | |
find /usr/share/zoneinfo/ -type f -exec md5sum {} \\; | grep "^$checksum" | sed "s/.*\\/usr\\/share\\/zoneinfo\\///" | head -n 1 | |
fi`.chomp |
This file contains hidden or 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
infix operator **: MultiplicationPrecedence | |
public func **<T: UnsignedInteger>(base: T, exponent: T) -> T { | |
return pow(base, exponent) | |
} | |
/// Implements pow() for integers using exponentiation by squaring | |
public func pow<T: BinaryInteger, U: UnsignedInteger>(_ base: T, _ exponent: U) -> T { | |
var result: T = 1 |
This file contains hidden or 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 SetGenerator<T:Hashable> : Generator { | |
var backingGenerator: DictionaryGenerator<T, Void> | |
init(backingGenerator: DictionaryGenerator<T, Void>) { | |
self.backingGenerator = backingGenerator; | |
} |
This file contains hidden or 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
function swift | |
set developer_dir $DEVELOPER_DIR | |
set -x DEVELOPER_DIR /Applications/Xcode6-Beta.app/Contents/Developer/ | |
xcrun swift | |
if echo $developer_dir | grep "/" | |
set -x DEVELOPER_DIR $developer_dir | |
else | |
set -e DEVELOPER_DIR | |
end | |
end |
This file contains hidden or 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/UIKit.h> | |
@protocol NNApplicationSubscriber <NSObject> | |
@optional | |
- (void)applicationDidBecomeActive:(UIApplication *)application; | |
- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame; | |
- (void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation; | |
- (void)applicationDidEnterBackground:(UIApplication *)application; | |
- (void)applicationDidFinishLaunching:(UIApplication *)application; |
This file contains hidden or 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
/** | |
Provides the ability to verify key paths at compile time. | |
If "keyPath" does not exist, a compile-time error will be generated. | |
Example: | |
// Verifies "isFinished" exists on "operation". | |
NSString *key = SQKeyPath(operation, isFinished); | |
// Verifies "isFinished" exists on self. |
This file contains hidden or 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 "memoize.h" | |
@implementation Example | |
- (id)null; | |
{ | |
return NNMemoize(^{ | |
sleep(1); | |
return [NSNull null]; | |
}); |
This file contains hidden or 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 <objc/runtime.h> | |
#import <stdlib.h> | |
// declare some of the Objective-C runtime's private parts where we can see them | |
typedef struct _NXMapTable NXMapTable; | |
extern NXMapTable *gdb_objc_realized_classes; | |
extern void *NXMapInsert(NXMapTable *table, const void *key, const void *value); | |
@implementation NSObject (Poser) |