Skip to content

Instantly share code, notes, and snippets.

@jxav
jxav / jquery.class.js
Created December 28, 2015 18:07 — forked from jonathonbyrdziak/jquery.class.js
jQuery OOP Class: This allows you to easily create a class in Jquery.
/*!
* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*
* Extended by Jonathon Byrd to include function hooks
* https://gist.github.com/Jonathonbyrd/724083
*
* Don't forget your Shims!
* https://github.com/kriskowal/es5-shim/blob/master
@jxav
jxav / mersenne-twister.js
Created November 22, 2015 21:03 — forked from banksean/mersenne-twister.js
a Mersenne Twister implementation in javascript. Makes up for Math.random() not letting you specify a seed value.
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
@jxav
jxav / gist:adf7a7c541e6fc57cd47
Created November 22, 2015 18:48 — forked from loretoparisi/gist:c147ca437ab9d5e163b7
Using JavaScript and k-means to find the dominant colors in images
<html>
<head>
<!-- adapted from http://charlesleifer.com/blog/using-python-and-k-means-to-find-the-dominant-colors-in-images/ -->
<script type="text/javascript">
function euclidean(p1, p2) {
var s = 0;
for (var i = 0, l = p1.length; i < l; i++) {
s += Math.pow(p1[i] - p2[i], 2)
}
@jxav
jxav / gist:13cc6191ffb476ec6194
Created November 22, 2015 18:47 — forked from loretoparisi/gist:fe6e5cf889bb2c8f2099
Basic Javascript port of the MMCQ (modified median cut quantization) - quantize.js Copyright 2008 Nick Rabinowitz.
/*!
* quantize.js Copyright 2008 Nick Rabinowitz.
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
// fill out a couple protovis dependencies
/*!
* Block below copied from Protovis: http://mbostock.github.com/protovis/
* Copyright 2010 Stanford Visualization Group
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php
@jxav
jxav / SassMeister-input.scss
Created October 22, 2015 15:55 — forked from jedfoster/.gitignore
JavaScript version of Sass' mix() function
// ----
// Sass (v3.3.0.rc.1)
// Compass (v0.13.alpha.10)
// ----
body {
width: 100%;
height: 10em;
background: mix(#ff0000, #0000bb, 75);
}