EuroBasket 2009 — Day 1

The biggest surprise of Day 1 of the EuroBasket 2009 is for me Turkey teaching Lithuanian basket to Lithuania by scoring 3 pointers after 3 pointers (7/17 opposed to 9/25 for Lithuania!). Led by 10 pts with less than 2 min to go, Lithuania has never really seemed able to recover from the panic stance they displayed after the crazy session soon after half-time, despite coming back to -2 at the beginning of q4. Turkoglu and Arlsan were imperial.

The other surprise is… actually not so surprising. Spain were defeated by a Serbia in great form (-9) in a display very much in line with what they showed in Vilnius a few days ago where they suffered an “embarrassing” -22, and a not so convincing win against Poland in August. Hopefully, they’ll become themselves again after a match against Great Britain that should be a formality.

France did a good match against Germany, and won 70-65. It was a tense match, with Germany leading for quite some time, until the 3rd quarter when the French decided to defend quite high and aggressively, which earned them a 17-11 that made all the difference in the end. The 4th quarter is all Tony Parker, typical of a NBA money time, but I think what made the difference is that 3rd quarter.

Tonight, France is playing Latvia and could get their qualification for the next round if they win. Other matches to watch: Greece–Croatia, Germany–Russia, Slovenia–Serbia.

Comment

 
---

4.09.09

,

EuroBasket 2009

EuroBasket 2009 is starting on Monday in Poland with a crucial France – Germany at 7.15pm in Gdansk.

France had some troubles to qualify in the playoffs, but finally won the final match against Belgium to win their ticket. Ahead of the match on Monday, I decided to invest in the FIBAtv.com package, and despite the usual problems with my credit card (apparently, AML software have troubles understanding I’m a Frenchman with a French card living in Ireland), I am currently watching Argentina v. Uruguay. Well, let me tell you, it’s pretty amazing: I was a bit concerned with quality, but full screen, it’s actually amazing. 22€ well spent.

I've always been a Lithuania supporter

Comment

 
---

Ruby and Oracle OCI8

Ruby comes handy for little nifty scripty stuff to be done before running unit tests. I use it in particular to do some database cleanups before running a whole suite of tests — it is far more efficient than dbUnit for simple tasks. ruby-oci8 is dead easy to install and to use, so that’s what I’m using and describing here.

(I did the following on Windows, still have to try on Ubuntu)

  1. Install the ruby-oci8 gem:
    >gem install ruby-oci8
    Successfully installed ruby-oci8-2.0.2-x86-mswin32-60
    1 gem installed
    Installing ri documentation for ruby-oci8-2.0.2-x86-mswin32-60...
    Installing RDoc documentation for ruby-oci8-2.0.2-x86-mswin32-60...
    
  2. Make sure the Oracle client folder is in the PATH.
  3. Create a sample file:
    require 'oci8'
    conn = OCI8.new('user', 'password', 'tnsname')
    conn.exec('select table_name from user_tables') { |r| puts r }
    conn.logoff
    

Make sure you replace tnsname with the value from your tnsname.ora file. You can then run your nice test with:

ruby oracle.rb

Or call it from ant with an exec task. The API is there, and quite straightforward.

Comment

 
---

Finding your Match

Not quite typography, but so funny I can’t help sharing this: the Accidental Headline of the Year.

Comment

 
---

"Type, Typography, Lettering & Signage"

That’s the We Love Typography programme, a place gathering typography-related pictures, from street signs to random posters and books. I can’t remember for the life of me how I came across this site, but it feels good not to be the only one to have a collection of pictures full of types...

Comment

 
---

Anagrammatically Ruby

For the past few weeks, I have been looking into Ruby. I’m still learning, but I have been playing with Sinatra and Rails, and along the way, I have conducted some experiments to understand the language a bit better.

Two of the things I like the most with Ruby came very handy for this one: iterators and the way you can chain function calls. Inspired by this, I wanted to solve this problem. The first result was doing it with a Java reflex:

