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
@protocol ILCannedURLProtocolDelegate <NSObject> | |
- (NSData*)responseDataForClient:(id<NSURLProtocolClient>)client request:(NSURLRequest*)request; | |
@optional | |
- (BOOL)shouldInitWithRequest:(NSURLRequest*)request; | |
- (NSURL *)redirectForClient:(id<NSURLProtocolClient>)client request:(NSURLRequest *)request; | |
- (NSInteger)statusCodeForClient:(id<NSURLProtocolClient>)client request:(NSURLRequest*)request; | |
- (NSDictionary*)headersForClient:(id<NSURLProtocolClient>)client request:(NSURLRequest*)request; | |
@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 "HKZFakeWebserver.h" | |
@implementation HKZFakeWebserver | |
// This function returns the correct JSON data, or whatever for the requested URL | |
// via the ILURLProtocol | |
- (NSData *)responseDataForClient:(id<NSURLProtocolClient>)client request:(NSURLRequest*)request { | |
NSData *responseData = nil; | |
// Dog profile information |
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
// beforeEach/afterEach are Kiwi constructs | |
beforeEach(^{ | |
//register as Protocol delegate, the magic begins | |
[NSURLProtocol registerClass:[ILCannedURLProtocol class]]; | |
// Default HTTP status code | |
[ILCannedURLProtocol setCannedStatusCode:200]; | |
// Configure ILtesting only for certain verbs if you like |
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
@interface HKZDogParkAPIClient : NSObject | |
- (void)fetchProfile:(int)profileId block:(void(^)(NSDictionary *dog, NSError* error))clientBlock; | |
- (void)signup:(void(^)(NSDictionary *dog, NSError* error))clientBlock; | |
@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
@interface HKZDogParkAPIClient : NSObject | |
- (void)fetchProfile:(int)profileId block:(void(^)(NSDictionary *dog, NSError* error))clientBlock; | |
- (void)signup:(void(^)(NSDictionary *dog, NSError* error))clientBlock; | |
@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
lines = File.new('gettys').gets | |
lineno = 0 | |
short = {0=>[]} | |
lines.split(' ').each do |word| | |
#count up the present line and include spaces. Take into account the current space count | |
#and the impact of adding the new word + 1 space. | |
if ( ( (short[lineno].inject(0){|sum, ele| sum+=ele.size} ) + (word.size+1 + (short[lineno].count-1)) ) <= 13) | |
short[lineno] = short[lineno].push word | |
else | |
lineno+=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
BBView = Backbone.View.extend({ | |
el: '#some-selector', | |
attributes: function () { | |
return { | |
name: this.nameField.val(), | |
email: this.emailField.val(), | |
password: this.passwordField.val(), | |
password_confirmation: this.passwordConfirmationField.val() | |
}; | |
}, |
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
//Make sure to namespace stuff :) | |
window.Poc = window.Poc || {}; | |
window.Poc.Models = window.Poc.Models || {}; | |
window.Poc.Collections = window.Poc.Collections || {}; | |
window.Poc.Views = window.Poc.Views || {}; | |
window.Poc.Dispatcher = {}; | |
/****************************** | |
****** Backbone Objects ****** |
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
<!-- Add the following lines to theme's html code right before </head> --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
<!-- | |
Usage: just add <div class="gist">[gist URL]</div> | |
Example: <div class="gist">https://gist.github.com/1395926</div> | |
--> |
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
var RoundButton = function(radius, label, action) { | |
this.radius = radius; | |
this.label = label; | |
this.action = action; | |
this.StuffSp = 'hoho'; | |
}; | |
var someStuff = function(){ | |
if(this.hasOwnProperty('StuffSpace')){ |