Xr's blog

To content | To menu | To search

Programming

Entries feed

Sunday, February 7 2010

Changing commit usernames in Subversion

I've recently had to change my Subversion host of choice. The said host fell out of my control and, while I completely trust the new admin, I cannot rely on that server staying indefinitely available.

Fortunately, I now have access to my own (shared) server, for which I also have an SSH access. I'm quite a nitpicker, though, and wanted to be able to use my old user name on the new server (mainly to keep consitency amongst revisions). Of course, since it's a shared server, I cannot simply create a new system user. Documentation is pretty hard to find regarding this, and it is split between multiple locations. Here is a concrete example.

Continue reading...

Thursday, July 30 2009

Using Matt Curry's Asset Packer with themes in CakePHP

Matt Curry has written a CakePHP plugin to automatically compress CSS and Javascript files in CakePHP. It requires nearly no modification of existing code and works as you would expect it to. Except when you need themes.

If you choose to use the 'Theme' view in CakePHP, that plugin will happily disregard it and load the regular files instead of the themed files. I wrote a patch to fix the behavior.

Continue reading...

Monday, March 16 2009

Getting the JVM arguments from Java

While working on a Java software, I developed an utility that forked into background so that the VM could return instantly without using system-dependent tools like the shell or Debian's start-stop-daemon. My utility chose the right JVM (using the java.home system property) and started a new VM, calling the same main class with the same arguments, using the same classpath. Everything was fine.

However, when I came to using it on a somewhat more advanced setup, I came across a problem: JVM arguments weren't passed to the running VM. No memory configuration (-Xmx), no instrumentation (-agentlib)...

Continue reading...

Saturday, February 14 2009

Java, XML and indenting (continued)

This is a followup to Java, XML and indenting.

More fun in the "Why doesn't my XML source get indented" series.

When you build a StreamResult and you want indentation, instanciate it with a Writer. If you use a regular OutputStream (like System.out, for example), you will have new lines but no indentation.

Of course, it's not documented. The Javadoc for StreamResult(Writer) only says:

Construct a StreamResult from a character stream. Normally, a stream should be used rather than a reader, so that the transformer may use instructions contained in the transformation instructions to control the encoding. However, there are times when it is useful to write to a character stream, such as when using a StringWriter.

See those useful times ? I guess it's what they're talking about.

Thursday, January 22 2009

Programmatically using LimeWire for BitTorrent transfers

While working on a Java project (which doesn't have a real homepage yet) with a friend and colleague, we felt the need to provide an efficient way to transfer potentially massive files on a Peer-to-Peer computing network (as opposed to the well known P2P data networks). We agreed on the use of BitTorrent, for a bunch of technical reasons (for example, see [1], [2], [3], [4], ...)

After digging for a few days, the best solution I found was to use Azureus (now called Vuze). After a lot of work, I succeeded in using both the client and the tracker in a programmatic way. However, for reasons that I can't or don't want to explain without trolling, we were never really happy with it.

Not much later, LimeWire added support for BitTorrent. And this week, I finally got the time and motivation to look into it.

Continue reading...

Thursday, September 11 2008

Java, XML and indenting

A while ago, a friend/colleague was having trouble outputting formatted XML with Java's XML API. Both our codes output valid XML, but only mine was indenting it.

Basically, they looked like this (some logic skipped for ease of reading):

Continue reading...