Skip to content

Instantly share code, notes, and snippets.

View gonzaloruizdevilla's full-sized avatar

Gonzalo Ruiz de Villa gonzaloruizdevilla

  • GFT
  • Madrid, Spain
View GitHub Profile
@gonzaloruizdevilla
gonzaloruizdevilla / map.js
Created January 24, 2012 13:19 — forked from Jxck/map.js
Hadoop Streaming with Node.js
#!/usr/bin/env node
var stdin = process.openStdin();
var stdout = process.stdout;
var input = '';
stdin.setEncoding('utf8');
stdin.on('data', function(data) {
if (data) {
input += data;
@gonzaloruizdevilla
gonzaloruizdevilla / LICENSE.txt
Created March 3, 2012 20:33 — forked from aemkei/LICENSE.txt
Lorenz Attractor - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@gonzaloruizdevilla
gonzaloruizdevilla / gist:2138066
Created March 20, 2012 16:42
Integer to string. Bad way
2.toString(); // raises SyntaxError​​
@gonzaloruizdevilla
gonzaloruizdevilla / gist:2138095
Created March 20, 2012 16:45
Integer to string. Good way
2..toString(); // el segundo punto se reconoce correctamente
2 .toString(); // fíjate en el espacio a la izquierda del punto
(2).toString(); // los paréntesis fuerzan a que el número 2 se evalúe primero
@gonzaloruizdevilla
gonzaloruizdevilla / gist:2174384
Created March 23, 2012 20:00
requestAnimationFrame sin polyfill
(function loopAnimacion(){
window.requestAnimationFrame(loopAnimacion);
hazLosCalculos();
})();
@gonzaloruizdevilla
gonzaloruizdevilla / gist:2174427
Created March 23, 2012 20:04
requestAnimationFrame con polyfill
// shim con fallback a setTimeout
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( callback ){
window.setTimeout(callback, 1000 / 60);
};
@gonzaloruizdevilla
gonzaloruizdevilla / rAF.js
Created March 23, 2012 20:11 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
@gonzaloruizdevilla
gonzaloruizdevilla / gist:2199269
Created March 25, 2012 19:39
requestAnimationFrame polyfill bien compacta
window.requestAnimFrame = (function(a,b){while(a--&&!(b=this["oR0msR0mozR0webkitR0r".split(0)[a]+"equestAnimationFrame"]));return b||function(a){setTimeout(a,15)}}(5));
// uso:
(function loopAnimacion(){
requestAnimFrame(loopAnimacion);
hazLosCalculos();
})();
@gonzaloruizdevilla
gonzaloruizdevilla / comma-first-var.js
Created April 16, 2012 10:23 — forked from isaacs/comma-first-var.js
Una mejor convención para codificar listas y literales de objetos en JavaScript
// Ver comentarios más abajo.
// Este ejemplo está basado en el original de
// Isaac Z. Schlueter, aka isaacs
// estilo estándar
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
@gonzaloruizdevilla
gonzaloruizdevilla / REPL-javascript.js
Created May 2, 2012 09:48
REPL y estilo coma primero en javascript
//El REPL de node.js no interpreta correctamente esto:
var a = 1
, b = 2
, c = 3;
//En cambio esto funciona bien:
var a = 1,