When is setting pointers to null usefull ?

29 September 2005

If you are just curious or need to profile your application, there are some debates :

There are some free profiling tools out there for Eclipse and NetBeans, more on this later.


Validating web.xml : mime type error

26 September 2005

If you ever try to validate the default web.xml Tomcat’s file : you will notice that there are errors due to a wrong pattern used in the Sun’s web-app_2_4.xsd schema.
The pattern doesn’t support the “+” used in application/mathml+xml or application/rdf+xml.
This isn’t quite an issue, because you just don’t really need to validate it. But since I use Eclipse : it runs validation easily and once it catch an error, it stay with an annoying red cross. Then, I had to make a local catalog of schema so I can validate off-line.
So,once I had the schema locally,it was easy to locate the buggy pattern and add the missing part (in bold) :
<xsd:pattern value="[\p{L}\-\p{Nd}]+/[\p{L}\+\-\p{Nd}\.]+"/>


Local XML catalog

26 September 2005

Because I am not always connected, I need to set up a local catalog of XML Schema (DTD, XSD and RelaxNG) so I can still validate my XML files.
The entries in the catalog allow you to map an URI (path to your local file) to a key of type “Schema location” (generally the file’s URL : http://&#8230;) This is the basis, but you can do smarter things. I will try for a next post.
I found some informations but no real consensus about how to set up such catalog. The problem is where to put the catalog file, where to put the shema and if possible find a convenient tool to manage the whole …
Here is what I found for now :

  • The environment variable is XML_CATALOG_FILES
  • The default catalog is in /etc/xml/catalog.
  • Finally, the shema could go to /usr/share/xml/ or /etc/xml/dtds

This is mainly what can be found in the Debian XML Policy.

Some references :


Open Source ports for MacOSX

22 September 2005

Update : 17/09/2006 : MacPorts !
I needed lftp (an efficient ftp program) on my Mac. I found several “Ports projects” : Fink (deb packages) ; MacPorts.org (ex DarwinPorts.org) and DarwinPorts.com (Source based.) The first (.org) is part of OpenDarwin.org and the second (.com) is more young, more uptodate but more uncertain too.
I choose .org and it went quite well :

  1. Install XCode tools (the installer was on my HDD anyway)
  2. download and install DarwinPorts click, click …
  3. create a .profile in your home directory
    # For DarwinPorts
    export PATH=$PATH:/opt/local/bin
    export MANPATH=$MANPATH:/opt/local/share/man
    export INFOPATH=$INFOPATH:/opt/local/share/infoexport

    Now you see where it is installed : /opt/local/
  4. Type : sudo port install lftp in a terminal and your done.
  5. To keep it up-todate put this in crontab sudo /opt/local/bin/port selfupdate
    sudo /opt/local/bin/port upgrade installed
    .

Note that the basic utilities are already in MacOSX. And if you can purchase a MacOSX Server, you will get MySQSL, Postfix and so on with nice GUI to configure them !

Finally, some ships MacOSX binaries, more or less integrated. This leads to some forks, like Camino wich is a Firefox cousin or NeoOffice an OpenOffice twin.


MacOSX environment variables

22 September 2005

How to set the environment variables in MacOSX : it is all there Runtime Configuration Guidelines
I still wonder how to set system wide environment variable (for the mysql “user” for example) I guess it may be in the startup scripts (BSD.)
How to open an hiden folder with finder : use the menu GO -> Go to folder


Different JVM for running Eclipse, Ant build

22 September 2005

Eclipse has multiple relation with the JVM : there is the JVM used to run Eclipse ; the JVM used by Eclipse to compile and build your projects ; Ant’s build file can fork and use another JVM too.

  • The most important and the easier : the JVM used for your projects. You can see them in Window / Preference ... : Java / Installed JREs. There you can add a new one or check the default one. Could it be override by each project ? (I didn’t find where.)
    The WebTools Platform let you choose one of those JVM to run your application server (ex: Tomcat.)
  • The JVM used to run Eclipse is harder to configure ! You can get general info in help.eclipse.org.
    To know wich JVM is used go to Help / About and click Configuration Details. By default, Eclipse uses the first JVM it finds in the PATH (not JAVA_HOME.)
    So, you have to put a -vm /path_to/java argument to Eclipse. If you use MacOSX … Ctrl-click your Eclipse icon and Show Package Content ; open Info.plist and in the Eclipse node add two sibling -vm and /System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java (put them at the end and continue the numbering.)
    Note the info.plist is for Eclipse arguments only, for the jvm they can be put in MacOSX/eclipse.ini (still in the Package Content.)
  • Ant too can launch a task with a different JVM : look at the java task. You can use the jvm attribute :
    <target name="start.tomcat">
        <java classname="org.apache.catalina.startup.Bootstrap"
                jvm="/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/bin/java"  
                fork="yes">
            <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
            <arg value="start"/>
        </java>
    </target>


WordPress plugin : Ultimate Tag Warrior

19 September 2005

I upgraded the Word Press Plugin : Ultimate Tag Warrior to 2.8. This is the moment to write an article about it.
Well, her site is a mess : you will have hard time to just find the last version ! But the plugin is great.
I already explain why tags are generally better than fixed categories.
Then there are a few things to setup in Word Press in order to get the most out of your Tags.
You can get a help page on your site : WordPress/wp-content/plugins/UltimateTagWarrior/ultimate-tag-warrior-help.html.

In the default sidebar, you should add :
<h2>Tag cosmos</h2>
<?php UTW_ShowWeightedTagSet(sizedcoloredtagcloud); ?>

I found some hints about how to change the templates in Jarrod Trainque’s blog.

I show the “related posts” when a single post is selected : (in post template)

<?php 
 if (is_single()) {
   echo "<p><small>Related posts :<ul>"; 
   UTW_ShowRelatedPostsForCurrentPost("posthtmllist");
   echo "</ul></small></p>"; 
 } 
 ?>

Note : to change the templates : go to Presentation / Theme Editor. Depending on your template, you may choose different presentations.

Finally, I set up a “tag cosmos” page : in the “Page Template”, I put after <div class="entrytext"?> this dirty hack :

<?php if ($post->ID==85) { ??>
   <p style="font-size: larger;"?>
      <?php UTW_ShowWeightedTagSetAlphabetical(sizedtagcloud); ??>
      <?php UTW_ShowWeightedTagSet("weightedlongtail") ??>
   </p?>
<?php }else { ??>
normal content ...


where 85 is the ID of a fake page I created. (replace with your own page ID.)
Then I put a link to this page in the “Tag cosmos” title of the sidebar.