Skip to content

Instantly share code, notes, and snippets.

View afonsomatos's full-sized avatar
🎯
Focusing

Afonso Matos afonsomatos

🎯
Focusing
  • Lisboa, Portugal
View GitHub Profile
@afonsomatos
afonsomatos / createTable.js
Last active August 29, 2015 14:22
Lightweight table creator
/*!
* Easy to use table creator
* afonsomatos <[email protected]>
*
* @param {Array} - Array containing the rows of the table
* @param {Object} [{rows: Array.length,
* padding: 2,
* marginLeft: 2,
* lineHeight: 0,
* cols: <row in most length>.length }] - Configure object
@afonsomatos
afonsomatos / getLocation.js
Created January 3, 2015 16:00
Get script file location
// Get script file location
// doesn't work for older browsers
var getScriptLocation = function() {
var fileName = "fileName";
var stack = "stack";
var stackTrace = "stacktrace";
var loc = null;
var matcher = function(stack, matchedLoc) { return loc = matchedLoc; };
@afonsomatos
afonsomatos / now.js
Created January 3, 2015 16:00
Most accurate javascript timing
// Most accurate javascript timing
now = function() {
return performance.now()||
performance.mozNow() ||
performance.msNow() ||
performance.oNow() ||
performance.webkitNow() ||
Date.now() ||
new Date().getTime();
@afonsomatos
afonsomatos / object-when.js
Last active August 29, 2015 14:12
Object.when implementation in ES5
/*!
Object-when implementation on ES5 (made by afonsomatos)
Released under the MIT license (2014-11-10)
*/
// object.when
Object.defineProperty(Object.prototype, "when", {