Skip to content

Instantly share code, notes, and snippets.

View icoloma's full-sized avatar

Nacho Coloma icoloma

View GitHub Profile
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashSet;
import java.util.Set;
import org.junit.Test;
@icoloma
icoloma / MainArguments.java
Created July 28, 2011 10:39
Java main arguments parser
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
* Parses options and arguments provided in the command line. All option values must be preceded with "--"
@icoloma
icoloma / GoogleMapsUrlFactory.java
Created March 4, 2012 09:17
Creates a URL to be used in Google Maps. Useful for creating links where the javascript API is not available, e.g. in HTML mail.
/**
* Creates a URL to be used in Google Maps. Useful for creating links where the javascript API is not available, e.g. in HTML mail.
* For info about each arguments, see http://mapki.com/wiki/Google_Map_Parameters
* @author icoloma
*/
public class GoogleMapsUrlFactory {
private HashMap<String, String> params = Maps.newLinkedHashMap();
public String build() {
@icoloma
icoloma / Base58.js
Created May 2, 2012 13:36
JavaScript implementation of Base58
/**
This is a javascript port of the Base58 code present at
http://icoloma.blogspot.com.es/2010/03/create-your-own-bitly-using-base58.html
*/
var Base58 = (function() {
var
BASE58_CHARS = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
return {
@icoloma
icoloma / example.js
Last active December 19, 2015 06:19
In which a data model for Opening Hours gets introduced with an evil plan to get transformed into a working implementation. Eventually.
var examples = {
// Monday to Friday 9 to 1 and 3 to 7
"Mon,Tue,Wed,Thu,Fri": "09:00-13:00,15:00-19:00",
// Saturdays, 9 to 2
"Sat": "09:00-14:00",
// Sundays closed
"Sun": "",
@icoloma
icoloma / IDEA (settings->live templates)
Last active December 21, 2015 01:39
IDE templates
// name: log
// scope: java->declaration
// set $CLASS_NAME$ to className()
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger($CLASS_NAME$.class);
@icoloma
icoloma / gist:6316635
Created August 23, 2013 07:53
Concatenate PDFs
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf
@icoloma
icoloma / gist:6751262
Created September 29, 2013 10:27
Git shortcuts
# Create a serverfix branch synchronized with origin
git checkout --track origin/serverfix
@icoloma
icoloma / .zshrc
Last active December 25, 2015 13:18 — forked from SlexAxton/.zshrc
Create screencasts
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@icoloma
icoloma / gist:7315985
Created November 5, 2013 09:06
Proxy in China
ssh somehost -D 6070
# then point your browser to use socks5://locahost:6070 as a proxy