Skip to content

Instantly share code, notes, and snippets.

@livingston
livingston / tracer.js
Created June 11, 2010 07:08
A JavaScript tracer utility in 2kb
/* tracer.js - A tracer utility in 2kb
*
* @author Angus Croll
* http://javascriptweblog.wordpress.com/2010/06/01/a-tracer-utility-in-2kb/
*/
String.prototype.times = function(count) {
return count < 1 ? '' : new Array(count + 1).join(this);
}
@ariefmulya
ariefmulya / myrss_feedreader.php
Created October 30, 2010 17:19
Multiple RSS feeds reading applications
<?php
/*
*
* Copyright (C) 2010 - Arief M Utama <me@arief-mulya.com>
* All Rights Reserved.
*
* Feeds Reader - Multiple feeds reading
*
* Version: 0.9
* Requirement: PHP >= 5.2
@indexzero
indexzero / mockreadwritestream.js
Created May 20, 2011 06:26
A mock stream for node.js that is both Readable and Writeable.
var events = require('events'),
util = require('util');
var MockReadWriteStream = helpers.MockReadWriteStream = function () {
//
// No need to do anything here, it's just a mock.
//
};
util.inherits(MockReadWriteStream, events.EventEmitter);
@Marak
Marak / mockreadwritestream.js
Created May 20, 2011 06:29 — forked from indexzero/mockreadwritestream.js
A mock stream for node.js that is both Readable and Writeable.
var events = require('events'),
util = require('util');
var MockReadWriteStream = helpers.MockReadWriteStream = function () {
//
// No need to do anything here, it's just a mock.
//
};
util.inherits(MockReadWriteStream, events.EventEmitter);
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@kig
kig / workcrew.js
Created September 2, 2011 11:03
WorkCrew - a WebWorker work queue library
/*
WorkCrew - a WebWorker work queue library
Usage:
// Create an 8 worker pool using worker.js.
var crew = new WorkCrew('worker.js', 8);
// Do something whenever a job is completed.
// The result object structure is
@mjackson
mjackson / mockstream.js
Created September 7, 2011 17:31
A mock stream wrapper for node.js
var util = require("util"),
Stream = require("stream").Stream;
module.exports = MockStream;
/**
* A constructor that inherits from Stream and emits data from the given
* `source`. If it's a Stream it will be piped through to this stream.
* Otherwise, it should be a string or a Buffer which will be emitted by this
* stream as soon as possible.
@bergie
bergie / .gitignore
Created September 19, 2011 15:50
Node.js email handling examples
config.json
reading-image.png
@danott
danott / social.js
Created November 28, 2011 22:04
Replace Twitter/Facebook/G+ scripts with one Modernizr.load call.
Modernizr.load(
[ '//platform.twitter.com/widgets.js'
, '//apis.google.com/js/plusone.js'
, { test: document.getElementById('facebook-jssdk')
, nope: '//connect.facebook.net/en_US/all.js#xfbml=1'
}
]);
/* When Using Modernizr, the above replaces all the social includes below
@mtrpcic
mtrpcic / Testcase.html
Created December 27, 2011 23:41
Code examples for Issue #13 on mtrpcic/pathjs
/*
The following is a concise outline of the test environment that I've set up to test the outcome described in
Issue #13 on the PathJS master branch. This setup is running on a Rails server.
https://github.com/mtrpcic/pathjs/issues/13
*/
// Step 1 - Server, Routes, and Data
// I set up a Rails 3.1.0 server with a 'Widget' model, and the following test route: