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> | |
@interface CameraTestAppDelegate : NSObject <UIApplicationDelegate> { | |
UIWindow *window; | |
} | |
@property (nonatomic, retain) IBOutlet UIWindow *window; | |
- (void) cameraControllerReadyStateChanged:(NSNotification*)aNotification; | |
- (void) cameraController:(id)sender tookPicture:(UIImage*)picture withPreview:(UIImage*)preview jpegData:(NSData*)rawData imageProperties:(struct __CFDictionary*) imageProperties; |
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
#define HEXCOLOR(c) [UIColor colorWithRed:((c>>24)&0xFF)/255.0 \ | |
green:((c>>16)&0xFF)/255.0 \ | |
blue:((c>>8)&0xFF)/255.0 \ | |
alpha:((c)&0xFF)/255.0]; | |
UIColor* myColor = HEXCOLOR(0xff0000); |
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
class Job < ActiveRecord::Base | |
STATUS_READY, STATUS_IN_PROGRESS, STATUS_DONE = 1, 2, 3 | |
def self.fetch(pid) | |
update_all( | |
{ :status => STATUS_IN_PROGRESS, | |
:pid => pid }, | |
{ :status => STATUS_READY }, | |
{ :limit => 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
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
dpkg --get-selections > packages.txt | |
dpkg --set-selections < packages.txt | |
apt-get dselect-upgrade |
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
# Checking out | |
git svn init <svn url> <checkout directory> | |
git svn fetch | |
git repack -d | |
# Working | |
git checkout -b some-feature | |
git commit -a -m "Some feature" | |
# Commiting |
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 UIView (Debugging) | |
-(void)inspectWithDepth:(int)depth path:(NSString *)path; | |
@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
Finding the H.264 format of a Vimeo video: | |
1. Fetch the clip XML metadata (e.g. "http://vimeo.com/moogaloop/load/clip:5531123") | |
2. Grab the value of "request_signature" and "request_signature_expires" from the XML | |
3. Use the URL "http://vimeo.com/moogaloop/play/clip:5531123/REQUEST_SIG/REQUEST_SIG_EXPIRES/?q=hd" |
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
@implementation NSArray(Filtering) | |
- (NSArray*)arrayByMappingArrayUsingSelector:(SEL)selector, ... { | |
NSInvocation* invocation; | |
va_list arguments; | |
if (selector && [self lastObject]) { | |
va_start(arguments, selector); | |
invocation = [NSInvocation invocationUsingSelector:selector onTarget:[self lastObject] argumentList:arguments]; | |
va_end(arguments); | |
} |
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 ify = function() { | |
return { | |
"link": function(t) { | |
return t.replace(/(^|\s+)(https*\:\/\/\S+)/g, function(m, m1, link) { | |
return m1.concat('<a href="', link, '">', link.substr(0, 24), 25 < link.length ? '...' : '', '</a>'); | |
}); | |
}, | |
"at": function(t) { | |
return t.replace(/(^|\s+)\@([a-zA-Z0-9_]{1,15})/g, ‘$1@<a href=”http://twitter.com/$2″>$2</a>’); | |
}, |