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
@interface NSArray (EnumerableStuff) | |
/** | |
* similar to a map | |
*/ | |
- (NSArray *) objectsTransformedByBlock:(id (^)(id, NSUInteger, BOOL *))block; | |
/** | |
* filter the array | |
*/ |
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
@interface NSArray (EnumerableExtras) | |
/** | |
* similar to a map | |
*/ | |
- (NSArray *) objectsTransformedByBlock:(id (^)(id obj, NSUInteger idx, BOOL *stop))block; | |
/** | |
* filter the array | |
*/ |
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 "NSIndexPath+RowSectinCache.h" | |
@interface PairIndexPath : NSObject { | |
@private | |
NSUInteger indexes[2]; | |
} | |
- (NSUInteger)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
class MyHTTPServer(tornado.httpserver.HTTPServer): | |
_stopped = False | |
def _quit_if_ioloop_is_empty(self): | |
ioloop = tornado.ioloop.IOLoop.instance() | |
if len(ioloop._handlers) <= 1: | |
logger.info("Graceful shutdown complete. Exiting!") | |
exit(0) | |
else: | |
logger.info("Waiting for ioloop to be empty. has %d handlers left" % len(ioloop._handlers)) |
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 redis | |
import time | |
from contextlib import contextmanager | |
class _LockFailedError(Exception): pass | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger() | |
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
#define _MEMO(iVarName, block) ^{if (!iVarName) {iVarName = (block)();} return iVarName;} | |
- (UIButton *)eatCheeseButton; | |
{ | |
return _MEMO(eatCheeseButton, ^{ | |
return [[UIButton alloc] init]; | |
})(); | |
} |
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 redis | |
from cStringIO import StringIO | |
import weakref | |
import contextlib | |
from collections import deque | |
def main(): | |
c = PipesClient('localhost') |
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
// | |
// CCBlockTableViewDataSource.h | |
// | |
// Created by Tristan O'Tierney on 1/24/11. | |
// | |
#import <UIKit/UIKit.h> | |
@interface CCBlockTableViewDataSource : NSObject <UITableViewDataSource, UITableViewDelegate> { |
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
# -*- coding: utf-8 -*- | |
""" | |
sphinx.domains.objc | |
~~~~~~~~~~~~~~~~~~~ | |
The Objective C domain. | |
""" | |
import re |
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
// | |
// PGGeometry.hh | |
// PonyGrid | |
// | |
// Created by Mike Lewis on 9/23/11. | |
// Copyright (c) 2011 Square, Inc. All rights reserved. | |
// | |
#ifndef PonyGrid_PGGeometry_hh | |
#define PonyGrid_PGGeometry_hh |