Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

<script>
var dojoConfig = {
packages: [
{
name: 'storehouse',
location: '../storehouse'
}
]
};
</script>
@jensarps
jensarps / detectIDB.js
Last active April 16, 2019 12:35
Script to detect buggy IndexedDB implementations
(function (name, definition, global) {
if (typeof define === 'function') {
define(definition);
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = definition();
} else {
global[name] = definition();
}
})('detectIDB', function () {
@jensarps
jensarps / dieassert.js
Created May 10, 2012 08:50 — forked from jeromeetienne/dieassert.js
a console.assert which actually stop the execution
/**
* [Forked from https://gist.github.com/2651899]
*
* A console.assert which actually stop the exectution.
* default console.assert() is a plain display, such as console.log() or console.error();
* It doesnt stop the execution like assert() is meant to do. This is a little code to
* "workaround this limitation" :)
*
* Usage:
* console.assert(foo === bar); // Will throw if not equal
@jensarps
jensarps / closure-compiler-config-2.js
Last active December 20, 2015 03:19
Snippets from my post on creating dynamic/configurable builds with Grunt and Closure Compiler.
//configure closure compiler
var closureFiles = handlerClassNames.map(function (name) {
return 'src/' + name + '.js';
});
closureFiles.unshift('src/InputController.js');
closureFiles.push('build/bundle.js');
/* ... */
grunt.config.set('closure-compiler.bundle', {
closurePath: 'lib/closure',
jsOutputFile: 'build/input-controller.js',
@jensarps
jensarps / gplus-comments.html
Created April 24, 2013 17:20
Use this markup to add Google+ comments to your blog/whatever. Oh, and don't forget to put the width and url in there.
<div class="g-comments"
data-href="{put-your-url-here}"
data-width="{put-your-container-width-here}"
data-first_party_property="BLOGGER"
data-view_type="FILTERED_POSTMOD"
></div>
<script type="text/javascript">
(function() {
var gp = document.createElement('script'); gp.type = 'text/javascript'; gp.async = true;
var SPEECH = 'speech';
var bindings = {
/* ... */
fullSpeed: {
device: SPEECH,
inputId: 'full speed'
},
stop: {
@jensarps
jensarps / puntMany.js
Created February 27, 2013 09:59
A putAll / putMany convenience method for IDBWrapper
/**
* Takes an array of data objects to store and calls IDBWrapper's batch() method
*
* @param {Array} dataArray An array of objects to be stored
* @param {Function} [onSuccess] Gets called if the operation was successful
* @param {onError} [onError] Gets called if an error occurred
*/
function putMany (dataArray, onSuccess, onError) {
var preparedData = dataArray.map(function(dataObject){
@jensarps
jensarps / example-1.js
Created November 13, 2012 14:16
Examples for IDBWrapper Tutorial, Part 2
var onItem = function (item) {
console.log('got item:', item);
};
var onEnd = function (item) {
console.log('All done.');
};
customers.iterate(onItem, {
order: 'DESC',
onEnd: onEnd
@jensarps
jensarps / iterate-with-keyrange.js
Created November 13, 2012 14:03
Code for IDBWrapper Tutorial, Part 2
customers.iterate(onItem, {
index: 'lastname',
keyRange: myKeyRange,
order: 'ASC',
filterDuplicates: false,
writeAccess: false,
onEnd: onEndCallback,
onError: onErrorCallback
});
@jensarps
jensarps / connect.js
Created August 9, 2012 11:07
Mouse-Picking Collada Models with THREE.js
container.addEventListener('click', function (evt) {
// The user has clicked; let's note this event
// and the click's coordinates so that we can
// react to it in the render loop
clickInfo.userHasClicked = true;
clickInfo.x = evt.clientX;
clickInfo.y = evt.clientY;
}, false);