Skip to content

Instantly share code, notes, and snippets.

View nelix's full-sized avatar
🎯
Focusing

Nathan Hutchision nelix

🎯
Focusing
View GitHub Profile
@creationix
creationix / app.js
Created January 2, 2011 07:27
Static file server for creationix.com (launches with spark to set port 80 and uid to nobody)
module.exports = require('http').createServer(require('stack')(
require('creationix/log')(),
require('creationix/static')('/', __dirname, "index.html")
))
@creationix
creationix / find.js
Created December 24, 2010 23:49
Find all references to an object.
function find(root, obj) {
var seen = [];
function search(root, name, depth) {
if (root === obj) {
console.log(name);
return;
}
if (!depth) { return; }
if (seen.indexOf(root) >= 0) { return; }
if (typeof root !== "object") { return; }
@nickfloyd
nickfloyd / create_merge_branches
Created December 21, 2010 17:32
To create and then merge changes into a branch
ex.
git checkout origin master
git pull origin master
--create branch and track master
git checkout -b f1-1234 origin/master
--make changes
--resolve conflicts, DO NOT PUSH branch, the merge is just to resolve conflicts
/*!
* jQuery Tiny Pub/Sub - v0.X - 11/18/2010
* http://benalman.com/
*
* Original Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Made awesome by Rick Waldron
*
function Client(config) {
if (!(this instanceof Client)) {
return new Client(config);
}
}
<!DOCTYPE HTML>
<html>
<head>
<script src="sharedworker.multi-connect.renderer.js"></script>
</head>
<body>
<pre id="shared-worker-log"></pre>
</body>
</html>
var
PARALLEL_CONNECTS = 10,
http = require('http'),
sys = require('sys'),
connectionCount = 0,
messageCount = 0;
lastMessages = 0;
function addClient() {
var fs = require('fs'),
sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
checkBalanceFile(req, res);
}).listen(8000);
function checkBalanceFile(req, res) {
fs.stat("balance", function(err) {
@creationix
creationix / mazemaker.js
Created November 5, 2009 22:32
Maze generator for node.js
Array.prototype.shuffle = function () {
var i, j, tempi, tempj;
i = this.length;
if ( i === 0 ) {
return false;
}
while ( --i ) {
j = Math.floor( Math.random() * ( i + 1 ) );
tempi = this[i];