Skip to content

Instantly share code, notes, and snippets.

View amcdnl's full-sized avatar

Austin amcdnl

View GitHub Profile
/**
* SystemJS hook that caches load and transpilation results of sources that haven't changed in IndexedDB storage.
* In Chrome dev tools the cache is easily managed under Resources > IndexedDB > jspm
* There's a global dependency on Dexie.js (ex: //npmcdn.com/[email protected]/dist/dexie.min.js)
* Add the following to your index.ghtml <script src="http://npmcdn.com/[email protected]/dist/dexie.min.js"></script>
* Adapted from https://gist.github.com/ineentho/70303c2ccdb69ad3661d
*/
;(function(){
var db = new Dexie("jspm");
db.version(1).stores({ files: "&url,format,hash,contents" });
@amcdnl
amcdnl / diffList.js
Last active August 29, 2015 14:06 — forked from katowulf/diffList.js
/**
* A diff utility that compares arrays and returns a list of added, removed, and updated items
*
* Returns an object with two methods:
* diff: do a one-time diff of two arrays
* watch: observe a variable on scope and report any changes to a callback
*
* Invoking the factory is done like so:
* <code>
* function(listDiff) {
@amcdnl
amcdnl / diffList.js
Last active August 29, 2015 14:06 — forked from katowulf/diffList.js
define(['angular'], function(angular) {
// add a few helpers
Array.prototype.union = function(a){
var r = this.slice(0);
a.forEach(function(i) { if (r.indexOf(i) < 0) r.push(i); });
return r;
};
Array.prototype.diff = function(a){
@amcdnl
amcdnl / gist:3822982
Created October 2, 2012 20:08 — forked from JeffreyWay/gist:1608901
Inline Web Workers
<!doctype html>
<html>
<head>
<title>Web Workers</title>
</head>
<body>
<script id="worker" type="app/worker">
addEventListener('message', function() {
postMessage('What up, sucka.');