Skip to content

Instantly share code, notes, and snippets.

[
{
"url": "https://www.datasyncbook.com/content/introduction/",
"file": "html/intro.xhtml",
"login": null
},
{
"url": "https://www.datasyncbook.com/content/server-to-client-updates/",
"file": "html/part1.xhtml",
"login": null
<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;
}
@jwhitehorn
jwhitehorn / api.js
Last active February 23, 2018 18:53
var onionrm = require('onionrm');
var express = require('express');
var openDb = require('./database.js');
var app = express();
app.get('/api/updates/:model', function (req, res) {
var filter = {
updated_at: onionrm.gte(req.query.timestamp)
};
openDb(function(err, models, closeDb){
[{
"id": 1,
"name": "Oaklake Trails Naturist Park",
"latitude": 35.8082099,
"longitude": -96.5649402,
"rating": 4,
"address": "24601 Milfay Rd",
"city": "Depew",
"state": "OK",
"zip_code": "74028",