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 / 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];
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) {
var
PARALLEL_CONNECTS = 10,
http = require('http'),
sys = require('sys'),
connectionCount = 0,
messageCount = 0;
lastMessages = 0;
function addClient() {
<!DOCTYPE HTML>
<html>
<head>
<script src="sharedworker.multi-connect.renderer.js"></script>
</head>
<body>
<pre id="shared-worker-log"></pre>
</body>
</html>
function Client(config) {
if (!(this instanceof Client)) {
return new Client(config);
}
}
/*!
* 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
*
@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
@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; }
@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")
))
@brandonb927
brandonb927 / gist:4149074
Last active December 11, 2016 19:23
Javascript: Async Gist loading
/**
* Shamelessly stolen from http://blog.jeansebtr.com/post/36590722386/async-loading-of-githubs-gists-without-jquery-31-loc
*
* Use like this: <gist data-username="brandonb927" data-id="4138162" data-file="gists2.js"><a href="https://gist.github.com/brandonb927/4138162#file_gists2.js">Gist</a></gist>
* UPDATED 02/06/2013: Github implemented Namespaced Gists a few hours ago, which means gist.github.com/4149074 now redirects to gist.github.com/brandonb927/4149074 and I have updated the gist to reflect this new format
*
*/
(function(){
var gists = document.getElementsByTagName('gist');