Skip to content

Instantly share code, notes, and snippets.

View tgriesser's full-sized avatar

Tim Griesser tgriesser

View GitHub Profile
var chunksize = 50;
return (function next(items) {
if (!items.length) { return; }
return knex('sites')
.insert(items.slice(0, chunksize))
.then(function () {
return next(items.slice(chunksize));
});
@tgriesser
tgriesser / 01.coffee
Last active August 29, 2015 14:01 — forked from w33ble/01.coffee
# bookshelf code, to compliment the knex code above
exports.PG = Bookshelf.PG = Bookshelf.initialize
client: 'pg'
connection: config.get('/postgres')
# property photo model
exports.PropertyPhoto = PropertyPhoto = Bookshelf.PG.Model.extend
tableName: 'property_photos'
var Parent = Bookshelf.Model.extend({
tableName: 'parent',
child: function() {
return this.hasOne(Child);
}
});
var Child = Bookshelf.Model.extend({
tableName: 'child',
//this has an attribute parent_id
@tgriesser
tgriesser / gist:3188993
Created July 27, 2012 16:27 — forked from alappe/gist:3143376
No events…
namespace 'TimeLog.View', (exports) ->
class exports.Log extends Backbone.View
tagName: 'li'
events:
'click .date': 'lala'
template = _.template("""