I hereby claim:
- I am couto on github.
- I am couto (https://keybase.io/couto) on keybase.
- I have a public key whose fingerprint is C230 B192 2E7F FADA B169 3BBC B38A BA95 DEEA 9F1B
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
var Promise = require('bluebird'), | |
Sequelize = require('sequelize'), | |
sequelize = new Sequelize('database', 'username', 'password', { | |
host: 'localhost', | |
dialect: 'sqlite' | |
}); | |
/* | |
* Quick explanation: | |
* A movie has a lot of credits (jon doe is the director, jane doe is the photographer, peter doe is the hair dresser...) |
// Kinda pseudo code | |
// This script will download and resize each image to half | |
// Because the images can be RRREAAALLY big | |
// the download and resize is done sequentially (in my case, inside a child_process) | |
// to ensure that memory is released after each image. | |
// We dont know how many images there are | |
let images = [ | |
'https://flickr.com/photo/1', | |
'https://flickr.com/photo/2' |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
elem.clientLeft
, elem.clientTop
, elem.clientWidth
, elem.clientHeight
elem.getClientRects()
, elem.getBoundingClientRect()
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/ | |
var metas = document.getElementsByTagName('meta'); | |
var i; | |
if (navigator.userAgent.match(/iPhone/i)) { | |
for (i=0; i<metas.length; i++) { | |
if (metas[i].name == "viewport") { | |
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0"; | |
} | |
} |
/** | |
* Button with Arrow | |
*/ | |
body { | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
min-height:100%; | |
} |
/** | |
* walk | |
* small function to walk along an array of functions | |
* each function walked gets an extra argument | |
* that argument is a function that should be called | |
* to notify the walk function to step to the next function | |
* the arguments given at call time are passed to the next function | |
* | |
* @function | |
* @param {Array} fns Array of functions |
function namespace (ns) { | |
var parts = ns.split('.'), | |
root = window || this; | |
return (function walk (obj) { | |
if (!root[obj]) { root[obj] = {}; } | |
root = root[obj]; | |
if (parts.length) { walk(parts.shift()); } | |
return root; | |
}(parts.shift())); |