Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View amatiasq's full-sized avatar

A. Matías Quezada amatiasq

View GitHub Profile
@amatiasq
amatiasq / race-condition.js
Created March 11, 2015 11:19
Solves a race condition issue on a Promise function: http://jsfiddle.net/amatiasq/zhmz8xdx/
function raceCondition(fn) {
var counter = 0;
return function() {
var index = ++counter;
var prom = fn.apply(this, arguments);
return new Promise(function(resolve, reject) {
prom.then(function(value) {
if (isLast()) resolve(value);
@amatiasq
amatiasq / eslint.yaml
Last active August 29, 2015 14:20
ESLint conf
env:
browser: true
globals:
define: true
rules:
# possible errors
comma-dangle: [1, "always-multiline"]
no-cond-assign: [2, "except-parens"]
@amatiasq
amatiasq / map.js
Last active August 29, 2015 14:23
(function() {
'use strict';
if (window.Map) return;
window.Map = FakeMap;
function FakeMap() {
this._keys = [];
this._values = [];
}
@amatiasq
amatiasq / mq-allow-external-clone.js
Created May 28, 2015 09:56
Directive to allow 3rd party libraries to clone angular nodes.
angular.module('my-module')
.directive('mqAllowExternalClone', function($compile) {
return {
link: link,
};
function link(scope, elem, attr) {
var element = elem[0];
var original = element.cloneNode;
element.cloneNode = patch;
@amatiasq
amatiasq / advice.js
Created June 11, 2012 13:46 — forked from angus-c/advice.js
simplest advice functional mixin
// usage
withAdvice.call(targetObject);
var withSomething = function() {
this.wrap('walk', function() {
// before
this.base();
// after
});
};
@amatiasq
amatiasq / HurdlesHack.js
Created August 7, 2012 13:50
Hack today's Google's Doodle (press numpad 0 to start)
function press(key) {
document.getElementById("hplogo").onkeydown({
keyCode:key,
preventDefault:function() { }
});
}
var interval;
document.addEventListener('keydown', function(e) {
if (e.keyCode !== 96)
@amatiasq
amatiasq / extend.base.js
Last active October 12, 2015 14:07
Simple base class with this.base() to call parent mehtod
/**
* Provides:
* Function extend(Function parent, Object config);
*
* It extends constructors with it's methods
* Also provides to every method who overwrites another one
* with a this.base() method to invoke overwrote method.
*
* Created constructor has methods
* .extend(Object config)
/* eslint no-multi-spaces:0 */
(function(root) {
var Firebase = root.Firebase;
var toArray = Function.prototype.call.bind(Array.prototype.slice);
window.FirebasePromise = FirebasePromise;
function DisconnectWrapper(disconnect) {
this._ref = disconnect;
}
Babel
Base16 color schemes
Cucumber
GitSavvy
Grunt
Gulp
Javsacript Beautify
JavascriptNext - ES6 Syntax
jsFormat
LESS
@amatiasq
amatiasq / extensions.js
Last active December 13, 2015 22:49
How to dominate Javascript's world
(function extensions() {
function arr(val) {
return Array.prototype.slice.call(val);
}
function extend(Type, prototype) {
function E(val) { this.val = val }
E.prototype = prototype;
prototype.constructor = E;