Skip to content

Instantly share code, notes, and snippets.

Jason Whitehorn jwhitehorn

Block or report user

Report or block jwhitehorn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View contents.json
[
{
"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
View toc.xhtml
<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>
View trigger.sql
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;
View database.js
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();
View database.js
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();
}
View NSArray+Construction.m
#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;
View NSArray+Construction.h
#import <Foundation/Foundation.h>
@interface NSArray (Construction)
+ (NSArray *) arrayWith:(int)count copiesOf:(NSString *)str;
@end
@jwhitehorn
jwhitehorn / MostlyLastDayOfFeb.js
Created Feb 23, 2018
The oh so overshadowed, mostly last day of February
View MostlyLastDayOfFeb.js
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;
}
View database.js
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();
}
View api.js
app.get('/api/updates/:model', function (req, res) {
You can’t perform that action at this time.