Skip to content

Instantly share code, notes, and snippets.

View jbgutierrez's full-sized avatar

Javier Blanco Gutiérrez jbgutierrez

View GitHub Profile
@jbgutierrez
jbgutierrez / gist:974079
Created May 16, 2011 08:14
Git history rewrite (fix a bad commit)
git tag bad HASH
git co bad
git commit --ammend
git rebase --onto HEAD bad master
git tag -d bad
@jbgutierrez
jbgutierrez / gist:1501179
Created December 20, 2011 10:47
closures
var tmp = 1;
function foo(x) {
var tmp = 2;
return function (y) {
alert(x + y + (++tmp));
}
}
var bar = foo(3);
bar(tmp);
bar(tmp);
@jbgutierrez
jbgutierrez / media-query-ie-fallback.html
Created January 25, 2012 10:39
Media querys IE fallback
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Media querys IE fallback</title>
<style>
p {
color: blue;
}
<!DOCTYPE HTML>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Events Flow</title>
<style type="text/css" media="screen">
div {
background-color: #ddd;
padding: 40px;
border: 1px solid white;
}
@jbgutierrez
jbgutierrez / AClass.js
Created April 3, 2012 08:20
Idea para contextualizar las llamadas a console.log
var AClass = new Class({
Implements: [ExtendedLogger],
initialize: function() {
this.initLogger('AClass', {
skip: ['silentMethod'],
debug: true
});
this.silentMethod();
this.otherMethod();
},
@jbgutierrez
jbgutierrez / metaprograming_example.coffee
Created July 3, 2012 09:17
Metaprogramación con Coffescript
Function::hasProperties = (properties) ->
self = @
self.prototype.properties = {}
definePropertie = (key, value) ->
self.prototype.properties[key] = value
self.prototype[key] = (newValue) ->
@properties[key] = newValue
@
for key, value of properties
definePropertie key, value
@jbgutierrez
jbgutierrez / index.html
Created September 19, 2012 11:00
HTMLElement.click behaviour
<a id='clickMe' href='#'>Click me</a>​
@jbgutierrez
jbgutierrez / app.coffee
Last active December 14, 2015 04:29
Laboratorio de yeoman y angular (http://yoplay.jbgutierrez.info)
String::pad = (l, s) ->
if (l -= @length) > 0
(s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length)
else
@
app = angular.module "yoplayApp", ["ngResource"]
app.factory "myHttpInterceptor", ["$q", "$window", "$rootScope", ($q, $window, $rootScope) ->
(promise) ->
@jbgutierrez
jbgutierrez / EJSRenderer.java
Last active May 25, 2021 06:37
Java + EJS + I18n
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import org.apache.commons.lang.StringEscapeUtils;
import org.codehaus.jackson.map.ObjectMapper;
import java.io.ByteArrayOutputStream;
@jbgutierrez
jbgutierrez / gist:5764369
Created June 12, 2013 10:55
Harmony Generators vs Promisses Libs
var step = 0;
async.waterfall([
function (next){
step = 1;
getJson('/country', function(data) { next(null, data); });
},
function (country, next){
step = 2;
getJson('/weather', function(data) { next(null, country, data); });