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
// Usage example: | |
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png | |
// | |
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]]; | |
// .h | |
@interface UIImage (IPImageUtils) | |
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color; | |
@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
static NSString * const AQPerThreadManagedObjectContext = @"AQPerThreadManagedObjectContext"; | |
void StoreManagedObjectContextForCurrentThread( NSManagedObjectContext * context ) | |
{ | |
[[[NSThread currentThread] threadDictionary] setObject: context forKey: AQPerThreadManagedObjectContext]; | |
} | |
NSManagedObjectContext * PerThreadManagedObjectContext( void ) | |
{ | |
NSManagedObjectContext * result = [[[NSThread currentThread] threadDictionary] objectForKey: AQPerThreadManagedObjectContext]; |
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
// prototype | |
new Ajax.Request("/your/mom", onSuccess: function(response) { $("lightbox_content").innerHTML = response.responseJSON.contents }) | |
// jquery | |
$.getJSON("/your/mom", function(json) { $("#lightbox_content").html(json.contents) }) | |
// $.getJSON provides no ability to handle connection/parse errors | |
$.ajax({ url: "/your/mom", success: function(json) { $("#lightbox_content").html(json.contents) }, dataType: "json" }) |
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> | |
#import "GTMStackTrace.h" | |
#ifdef DEBUG | |
extern BOOL NSDebugEnabled; | |
extern BOOL NSZombieEnabled; | |
extern BOOL NSDeallocateZombies; | |
extern BOOL NSHangOnUncaughtException; | |
static void exceptionHandler(NSException *exception) { | |
FTLOG(@"%@", GTMStackTraceFromException(exception)); |
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 measure_time task_description | |
beginning = Time.now | |
yield | |
puts "Time to #{task_description}: #{Time.now - beginning} seconds" | |
end | |
def add a, i | |
a << i | |
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
# Would help dramatically if the function and arguments were appropriately named | |
def f(ra,n) | |
ra.inject(0) do |accum, value| | |
value.include?(n) ? accum + 1 : accum | |
end | |
end |