Skip to content

Instantly share code, notes, and snippets.

View jpcaruana's full-sized avatar

Jean-Philippe Caruana jpcaruana

View GitHub Profile
@jpcaruana
jpcaruana / gist:751540
Created December 22, 2010 14:02
String and hascodes
int h1 = "0-42L".hashCode();
int h2 = "0-43-".hashCode();
System.out.println("h1 = " + h1);
System.out.println("h2 = " + h2);
/*
results :
h1 = 45721201
h2 = 45721201
*/
@jpcaruana
jpcaruana / gist:751544
Created December 22, 2010 14:06
update-alternatives : jdk 1.4 in Ubuntu
sudo update-alternatives --verbose --install /usr/bin/java java /opt/j2sdk1.4.2_18/bin/java 500 --slave /usr/share/man/man1/java.1 java.1 /opt/j2sdk1.4.2_18/man/man1/java.1 `for prog in *; do echo --slave /usr/bin/$prog $prog /opt/j2sdk1.4.2_18/bin/$prog; done | grep -v "java " | xargs`
@jpcaruana
jpcaruana / MonObjet.java
Created December 22, 2010 14:12
utilisation de XStream
public class MonObjet {
private int monAttributEntier = 3;
private String monAttributString = "attribut";
public static void main(String[] args) {
System.out.println(new XStream().toXML(new MonObjet()));
}
}
@jpcaruana
jpcaruana / setUpTearDownBarreVerteTime.java
Created January 10, 2011 14:12
setUpTearDownBarreVerteTime
@Before public void setup() {
BarreVerteTime.setMockTime(true);
BarreVerteTime.getInstance().setMockDate("2010-01-10 10:00:00");
}
@After public void teardown() {
BarreVerteTime.setMockTime(false);
}
@Test public void unPremierTest() { /* ... */ }
@Test public void unDeuxiemeTest() { /* ... */ }
@jpcaruana
jpcaruana / BarreVerteTimeRule.java
Created January 10, 2011 16:19
BarreVerteTimeRule
package fr.barreverte.time;
import java.util.Date;
import org.junit.rules.ExternalResource;
static import fr.barreverte.BarreVerteDateUtils.*;
public class BarreVerteTimeRule extends ExternalResource {
public final String dateDeMaintenant;
@jpcaruana
jpcaruana / testAvecTimeRule.java
Created January 10, 2011 16:27
appel à BarreVerteTimeRule
public class MonTest {
@Rule public BarreVerteTimeRule timeRule =
new BarreVerteTimeRule("2010-01-10 10:00:00");
@Test public void premierTest { /*...*/ }
@Test public void deuxiemeTest { /*...*/ }
}
@jpcaruana
jpcaruana / appelBarreVerteTime.java
Created January 10, 2011 16:28
new Date() avec BarreVerteTime
Date maDateNonTestable = new Date(); // :-( à ne plus faire
Date maDateTestable = BarreVerteTime.now(); // :-) la nouvelle façon
@jpcaruana
jpcaruana / createBuildrProject.sh
Last active December 2, 2017 14:51
utiliser buildr pour créer un projet minimal
#!/bin/bash
projectName=$1
if [[ $projectName == '' ]]; then
echo "usage: $0 nameOfTheProjectToCreate"
exit 1
fi
mkdir $projectName
cd $projectName
@jpcaruana
jpcaruana / .gitconfig
Created January 11, 2011 16:48
ma conf de git
[color]
branch = auto
diff = auto
status = auto
interactive = auto
[user]
name = Jean-Philippe CARUANA
email = jp@barreverte.fr
[alias]
last = cat-file commit HEAD
@jpcaruana
jpcaruana / mvn archetype
Created January 12, 2011 11:28
mvn archetype:generate
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/2.0/maven-archetype-plugin-2.0.pom
Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetype/maven-archetype/2.0/maven-archetype-2.0.pom
Downloading: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/2.0/maven-archetype-plugin-2.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------