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 / ExtractProperty.vim
Created May 6, 2014 22:50
Shortcut to send translation tokens to an external properties file
function! ExtractProperty()
let a_save = @a
try
let properties_file = expand('%:r').'.properties'
if filereadable(properties_file)
normal! gv"ay
let value = @a
let key = substitute(value, ".*", "\\U\\0", "")
let key = substitute(key, '\W\+', "_", "g")
if len(key) > 20
@jbgutierrez
jbgutierrez / setup-continuous-deployment-ubuntu-12.10-x86_64.sh
Last active December 27, 2015 07:59
Self-contained bash script to setup continuous deployment for nodejs apps built on top of ubuntu, git and foreman
DEPLOYER='deployer'
DEPLOYER_HOME="/home/$DEPLOYER"
PROJECT_NAME='node-js-sample'
PROJECT_REPO='https://github.com/heroku/node-js-sample.git'
# Provisining an ubuntu server
apt-get -y update
apt-get -y upgrade
apt-get -y install software-properties-common
add-apt-repository ppa:chris-lea/node.js
@jbgutierrez
jbgutierrez / mental-mapping-code-smell.html
Last active December 22, 2015 15:39
Mental mapping code smell
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Mental mapping code smell</title>
<style>
.language-flag {
float: left;
}
</style>
@jbgutierrez
jbgutierrez / git-svn-relocate.sh
Created August 29, 2013 15:25
Rewriting Git History: Relocating Subversion URLs (http://goo.gl/OgudcR)
#!/bin/sh
# Must be called with two command-line args.
# Example: git-svn-relocate.sh http://old.server https://new.server
if [ $# -ne 2 ]
then
echo "Please invoke this script with two command-line arguments (old and new SVN URLs)."
exit $E_NO_ARGS
fi
@jbgutierrez
jbgutierrez / draw_bounding_box.cpp
Created July 5, 2013 08:09
Drawing a bounding box around the detected contours of an image
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <algorithm>
#include <iostream>
#include <iterator>
#include <stdio.h>
#include <stdlib.h>
using namespace cv;
using namespace std;
@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); });
@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 / 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 / index.html
Created September 19, 2012 11:00
HTMLElement.click behaviour
<a id='clickMe' href='#'>Click me</a>​
@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