Skip to content

Instantly share code, notes, and snippets.

View icoloma's full-sized avatar

Nacho Coloma icoloma

View GitHub Profile
@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 / 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 / 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 / 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 / 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 "--"
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;