Skip to content

Instantly share code, notes, and snippets.

var async = require('async');
var pg = require('pg');
var connString = "postgres://postgres@localhost/template1";
// attempt 1 - all ok
pg.connect(connString, function(err, client, done) {
// this function has a .length of 3 ... therefore done is defined
console.log('1) Connected ok');
done();
// pg.end();
@brianc
brianc / users.js
Created November 6, 2012 02:52 — forked from iToto/users.js
Get all users
/**
+ \brief readUsers
+
+ This function will return all user objects to the client
+
+ \author Salvatore D'Agostino
+ \date 2012-11-05 20:47
+ \param response The response to return to the client
+ \param client (PSQL) PSQL client object
+
#!/usr/bin/env node
"use strict";
var fs = require('fs');
var net = require('net');
var uuid = require('node-uuid');
var async = require('async');
var cobol = require('../lib/cobol');
var fifo = require('../lib/fifo');
var tmpuuid = '/tmp/' + uuid.v4(), cust = 'upgrade', user = 'WEB99';
@brianc
brianc / protype.js
Created September 22, 2011 19:08 — forked from travisperson/protype.js
Overwriting a function prototype
var util = require("util");
//// Model ////
var Model = function(data) {
this._data = data
}
Model.prototype.show = function (data, cb) {
// act on data and then return exicute the callback
@brianc
brianc / Classical Inheritance in JS
Created April 26, 2011 16:04 — forked from JamesRyanATX/Classical Inheritance in JS
Classical Inheritance in JS
TinyOOP = {
mixin: function(target, other) { for(var key in other) { target[key] = other[key] }; return target },
class: function(parent, definition) {
var klass = parent.subclass(definition);
},
ClassMethods: {
subclass: function(definition) {
return TinyOOP.Class(this, definition);
}
}
@brianc
brianc / gist:784517
Created January 18, 2011 14:45 — forked from xrd/gist:784242
var pg = require('pg');
var cs = "postgres://blarg:blarg@localhost/blarg-upload-development";
pg.connect( cs, function( err, client ) {
//check for a connection error
if(err) {
console.log(err);
return;
}
var filename = "foobar";