Friday, June 29, 2012

GPX batch upload to sportstracklive.com

I've just pasted a new GIST Groovy script to enable uploading of all GPX files from a folder to http://www.sportstracklive.com/. it can be used in example to switch from RunKeeper (or another) to sportstracklive.com by exporting all your data and then re-importing it.

The script requiresJava and Groovy.

Script: https://gist.github.com/3015746

Thursday, May 3, 2012

jQuery CORS plugin

We have moved to a GitHub project the jQuery plugin we have developped at Ovea to support CORS for IE8+.

This implementation adds transparent CORS support for jQuery (through XDomainRequest) and is able to pass cookies and headers such as JSESSIONID, PHP Session, and all others you want.

It is also able to support custom error code: default IE implementation only returns HTTP code 200 but with this one you'll be able to support any HTTP code.

See https://github.com/Ovea/cors

Friday, December 2, 2011

Redis Introduction

Redis est un serveur NoSQL (sorte de MemCache évolué) permettant de partager des données entre différens serveurs. Nous allons voir comment l'utiliser en Java et ses principaux atout, notament l'atomicité, les transactions, l'asynchrone et les différents types de données supportés. Nous allons également montrer un usage concret d'utilisation d'un tel type de BD pour le clustering de sessions sur Jetty. Source code: https://github.com/Ovea/conf-redis

Advanced Junit & Mockito

Junit est une librarie de test que tout le monde connaît, mais peu de personne savent qu'il existe de nombreuses fonctionnailités plus ou moins documentées et assez puissantes. Cette présentation vise à montrer ces outils cachés via des démonstrations (@Rule, Suite, Theories, Comment tester la concurrence, Exécution en parallèle des tests, ...). Nous entrerons également dans le détail à savoir comment créer votre propre Runner Junit pour étendre ce framework et nous verrons les features expérimentales de Junit. Enfin nous verrons comment utiliser Mockito, un framework avancé de mocking. Source code: http://github.com/Ovea/conf-junit

Tuesday, November 15, 2011

Java, Groovy and Javascript compatible coding library

Last week I worked on a Java/Groovy and JavaScript compatible coding library including:
  • binary to hex representation (aka Hex class of commons codec)
  • base64 implementation
  • Tiny Encryption Algorithm (XXTEA)
  • ASCII to binary conversion
The challenge is to get the same output in JavaScript and Java for the same input. JavaScript has no byte type so the only common binary type representation I found for both of them is to arrays of 32-bits integers,

Most of existing coding JavaScript library works based on String, but String encoding may vary between Java and JavaScript. Integers cannot. On Java-side, the library can work with bytes, integers and most of all NIO buffers.

Here is an excerpt of what you can do with this library. The result is the same in Java, Groovy and JavaScript providing the same input.

Java / Groovy

// ascii <-> binary conversion
String str = 'abcdefghijklmnopqrstuvwxyz'
IntBuffer buffer = ASCII.toIntBuffer(str)
assert str == ASCII.fromIntBuffer(buffer)
// hex representation
String str = '0123456789ABCDEF'
IntBuffer buffer = HEX.decodeHexAsInts(str)
assert str == HEX.encodeHexString(buffer)

// Base64
String str = Base64.encodeBase64String(buffer)
ByteBuffer buffer =  Base64.decodeBase64(str)

// TEA key generation
Random r = new SecureRandom()
IntBuffer key = IntBuffer.wrap([
    r.nextInt(), 
    r.nextInt(), 
    r.nextInt(), 
    r.nextInt()] as int[]) //128-bits keys

// TEA encryption
String data = "...." // > 128-bits data
IntBuffer buffer = ASCII.toIntBuffer(data)
XXTEA.encryptInPlace(buffer, key)
String b64 = Base64.encodeBase64String(buffer)

// TEA decryption
buffer = Base64.decodeBase64(b64).asIntBuffer()
XXTEA.decryptInPlace(buffer, key)
String clear_text = ASCII.fromIntBuffer(buffer)

JavaScript

// ascii <-> binary conversion
var str = 'abcdefghijklmnopqrstuvwxyz';
var int_array = ovea.crypto.ascii.toInts(str);
str ==  ovea.crypto.ascii.fromInts(int_array);

// hex representation
var str = '0123456789ABCDEF'v
var int_array = ovea.crypto.hex.decode(str);
str == ovea.crypto.hex.encode(int_array);

// Base64
var str = ovea.crypto.base64.encode(buffer);
var int_array =  ovea.crypto.base64.decode(str);

// TEA key generation
var key = [0, 1, 2, 3]  // 128-bits key

// TEA encryption
var data = "...." // > 128-bits data
var buffer = ovea.crypto.ascii.toInts(data);
ovea.crypto.xxtea.encryptInPlace(buffer, key);
var b64 = ovea.crypto.base64.encode(buffer);

// TEA decryption
var buffer = ovea.crypto.base64.decode(b64);
ovea.crypto.xxtea.decryptInPlace(buffer, key);
var clear_text = ovea.crypto.ascii.fromInts(buffer);


The project java-js-crypto is available on Ovea's GitHub. The license is Apache 2 and libraries are deployed in Maven2 Central Repository at:

http://repo1.maven.org/maven2/com/ovea/ovea-crypto/