Bearded Magnum

Archive for the ‘Uncategorized’ Category

SF, I’m on my way!

leave a comment

My first interview for this californian position was in last november, almost a year later my visa H1B is delivered!
Now, with that lovely sticker, I can live and work in the US for 3 years.
Our move to San Francisco is planned for mid-december with my wife, my son, and my dog…

Ellis Island Ship Image A hundred years before we could have have been aboard one of these ships crossing the Atlantic ocean to Ellis Island. Of course we are not running away from starvations or wars.
I searched for my name in the online Ellis Island registry, and I was surprised to get some matches.
I dont know of any links between these immigrants and my family. May be I should dive into the genealogical books my grand-mother wrote.

Written by Alexis

October 5th, 2007 at 3:47 pm

Posted in Uncategorized

Oracle-xe on Ubuntu

one comment

My purpose is not to write another installation guide for Oracle Express Edition on Ubuntu (Feisty). This is very well documented and quite easy.

However, despite a fresh installation, you will get the following error when loading /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh :

/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh:114:[[:not found
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/nls_lang.sh:114:[[:not found

You're not to be blamed, there is a slight error in the script.
The solution is to simply edit it (as root) and remove a pair of square brackets on lines #108 and #110.

if [ -n "$LC_ALL" ]; then
  locale=$LC_ALL
elif [ -n "$LANG" ]; then
  locale=$LANG
else
  locale=
fi

An alternative solution is to change the shell declaration on the very first line of the script.

Now, after reexecuting oracle_env.sh, the variable NLS_LANG should be set.

> echo $NLS_LANG
> AMERICAN_AMERICA.AL32UTF8

The explanation of this issue is that the Bourne Shell does not support the [[ compound command while the Bash shell does.

Written by Alexis

September 15th, 2007 at 2:59 am

Posted in Uncategorized

Oracle Recyclebin and JDBC

leave a comment

or how to lose your time…

To test my Hibernate mappings, I’ve been inspired by the base unit test shipped with Hibernate. I adapted it to my own needs but the concept remains unchanged: some DBUnit operations are executed before and/or after every unit tests. For instance, tables can be fully recreated and filled with test dataset.

Everything were working fine for weeks when suddenly an error poped out:

org.dbunit.database.AmbiguousTableNameException:TEST.BIN$OgO5GiZBrIrgQAB/AQEh6w==$0

Read the rest of this entry »

Written by Alexis

September 13th, 2007 at 4:22 pm

Posted in Uncategorized

Hibernate, how to get Table dependencies …

leave a comment

This is could be very useful when it comes to import dataset in batch (for testing?) . Insertions must avoid Foreign Key constraint violations. But before importing, you got to export.

    /**
     * Resolve table dependencies following the foreign keys.
* The returned list contains all the referenced table order by "foreign key", * and the table passed as argument. * * For instance, lets use the following model: * One User has a many-to-many relation to Team, and a many-to-one to Address. * * Asking for the dependencies of 'user2team' link table will return: * {@code ['address','user','user2team']} * * @return for convenience, the same List instance passed as parameter */ void getTableDependencies(List dep, Table table){ if(dep.contains(table)) return; for (Iterator it = table.getForeignKeyIterator(); it.hasNext();) { ForeignKey fk = (ForeignKey) it.next(); getTableDependencies(dep, fk.getReferencedTable()); } dep.add(table); }

Written by Alexis

September 4th, 2007 at 10:31 pm

Posted in Uncategorized

Ruby is great

leave a comment

or “Closures are great” I should say.

After thousands of Java lines, it’s so sweet to write such simple things as:

Dir.chdir(some_dir){
   puts "do your business here"
}

instead of:

actual = Dir.pwd
Dir.chdir(some_dir)
puts "do your business here"
Dir.chdir(actual)

As of today, closures are not available in Java. A JSR proposal may be included in Java7. Alex Miller maintains a good summary of what’s going on about Closures in Java7.
If you want to know more about Closures and Java, another Miller wrote a nice post few years ago.

Written by Alexis

August 24th, 2007 at 4:33 am

Posted in Uncategorized

Who cares about Polymorphism?

leave a comment

Sometimes you come accross some nice snippets of code. Another hint that copy/paste is getting more used than brains. Some developers do not really care about what they write. I could wish they could suffered a lack of OO knowledge, but come on even a first-year student is supposed to understand polymorphism, isn’t he?

Enjoy this piece of code. Note the delicate use of Vector.

    public static boolean isEqualDates(Date s1, Date s2) {
        if (s1 == null && s2 != null)
            return false;
        if (s2 == null && s1 != null)
            return false;
        if (s2 == null)
            return true;
        return s1.equals(s2);
    }

    public static boolean isEqualString(String s1, String s2) {
        if (s1 == null && s2 != null)
            return false;
        if (s2 == null && s1 != null)
            return false;
        if (s2 == null)
            return true;
        return s1.equals(s2);
    }

    public static boolean isEqualVectors(Vector s1, Vector s2) {
        if (s1 == null && s2 != null)
            return false;
        if (s2 == null && s1 != null)
            return false;
        if (s2 == null)
            return true;
        return s1.equals(s2);
    }

ps: of course these methods were hold by a class named ‘Util’, along with 300 other methods…

Written by Alexis

August 22nd, 2007 at 7:45 am

Posted in Uncategorized

Next stop is…

leave a comment

Last saturday for the first time I took the Caltrain to join Palo Alto. As every first time, especially in a foreign country, it has a taste of adventure even if it was not as exotic as the Trans-Siberian

After this thrilling trip in the San Francisco peninsula, I checked out the official website to see where Caltrain stations are located. If we rent a house outside SF it might be interesting to be near one of these stations. The station list being so static, I took on me to create a Google Map with all the Caltrain stations.


View Larger Map

Written by Alexis

August 21st, 2007 at 7:48 am

Posted in Uncategorized