Skip to content

Instantly share code, notes, and snippets.

@ajoslin
Created April 23, 2016 16:35
Show Gist options
  • Save ajoslin/e1b61705dbb4a6318dcea35c19955233 to your computer and use it in GitHub Desktop.
Save ajoslin/e1b61705dbb4a6318dcea35c19955233 to your computer and use it in GitHub Desktop.
requirebin sketch
var murmur = require('murmurhash')
var cases = [
{ color: '#0008d0' },
{ color: '#000f82' }
]
document.body.innerHTML = cases
.map(JSON.stringify.bind(JSON))
.map(murmur)
.join('<br />')
setTimeout(function(){require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({murmurhash:[function(require,module,exports){(function(){var _global=this;function MurmurHashV2(str,seed){var l=str.length,h=seed^l,i=0,k;while(l>=4){k=str.charCodeAt(i)&255|(str.charCodeAt(++i)&255)<<8|(str.charCodeAt(++i)&255)<<16|(str.charCodeAt(++i)&255)<<24;k=(k&65535)*1540483477+(((k>>>16)*1540483477&65535)<<16);k^=k>>>24;k=(k&65535)*1540483477+(((k>>>16)*1540483477&65535)<<16);h=(h&65535)*1540483477+(((h>>>16)*1540483477&65535)<<16)^k;l-=4;++i}switch(l){case 3:h^=(str.charCodeAt(i+2)&255)<<16;case 2:h^=(str.charCodeAt(i+1)&255)<<8;case 1:h^=str.charCodeAt(i)&255;h=(h&65535)*1540483477+(((h>>>16)*1540483477&65535)<<16)}h^=h>>>13;h=(h&65535)*1540483477+(((h>>>16)*1540483477&65535)<<16);h^=h>>>15;return h>>>0}function MurmurHashV3(key,seed){var remainder,bytes,h1,h1b,c1,c1b,c2,c2b,k1,i;remainder=key.length&3;bytes=key.length-remainder;h1=seed;c1=3432918353;c2=461845907;i=0;while(i<bytes){k1=key.charCodeAt(i)&255|(key.charCodeAt(++i)&255)<<8|(key.charCodeAt(++i)&255)<<16|(key.charCodeAt(++i)&255)<<24;++i;k1=(k1&65535)*c1+(((k1>>>16)*c1&65535)<<16)&4294967295;k1=k1<<15|k1>>>17;k1=(k1&65535)*c2+(((k1>>>16)*c2&65535)<<16)&4294967295;h1^=k1;h1=h1<<13|h1>>>19;h1b=(h1&65535)*5+(((h1>>>16)*5&65535)<<16)&4294967295;h1=(h1b&65535)+27492+(((h1b>>>16)+58964&65535)<<16)}k1=0;switch(remainder){case 3:k1^=(key.charCodeAt(i+2)&255)<<16;case 2:k1^=(key.charCodeAt(i+1)&255)<<8;case 1:k1^=key.charCodeAt(i)&255;k1=(k1&65535)*c1+(((k1>>>16)*c1&65535)<<16)&4294967295;k1=k1<<15|k1>>>17;k1=(k1&65535)*c2+(((k1>>>16)*c2&65535)<<16)&4294967295;h1^=k1}h1^=key.length;h1^=h1>>>16;h1=(h1&65535)*2246822507+(((h1>>>16)*2246822507&65535)<<16)&4294967295;h1^=h1>>>13;h1=(h1&65535)*3266489909+(((h1>>>16)*3266489909&65535)<<16)&4294967295;h1^=h1>>>16;return h1>>>0}var murmur=MurmurHashV3;murmur.v2=MurmurHashV2;murmur.v3=MurmurHashV3;if(typeof module!="undefined"){module.exports=murmur}else{var _previousRoot=_global.murmur;murmur.noConflict=function(){_global.murmur=_previousRoot;return murmur};_global.murmur=murmur}})()},{}]},{},[]);var murmur=require("murmurhash");var cases=[{color:"#0008d0"},{color:"#000f82"}];document.body.innerHTML=cases.map(JSON.stringify.bind(JSON)).map(murmur).join("<br />")},0);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"murmurhash": "0.0.2"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment