Skip to content

Instantly share code, notes, and snippets.

View ncb000gt's full-sized avatar
💭
Slapping keyboard...

Nick Campbell ncb000gt

💭
Slapping keyboard...
View GitHub Profile
@ncb000gt
ncb000gt / tmp
Created December 11, 2009 20:56
0 0 * * * rm -Rf /home/me/tmp/*
var sys = require("sys"),
http = require("http"),
fs = require('fs'),
path = require('path');
http.createServer(function(request, response) {
var headers = { "Content-Type": "text/html" };
var filename = path.join(process.cwd(), 'work/terminix/knox/index.html');
path.exists(filename, function(exists) {
if(!exists) {
var sys = require('sys')
,events = require('events')
function Eventer() {
events.EventEmitter.call(this);
}
sys.inherits(Eventer, events.EventEmitter);
var eventer = new Eventer();
it('can haz cloned node', function() {
var gchild_string = '<grandchild from="julie numar">with love</grandchild>';
var doc1_string = [
'<?xml version="1.0" encoding="UTF-8"?>',
'<root><child to="wongfoo">'+gchild_string+'</child><sibling>with content!</sibling></root>',
''
].join("\n");
var doc2_string = [
'<?xml version="1.0" encoding="UTF-8"?>',
From 37f3ea740829e95e733951aab8def5d525a0bc29 Mon Sep 17 00:00:00 2001
From: Nick Campbell <ncampbell@siteworx.com>
Date: Thu, 16 Dec 2010 10:54:04 -0500
Subject: [PATCH] Match lowercased protocols so that protocols can be specified in any way.
Signed-off-by: Nick Campbell <ncampbell@siteworx.com>
---
lib/url.js | 18 +++++++++++-------
test/simple/test-url.js | 6 ++++++
2 files changed, 17 insertions(+), 7 deletions(-)
@ncb000gt
ncb000gt / gunzip-htmlparser-test.js
Created January 6, 2011 20:49
Make a request, gunzip with node-compress and parse to dom with node-htmlparser.
var htmlparser = require('htmlparser'),
sys = require('sys'),
http = require('http'),
compress_lib = require('compress'),
gunzip = new compress_lib.GunzipStream();
var domain = 'www.example.com'; //TODO: CHANGE ME
var rawHtml = "Xyz <script language= javascript>var foo = '<<bar>>';< / script><!--<!-- Waah! -- -->";
var handler = new htmlparser.DefaultHandler(function (error, dom) {
@ncb000gt
ncb000gt / nodeunit-testcase.js
Created February 15, 2011 20:30
Nodeunit setUp and tearDown wrapping.
var nodeunit = require('nodeunit');
function testCase(suite){
suite.setUp = function(test){
// your stuff
};
suite.tearDown = function(test){
// your stuff
};
return testCase.super_.call(this, suite);
@ncb000gt
ncb000gt / app.js
Created February 15, 2011 21:38 — forked from mauritslamers/app.js
App.prototype.save = function() {
var that = this,
stylesheets = [],
scripts = [],
fw,i,len,
stylesheet, script, html, savr;
var Saver = function(app, file) {
var that = this;
App.prototype.save = function() {
var that = this,
stylesheets = [],
scripts = [],
fw,i,len,
stylesheet, script, html, savr;
var Saver = function(app, file) {
var that = this;
@ncb000gt
ncb000gt / looperator.js
Created February 16, 2011 15:50
Async dep example with Cradle.
var data = [1,2,3,4,5,6,7,8,9,10],
len = data.length,
count = 0;
function f() {
//do your dependent stuff here
}
data.forEach(function(i) {
db.save(key, {val: i}, function(err, res) {