Skip to content

Instantly share code, notes, and snippets.

View benek's full-sized avatar

Javier Benek benek

View GitHub Profile
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.FileNotFoundException;
@benek
benek / setenv.sh
Last active August 29, 2015 14:24 — forked from terrancesnyder/setenv.sh
./setenv.sh - example setenv.sh with defaults set for minimal time spent in garbage collection
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@benek
benek / SocketClient.java
Created June 13, 2013 17:08
Very simple socket client...
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
public class SocketClient {
public static void main(String[] args) throws IOException {
@benek
benek / ConstraintUnitSpec.groovy
Last active December 16, 2015 17:19
Clase con métodos utilitarios para tests y validación de constraints parametrizada. Basada en http://bit.ly/LFjAqZ
import spock.lang.Specification
import org.springframework.validation.FieldError
/**
* @author Javier Ramirez
* <[email protected]>
* Date: 30/06/12
* Time: 17:29
* www.javamexico.org
*
@benek
benek / grailsversion.sh
Last active December 14, 2015 09:50
Shell script para cambiar entre versiones de Grails en la consola
#!/bin/bash
# Shell script para cambiar la versión de Grails en el PATH
echo "Cambiando versión de Grails en variable PATH..."
if [ "$1" = "1.3" ] ; then
echo "Cambiando a versión 1.3.7..."
export GRAILS_HOME=/Users/benek/Downloads/grails-1.3.7
elif [ "$1" = "1.2" ] ; then
echo "Cambiando a versión 1.3.7..."
export GRAILS_HOME=/Users/benek/Downloads/grails-1.2-M3
@benek
benek / GenerateORMMappings.groovy
Created December 11, 2012 00:20
Generate Java fields from database column names
/**
* Author: Javier Alberto Ramirez Hernandez
* Date: 03/12/12
* Time: 10:39
* SintelTI.mx
*/
def basePath = '/base/path'
def convertLine(String line) {
@benek
benek / ToStringReflect.groovy
Created September 5, 2012 04:47
toString() que devuelve los valores de todas las propiedades de una clase Groovy
@Override
public String toString() {
def s = new StringBuilder()
this.properties.each {
s.append("$it.key: $it.value\n")
}
return s.toString()
}
@benek
benek / NumerosPrimos.java
Created January 13, 2012 04:37
Coding Kata 1
package codingdojo.numerosprimos;
/**
* @author benek
* Date: 12/01/12
* Time: 20:57
* www.javamexico.org
*/
public class NumerosPrimos {
@benek
benek / UsuarioSpec.groovy
Last active September 28, 2015 17:08
Ejemplo de una Spec con Spock para Unit Testing
/**
* @author Javier Ramirez
* <[email protected]>
* Date: 19/06/12
* Time: 22:30
* www.javamexico.org
*/
package org.javamexico.jm2.usuarios
@benek
benek / sketch_bolas.pde
Created November 23, 2011 06:11
Un básico "Hola Mundo" en Processing.
void setup() {
size(1024, 768);
smooth();
}
void draw(){
if (mousePressed) {
fill(0);
} else {
fill(255);