Skip to content

Instantly share code, notes, and snippets.

View Couto's full-sized avatar
👽
Did you raid area 51?

Luís Couto Couto

👽
Did you raid area 51?
View GitHub Profile

Keybase proof

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:

@Couto
Couto / list.md
Last active August 29, 2015 14:05
golang tools to write web applications/API

Keybase proof

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 6615 D57E 7D20 7B0C 537C ADDF 7C62 5B90 A681 6DA3

To claim this, I am signing this object:

@Couto
Couto / credits.js
Last active August 29, 2015 14:17
Save the credits from a movie.
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'
@Couto
Couto / what-forces-layout.md
Last active September 19, 2015 10:55 — forked from paulirish/what-forces-layout.md
What forces layout/reflow in Chrome. The comprehensive list.

What forces layout / reflow

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.

Element

Box metrics
  • 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";
}
}
@Couto
Couto / dabblet.css
Created January 27, 2012 01:43
Button with Arrow
/**
* Button with Arrow
*/
body {
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
}
@Couto
Couto / walk.js
Created April 17, 2012 19:22
Walk along an array of asynchronous functions
/**
* 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
@Couto
Couto / namespace.js
Created May 10, 2012 14:21
Small & Recursive Namespace function
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()));