Requirements:
If you're on OSX you're probably best off using Homebrew to install this stuff:
$ brew install node mongodb
Usage:
rvm gemset create RestKit | |
git submodule update --init --recursive |
$("#someDiv").bind("DOMSubtreeModified", function() { | |
alert("tree changed"); | |
}); |
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | |
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) | |
#define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f) | |
#define IS_IPHONE_4 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0f) |
// iOS5 Only | |
- (void) setMediaInfo { | |
NSMutableDictionary * dict = [[NSMutableDictionary alloc] init]; | |
NSString * imName = @"imagetest.png"; // Artwork image | |
[dict setObject:NSLocalizedString(@"My Music", @"") forKey:MPMediaItemPropertyTitle]; | |
[dict setObject:NSLocalizedString(@"Myself Artist", @"") forKey:MPMediaItemPropertyArtist]; | |
MPMediaItemArtwork * mArt = [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:imName]]; | |
[dict setObject:mArt forKey:MPMediaItemPropertyArtwork]; | |
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = nil; | |
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:dict]; |
// articles per page | |
var limit = 10; | |
// pagination middleware function sets some | |
// local view variables that any view can use | |
function pagination(req, res, next) { | |
var page = parseInt(req.params.page) || 1, | |
num = page * limit; | |
db.articles.count(function(err, total) { | |
res.local("total", total); |
- (void)fetchContacts:(void (^)(NSArray *contacts))success failure:(void (^)(NSError *error))failure { | |
if (ABAddressBookRequestAccessWithCompletion) { | |
// on iOS 6 | |
CFErrorRef err; | |
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &err); | |
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { | |
// ABAddressBook doesn't gaurantee execution of this block on main thread, but we want our callbacks to be | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
if (!granted) { |
var mongoose = require('mongoose'); | |
mongoose.connect('localhost/test'); | |
var Schema = mongoose.Schema; | |
var AlbumSchema = new Schema({ | |
artist: { type: Schema.Types.ObjectId, ref: 'Artist' }, | |
name: String, | |
year: Number, |
resetForm = (form) -> | |
frm_elements = form.elements | |
for element in frm_elements | |
field_type = element.type.toLowerCase(); | |
switch field_type | |
when "text", "textarea", "hidden" then element.value = "" | |
when "radio", "checkbox" then element.checked = false | |
when "select-one", "select-multi" then element.selectedIndex = -1 | |
else element.innerHTML = ""; |