Skip to content

Instantly share code, notes, and snippets.

View samholmes's full-sized avatar

Sam Holmes samholmes

View GitHub Profile
@samholmes
samholmes / NodeIgniter Server.js
Created February 9, 2011 05:20
My attempt in making a CodeIgniter routing server.
var http = require('http');
var util = require('util');
var path = require('path');
var chromesMinimumByteFix = " ";
var server = http.createServer(function(req, res){
var pathParts = req.url.split('/');
pathParts.shift();
ReferenceError: module is not defined
at IncomingMessage.anonymous (eval at <anonymous> (/usr/local/lib/node/.npm/ejs/0.3.0/package/lib/ejs/index.js:139:14))
at IncomingMessage.<anonymous> (/usr/local/lib/node/.npm/ejs/0.3.0/package/lib/ejs/index.js:141:19)
at Object.render (/usr/local/lib/node/.npm/ejs/0.3.0/package/lib/ejs/index.js:176:13)
at ServerResponse.render (/usr/local/lib/node/.npm/express/1.0.7/package/lib/express/view.js:334:22)
at ServerResponse.partial (/usr/local/lib/node/.npm/express/1.0.7/package/lib/express/view.js:200:17)
at Object.<anonymous> (/usr/local/lib/node/.npm/express/1.0.7/package/lib/express/view.js:311:25)
at IncomingMessage.anonymous (eval at <anonymous> (/usr/local/lib/node/.npm/ejs/0.3.0/package/lib/ejs/index.js:139:14))
at IncomingMessage.<anonymous> (/usr/local/lib/node/.npm/ejs/0.3.0/package/lib/ejs/index.js:141:19)
at Object.render (/usr/local/lib/node/.npm/ejs/0.3.0/package/lib/ejs/index.js:176:13)
$ npm update
npm info it worked if it ends with ok
npm info using npm@0.3.0-6
npm info using node@v0.4.0
npm info updates connect@0.5.10 resware@0.0.3 qs@0.0.6
npm info preupdate connect@0.5.10
npm info preupdate resware@0.0.3
npm info preupdate qs@0.0.6
npm ERR! gzip "--decompress" "--stdout" "/usr/local/lib/node/.npm/.cache/resware/0.0.3/package.tgz"
npm ERR! gzip "--decompress" "--stdout" "/usr/local/lib/node/.npm/.cache/resware/0.0.3/package.tgz" gzip: /usr/local/lib/node/.npm/.cache/resware/0.0.3/package.tgz: unexpected end of file
# Run each statement separately, not all at once
CREATE TABLE `posts` (
`post_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL DEFAULT '0',
`date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`active` tinyint(2) NOT NULL DEFAULT '0',
PRIMARY KEY (`post_id`)
) ENGINE=InnoDB AUTO_INCREMENT=190 DEFAULT CHARSET=utf8;
var mysql = require('mysql');
var db = new mysql.Client({
user: 'root',
password: '',
database: 'main'
});
db.connect();
$ node test.js
0.5961614400148392
0.5961614400148392
We couldn’t find that file to show.
@samholmes
samholmes / app.js
Created March 15, 2012 18:47
Shows issue using transactions on the same db connection
var http = require('http');
var mysql = require('mysql');
var db = mysql.createClient({
user: 'root',
password: 'password',
database: 'db1'
});
db.query("BEGIN"); // Start first transaction
var db = require('./exports-the-db-connection.js');
var http = require('http');
http.createServer(function(req, res){
if (req.url == '/A')
DoA();
else if (req.url == '/B')
DoB();
else
PS C:\Users\UserName\Programming\ProjectName> npm install email-templates-windows
npm http GET https://registry.npmjs.org/email-templates-windows
npm http 200 https://registry.npmjs.org/email-templates-windows
npm http GET https://registry.npmjs.org/email-templates-windows/-/email-templates-windows-0.0.1.tgz
npm http 200 https://registry.npmjs.org/email-templates-windows/-/email-templates-windows-0.0.1.tgz
npm http GET https://github.com/niftylettuce/juice/tarball/windows
npm http GET https://registry.npmjs.org/async/0.1.22
npm http GET https://registry.npmjs.org/ejs/0.7.1
npm http 304 https://registry.npmjs.org/async/0.1.22
npm http 304 https://registry.npmjs.org/ejs/0.7.1