Skip to content

Instantly share code, notes, and snippets.

<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>
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;
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();
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();
}
#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;
#import <Foundation/Foundation.h>
@interface NSArray (Construction)
+ (NSArray *) arrayWith:(int)count copiesOf:(NSString *)str;
@end
@jwhitehorn
jwhitehorn / MostlyLastDayOfFeb.js
Created February 23, 2018 21:43
The oh so overshadowed, mostly last day of February
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;
}
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();
}
app.get('/api/updates/:model', function (req, res) {
dispatch_async(syncQueue, ^{