Last active
December 27, 2015 12:19
-
-
Save ecto/7324775 to your computer and use it in GitHub Desktop.
Revisions
-
ecto revised this gist
Nov 5, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ var net = require('net'); var url = require('url'); // edit this var conString = 'tcp://crypton_test_user:crypton_test_user_password@localhost:5432/crypton_test'; // default var config = parse(conString); -
ecto renamed this gist
Nov 5, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ecto created this gist
Nov 5, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ ~ → cat testConnection.js var net = require('net'); var url = require('url'); // edit this (password) var conString = 'tcp://crypton_test_user:crypton_test_user_password@localhost:5432/crypton_test'; // default var config = parse(conString); console.log(config); var stream = new net.Stream(); stream.on('connect', function () { console.log('connected', arguments); }); stream.on('data', function () { console.log('data', arguments); }); stream.on('error', function () { console.log('error', arguments); }); stream.on('end', function () { console.log('end', arguments); }); stream.connect(config.port, config.host); // Below is code from the node-postgres module function parse (str) { //unix socket if(str.charAt(0) === '/') { return { host: str }; } // url parse expects spaces encoded as %20 str = encodeURI(str); var result = url.parse(str); var config = {}; config.host = result.hostname; config.database = result.pathname ? result.pathname.slice(1) : null; var auth = (result.auth || ':').split(':'); config.user = auth[0]; config.password = auth[1]; config.port = result.port; return config; }; ~ → node testConnection.js { host: 'localhost', database: 'crypton_test', user: 'crypton_test_user', password: 'crypton_test_user_password', port: '5432' } connected {} ^C%