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 SomeModel = Backbone.Model.extend({}); | |
someModel = new SomeModel(); | |
someModel.bind("change", function(model, collection){ | |
alert("You set some_attribute to " + model.get('some_attribute')); | |
}); | |
someModel.set({some_attribute: "some value"}); |
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 SizableImageCell : UITableViewCell {} | |
@end | |
@implementation SizableImageCell | |
- (void)layoutSubviews { | |
[super layoutSubviews]; | |
float desiredWidth = 80; | |
float w=self.imageView.frame.size.width; | |
if (w>desiredWidth) { | |
float widthSub = w - desiredWidth; |
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
+(NSString*)urlEscape:(NSString *)unencodedString { | |
NSString *s = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, | |
(CFStringRef)unencodedString, | |
NULL, | |
(CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ", | |
kCFStringEncodingUTF8); | |
return [s autorelease]; // Due to the 'create rule' we own the above and must autorelease it | |
} | |
// Put a query string onto the end of a url |
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
- (UIImage *)radialGradientImage:(CGSize)size start:(float)start end:(float)end centre:(CGPoint)centre radius:(float)radius { | |
// Render a radial background | |
// http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_shadings/dq_shadings.html | |
// Initialise | |
UIGraphicsBeginImageContextWithOptions(size, YES, 1); | |
// Create the gradient's colours | |
size_t num_locations = 2; | |
CGFloat locations[2] = { 0.0, 1.0 }; |
NewerOlder