words = {}
IO.readlines("/usr/share/dict/words").each do |word|
  hash = word.chomp.downcase.split(//).sort.join
  if !words.has_key?(hash)
    words[hash] = []
  end
  words[hash] << word.chomp
end
words.values.each do |value|
  if value.length > 1
    puts value.join(",")
  end
end

Symptomatic of this Java-flavoured version is the if !words.has_key?(hash), testing for the presence if the hash key to initialize the value with an array. But we’ll get back to that later.

The other Java-looking thing is the test if value.length > 1 for filtering out single values. As you can use closures in Ruby, this piece can be neatly rewritten as follows:

words = {}
IO.readlines("words").each do |word|
  hash = word.chomp.downcase.split(//).sort.join
  if !words.has_key?(hash)
    words[hash] = []
  end
  words[hash] << word.chomp
end
words.values.find_all{|elt| elt.length > 1}.each do |value|
    puts value.join(",")
end

Now is time to get rid of the test for the presence of the key. A little search gives an interesting result indicating how the value can be automatically initialized with an array when the key is not present:

words = Hash.new { |h,k| h[k] = [] }
IO.readlines("words").each do |word|
  words[word.chomp.downcase.split(//).sort.join] << word.chomp
end
words.values.find_all{|elt| elt.length > 1}.each do |value|
    puts value.join(",")
end

Then, it is just a laugh, you can rewrite the blocks so that they hold on a single line:

words = Hash.new { |h,k| h[k] = [] }
IO.readlines("words").each{ |word| words[word.chomp.downcase.split(//).sort.join] << word.chomp }
words.values.find_all{|elt| elt.length > 1}.each{ |value| puts value.join(",") }

Pretty cool stuff. This little experiment shows how handy the blocks in Ruby are; again, I’m still learning, but I somehow have the feeling that this could be reduced a bit further — albeit at the expense of readibility.

Comment

 
---

Typedia: Types Enter the Web 2.0

Typedia is the Wikipedia of typefaces, listing and classifying types in a collaborative manner. It’s a fantastic job done by a dozen of font enthusiasts: the website is slick and very nice-looking — the power of simple design, of Lucida and fab logo by John Langdon whose Wordplay is a must-have.

Comment

 
---

Draw the Character You're Looking For

You’re writing some nice LaTeX document, and there is some character whose command you can’t remember. Well, Detexify is a nifty little webapp that allows you to draw the symbol or character you’re looking for, and returns you a list of potential candidates. Pretty cool stuff, since you can “teach” the beast to recognize your symbols, and the code is available on git (have to get back to Ruby these days… looking at the code makes you wonder why you still bother with all that Java overhead).

Simple and smart.

Comment

 
---

Ecology and Font

That’s Ecofont, a font with “holes” mentioned by National Geographic. A (Dutch) font with holes, which therefore “uses up to 20% less ink” according to the ecofont website. It is based on Vera sans, the omnipresent font on Linux platforms these days. It is available and sounds like a creative marketing coup more than anything (I guess not printing still remains the best solution, though).

Comment

 
---

Where is the Hibernate stuff gone?

Want to see something freaky? Google any Hibernate documentation, and see what you can dig out.

Not sure what the craic is, but it kind of makes you wonder…

Update: Ah, that was just me being paranoid’n‘all, it is all back now.

Comment

 
---

« Mettre cartes sur table »

Jacques Demers, consultant pour la NHL sur CKAC Sports, est en colère avec la performance des Canadiens de Montréal qui restent sur 4 défaites de suite : http://www.corussports.com/radio/audioplayer.php?file=expert_2009-01-30_071804.mp3&mode=fs

Une intervention d’anthologie colorée qui va crescendo, à tel point que son interlocuteur ne peut pas en placer une…

Comment

 
---

Google's New Favicon

The BBC News Magazine has an interesting article about the new version of Google’s favicon (the third in a very short period of time):

The new favicon is based on a design sent in by André Resende, a computer science undergraduate student at the University of Campinas in Brazil.

Comment

 
---

Installing Latin Modern Fonts in LaTeX

The UK TUG FAQ page is a wonderful treasure for anything LaTeX-related, but after I spent quite some time trying to install the Latin Modern fonts on my Ubuntu box, it appears that this entry could do with a bit more details.

First, you obviously have to have a local texmf directory, hashed properly:

mkdir ~/texmf
texhash ~/texmf

You can then stick all your “local” LaTeX files in there (as the TDS spec indicates, it is unclear what “local” means, either any file outside your TeX distribution, or a file created locally. Whatever you prefer, I guess); it is all very well explained there: https://help.ubuntu.com/community/LaTeX.

Now, I happened to want to install Latin Modern after reading the frenchb documentation (Goodness me, memories, memories…), and the FAQ linked above seemed to be indicating that it was a mere piece of cake. Well, if you happened to download the gzipped tar version of the archive like I did (as opposed to the zip archive), the files are stored like this:

/tex-archive/fonts/lm/

And then, you have the correct tex, doc, fonts structure. These are the folders you must stick right under ~/texmf — the fonts folder right under tex-archive really got me there. You then run as per the FAQ:

updmap --enable Map lm.map

(Not sure if this matters — I’m not familiar with updmap yet… — but I ran this in /tex-archive/fonts/lm/). Import lmodern and fontenc with the T1 option, and that should be it.

Now, I’ve not played with LaTeX for quite a long time, but man this looks good…

Comment

 
---

Zero Constant

Seen recently in the application I’m working on:

private final static int ZERO = 0;

Damn handy if you want to change ZERO to, say, 1 or 10000 everywhere.

Comment [2]

 
---

Find a Class in Jars

I often have to find a class (or its different occurrences) in a list of jars located in a folder (or its sub-folders). The Jython script below parses all the jars in a location, and display the name of all the jars containing the class I’m looking for. Stick it into a file called “search_jar.py.”


import os, sys, traceback
from os.path import isdir,join
from java.util.zip import *
from java.util.jar import *
from java.io import *

def scan_directory(class_name, directory=’.’): for f in os.listdir(directory): if os.path.isdir(join(directory, f)): scan_directory(class_name, join(directory, f)) if os.path.basename(f).lower().endswith(’.jar’) > 0 \ and not os.path.isdir(join(directory, f)): scan_jar(class_name, join(directory, f))

def scan_jar(class_name, jar_file): try: jar = JarFile(jar_file) entries = jar.entries() while entries.hasMoreElements(): entry = entries.nextElement() if entry.toString().find(class_name) >= 0: print ‘%s: %s’ \ % (os.path.abspath(jar_file), entry)

except ZipException: print ‘Error trying to open %s’ % jar_file traceback.print_exc(file=sys.stdout)

if name '__main__': if not len(sys.argv) 3: print “Usage: jython search_jar.py “ sys.exit(1) scan_directory(sys.argv[1] + '.class', sys.argv[2])

It can be called as follows:

jython search_jar.py MyNiceStub C:\application_server\lib

This script is quite handy when investigating issues related to ClassNotFoundException, or ClassCastException, or classloading-related problems. Watch out, the script appends “.class” to the name of the class you’re passing to the script, so if you’re looking for something other than a class (a resource file, for example), it won’t find it. It doesn’t look for classes which are not in jars either – but adding this to the script is trivial!

Comment

 
---

← Older Newer →