Skip to content

Instantly share code, notes, and snippets.

View doug-martin's full-sized avatar

Doug Martin doug-martin

  • C2FO
  • Fort Collins, CO
View GitHub Profile
const path = require('path');
const fs = require('fs');
const { Transform } = require('stream');
const csv = require('fast-csv');
class PersistStream extends Transform {
constructor(args) {
super({ objectMode: true, ...(args || {}) });
this.batchSize = 100;
this.batch = [];
const path = require('path');
const fs = require('fs');
const { Transform } = require('stream');
const csv = require('fast-csv');
class EndEarlyTransform extends Transform {
constructor(args) {
super({ objectMode: true, ...(args || {}) });
this.rowCount = 0;
this.endOn = 30000;

Keybase proof

I hereby claim:

  • I am doug-martin on github.
  • I am dougamartin (https://keybase.io/dougamartin) on keybase.
  • I have a public key whose fingerprint is A7BF 0130 4A65 B4FF 0D70 49A7 DCB3 E865 76B3 6367

To claim this, I am signing this object:

var when = comb.when,
wrap = comb.wrap,
User = models.User,
Chores = models.Chores;
when(
wrap(User.find, User)({}),
wrap(Chore.find, Chore)({})
).then(function(res){
@doug-martin
doug-martin / gist:2240190
Created March 29, 2012 17:17
Patio orm join example
var patio = require("patio"),
SQL = patio.sql;
var DB = patio.connect("mysql://localhost:3306/test");
var sql = "SELECT * FROM Device AS dev JOIN PushID AS pid ON dev.macAddress=pid.idDevice JOIN State AS state ON pid.deviceToken=state.pushId JOIN Message AS msg ON state.messageId=msg.idMessage WHERE dev.macAddress={macAddress} AND msg.idMessage={idMessage}";
var sqlDs = DB.fetch(sql, {macAddress:"", idMessage:"idMessage"});
console.log(sqlDs.sql);
@doug-martin
doug-martin / gist:2115744
Created March 19, 2012 15:11
Drop Foreign Key
"use strict";
var patio = require("../index"),
sql = patio.sql,
comb = require("comb"),
format = comb.string.format;
patio.camelize = true;
//comb.logging.Logger.getRootLogger().level = comb.logging.Level.ERROR;