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 / 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 / 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 / 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 / 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 / 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 / SpotsManager.py
Last active August 29, 2015 14:03
Using sublime quick panel and hooks to retrieve/save content from an external ruby script (Sublime Plugin)
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sublime, sublime_plugin
import tempfile, subprocess, collections
DEBUG_MODE = False
IS_OSX = sublime.platform() == 'osx'
settings = sublime.load_settings('SpotsManager.sublime-settings')
@jbgutierrez
jbgutierrez / chart-pie-from-zsh_history.rb
Created September 3, 2014 07:14
Distribution of hours spent typing commands at my zsh shell each day
#!/usr/bin/env ruby
# coding: UTF-8
require 'pathname'
require 'googlecharts'
file = Pathname.new 'zsh_history'
dates = {}
file.each_line do |line|
next unless line =~ /^: /
@jbgutierrez
jbgutierrez / Gemfile
Last active August 29, 2015 14:13
Hodgepodge of useful scripts to analize different compression tools
# A sample Gemfile
source "https://rubygems.org"
gem "sinatra"
gem "mongoid"
gem "bson_ext"
gem 'sinatra-reloader'
gem 'haml'
@jbgutierrez
jbgutierrez / refactor.coffee
Last active August 29, 2015 14:15
Colaborative function patches
Function::patch = (binding, fn) ->
unless fn
fn = binding
binding = @
wrapped = (args...) ->
args.unshift (args...) ->
wrapped.previous.apply binding, args
fn.apply binding, args
wrapped.previous = @
wrapped
@jbgutierrez
jbgutierrez / plot-graphviz.rb
Last active August 29, 2015 14:15
Plotting a dependency graph
#!/usr/bin/env ruby
# coding: UTF-8
require 'yaml'
ALIAS = {
text: '/vendor/requirejs-text/text',
jquery: '/vendor/jquery/dist/jquery',
dust: '/vendor/dustjs-linkedin/dist/dust-full',
dustHelpers: '/vendor/dustjs-linkedin-helpers/dist/dust-helpers',
pagejs: '/vendor/page.js/page',