Skip to content

Instantly share code, notes, and snippets.

View benek's full-sized avatar

Javier Benek benek

View GitHub Profile
@benek
benek / placeholders.groovy
Created July 11, 2011 04:56
Just a simple Groovy script for creating placeholders...
new File("/path/to/base/dir").eachDirRecurse {
if (it.isDirectory() && !it.list().length) new File("$it.absolutePath/PLACEHOLDER") << ''
}
@benek
benek / SingleThreadExecutorScript.groovy
Created August 29, 2011 19:52
Testing SingleThreadExecutor
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
ExecutorService executor = Executors.newSingleThreadExecutor()
10.times {
executor.execute(new Runnable(){
public void run(){
println "Inicio"
Thread.sleep(1000)
@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);
@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 / 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 / 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 / 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 / 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 / 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 / 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 {