Skip to content

Instantly share code, notes, and snippets.

View ItsAsbreuk's full-sized avatar

Marco Asbreuk ItsAsbreuk

View GitHub Profile
@lsmith
lsmith / gist:6664382
Last active December 23, 2015 16:49
Custom event hacked up to support defaultFn that can return a promise to delay after subscribers. POC, mostly untested, so YMMV.
/*global SM:true*/
'use strict';
// Publish a very special, promise-compatible event that supports the default
// function behavior to chain on internally created promises before executing
// the after() subs. on() subs can still e.preventDefault(), which will
// reject the promise and thus skip the default behavior and after() subs.
var asyncEvent = eventTarget.publish('foo');
asyncEvent._firing = new Y.Promise(function (resolve) { resolve(); });
@juandopazo
juandopazo / gist:5405383
Last active December 16, 2015 08:19
Storage module design and API for review

Storage

Motivation

There are 3 major types of storage is browsers up to date:

  • IndexedDB. The future.
  • localStorage. Limited in size and can be observed through the storage event.
  • WebSQL. Dropped by the W3C but it's still very present in the wild, with notable platforms like iOS and PhoneGap.
@Satyam
Satyam / leak-test.js
Last active December 16, 2015 08:18
This is related to this conversation: https://groups.google.com/forum/?hl=en&fromgroups=#!topic/yui-contrib/hP-Qg2jLQXo. It logs DOM Nodes, cached Node instances and DOM events left behind after a test case in YUI Test. It takes a snapshot of short handles that can help identify them in the setUp() function of each test case and compares them wi…
// How to use it.
//
// This code is based on the template file that YOGI produces for unit testing
// when a module is created. Only the main changes to it are listed.
//
// Add a reference to the module in the YUI configuration section so it can locate it
// It's up to you where you put it.
YUI({
groups: {
leaks: {
@lsmith
lsmith / gist:5271961
Last active December 15, 2015 14:09
var dataPromise = new Y.Promise(function (resolve, reject) {
var data = [];
function getData(offset) {
return new Y.Promise(function (dataResolve, dataReject) {
Y.io('getdata.php?offset=' + offset, {
on: {
success: function (id, response) {
var dataset = Y.JSON.parse(response.responseText);