Skip to content

Instantly share code, notes, and snippets.

View gaboelnuevo's full-sized avatar

Gabriel S. L gaboelnuevo

View GitHub Profile
@gaboelnuevo
gaboelnuevo / gist:7b48ea763a3665f0abfa
Created September 13, 2015 23:33
mixin: timestamp loopback
module.exports = function(Model, options) {
// Model is the model class
// options is an object containing the config properties from model definition
Model.defineProperty('created', {type: Date, default: '$now'});
Model.defineProperty('modified', {type: Date, default: '$now'});
}
@gaboelnuevo
gaboelnuevo / calculate-aspect-ratio.js
Created September 3, 2015 22:30
Calculate a ratio from two numbers
//calculate aspect ratio
// Via: http://stackoverflow.com/questions/1186414/whats-the-algorithm-to-calculate-aspect-ratio-i-need-an-output-like-43-169
function gcd (a, b) {
return (b == 0) ? a : gcd (b, a%b);
}
var w = screen.width;
var h = screen.height;
var r = gcd (w, h);
console.log("Dimensions = " + w + " x " + h);