Skip to content

Instantly share code, notes, and snippets.

View fuzzyfox's full-sized avatar

William Duyck fuzzyfox

View GitHub Profile
@fuzzyfox
fuzzyfox / server.js
Last active August 29, 2015 13:56 — forked from kentbrew/tiny-web-server.js
JavaScript: a simple, tiny web server for nodejs.
// hat-tip to [Kent Brewster](https://gist.github.com/kentbrew), mod to allow
// commandline usage: `node server.js {port} {rootdir}`
// hey, everybody! it's a tiny Web server!
// INSTALL: `npm install mime colors`
// instead of a bunch of foo = reqire("foo")
// list our required modules and loop through
var r = [ "fs", "http", "mime", "path", "url", "colors" ];
@fuzzyfox
fuzzyfox / jsdiff.js
Created October 15, 2013 16:13 — forked from mbijon/jsdiff.js
JavaScript: Diff Algorithm
/*
* Javascript Diff Algorithm
* By John Resig (http://ejohn.org/)
* Modified by Chu Alan "sprite"
*
* Released under the MIT license.
*
* More Info:
* http://ejohn.org/projects/javascript-diff-algorithm/
*/
@fuzzyfox
fuzzyfox / pubsub.jquery.js
Last active December 19, 2015 15:58
JavaScript: Sexy PubSub
// Works in modern browsers + IE9, but Modernizr has a polyfill baked in for function.bind.
// Hat tip Paul Irish
var o = $( {} );
$.subscribe = o.on.bind(o);
$.unsubscribe = o.off.bind(o);
$.publish = o.trigger.bind(o);
@fuzzyfox
fuzzyfox / dominant-color.js
Created July 11, 2013 17:49 — forked from leibovic/dominant-color.js
JavaScript: Dominant Color
function getDominantColor(aImg) {
let canvas = document.createElement("canvas");
canvas.height = aImg.height;
canvas.width = aImg.width;
let context = canvas.getContext("2d");
context.drawImage(aImg, 0, 0);
// keep track of how many times a color appears in the image
let colorCount = {};
@fuzzyfox
fuzzyfox / data-markdown.user.js
Created June 23, 2013 00:45 — forked from paulirish/data-markdown.user.js
JavaScript: [data-markdown]
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.