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
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"> | |
<head></head> | |
<body> | |
<nav epub:type="toc" id="toc"> | |
<h1>Table of contents</h1> | |
<ol> | |
<li><a href="intro.xhtml">Introduction</a> </li> | |
<li><a href="part1.xhtml">Part 1: Server to Client Updates</a> </li> | |
<li> <a href="chapter1.xhtml">Chapter 1: Whole Database Synchronization</a></li> | |
<li> <a href="chapter2.xhtml">Chapter 2: Delta-based Synchronization</a></li> |
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
create or replace function do_record_deleted_campground_reviews() | |
returns trigger as | |
$BODY$ | |
begin | |
insert into deleted_records(table_name,record_id,deleted_at) | |
select 'campground_reviews', OLD.id, now(); | |
end; | |
$BODY$ | |
language plpgsql; |
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 CampgroundReview = db.define("campground_reviews", { | |
headline: String, | |
body: String, | |
rating: Number, | |
campground_id: Number, | |
updated_at: Date | |
}, { | |
hooks: { | |
beforeSave: function(next){ | |
this.updated_at = new Date(); |
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 DeletedRecord = db.define("deleted_records", { | |
table_name: String, | |
record_id: Number, | |
deleted_at: Date | |
}, { | |
hooks: { | |
beforeSave: function(next){ | |
this.deleted_at = new Date(); | |
next(); | |
} |
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 "NSArray+Construction.h" | |
@implementation NSArray (Construction) | |
+ (NSArray *) arrayWith:(int)count copiesOf:(NSString *)str { | |
NSMutableArray *result = [NSMutableArray new]; | |
for(int i = 0; i != count; i++){ | |
[result addObject:str]; | |
} | |
return result; |
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 <Foundation/Foundation.h> | |
@interface NSArray (Construction) | |
+ (NSArray *) arrayWith:(int)count copiesOf:(NSString *)str; | |
@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
var isMostlyLastDayOfFebruary = function(){ | |
var now = new Date(); | |
var isFeb28 = now.getMonth() == 1 && now.getDate() == 28; | |
var year = now.GetFullYear(); | |
var isLeapYear = year % 4 == 0 && !(year % 100 == 0 && year % 400 != 0); | |
return isFeb28 && !isLeapYear; | |
} |
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 CampgroundPhoto = db.define("campground_photos", { | |
photo_url: String, | |
campground_id: Number, | |
updated_at: Date | |
}, { | |
hooks: { | |
beforeSave: function(next){ | |
this.updated_at = new Date(); | |
next(); | |
} |
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
app.get('/api/updates/:model', function (req, res) { |
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
dispatch_async(syncQueue, ^{ |