// xmlsort: swiss army knife xml ordering utility


Sort an xml file or parts of it to avoid false positive differences comparing it with a previous version (stored in a version control system like GIT or Mercurial).

Did you have some experience changing 1 thing only in a server, dump again data and obtain dozens of changed files like this ?

diff --git a/geonode.xml b/geonode.xml
index f4fc60f..ffcdbfc 100644
--- a/geonode.xml	2012-10-24 09:25:42.198961002 +0200
+++ b/geonode.xml	2012-10-24 09:26:58.034957830 +0200
@@ -19,12 +19,12 @@
     <entry key="namespace">http://geonode.org/</entry>
     <entry key="schema">the_schema</entry>
     <entry key="Loose bbox">true</entry>
-    <entry key="Expose primary keys">false</entry>
     <entry key="fetch size">1000</entry>
     <entry key="Max open prepared statements">50</entry>
+    <entry key="Expose primary keys">false</entry>
+    <entry key="user">MYUSER</entry>
     <entry key="preparedStatements">false</entry>
     <entry key="Estimated extends">true</entry>
-    <entry key="user">MYUSER</entry>
     <entry key="min connections">1</entry>

// Graphviz graph with dynamic layers into dokuwiki


Add layering feature to graphviz powerful tool and expose it by docuwiki graphviz plugin.

a : b : c

How to proceed

To be able to use this feature you need to install:

  1. the developing version of graphviz, you can find binary package here http://www.graphviz.org/Download..php
    compile sources, downloading them with the command hg clone http://hg.research.att.com/graphviz and following doc/build.html documentation.
  2. replace the standard version of the dokuwiki-plugin-graphviz with my fork that you can download from github here.

After both packages are installed you need to instruct dokuwiki to use the new graphviz suite of programs setting the Graphviz Plugin Settings part of the Docuwiki Configuration page with the correct new path for the dot command.

What's news

Following the layers usage described in the dotguide documentation you can see how layers work.

Layers are stacked from left to right.

The previous limitation where nodes and edges can appear on contiguous layers only is removed.

For each layer a transparent image is created and displayed together by the browser.

If you add a layer named _background_ it will be considered the background layer and not showed in the layers list.

Checkboxes and small javascript is automatically added by docuwiki plugin to be able to turn on and off each layer.

New dokuwiki graph tag attributes

There are two new attributes:

  • dpi=<dpi>: you can choose the number of <dpi> which to render the graph
  • slicespace=<pixels>: if present: render the graph as an isometric projection with a layer separation of <pixels> distance

a : b : c

show the source



  • Add a flag to avoid layers visualization (normal view).
  • Add a references system to draw the same graph many times with different layers turned on (in different documents too).


  • Add a field for layers description (to be use into dokuwiki instead of current displayed layer name).

// An object oriented approach to animate google maps markers


Obtain a good animation of markers, with 8 bit transparency channel, in google maps, and self-remove them at the end of the “movie”.

Approaching the problem

Google Maps API don't have a way to build animations with 8 bit transparency images as frames.

To achieve this purpose we use javascript, enriching the Marker object with our attribute mop_ct to save the index of the current animation frame.

At the end we remove the Marker itself from the page.

// Retrieves the current reading position in a file of any process on linux

Rarely I cross-post messages but for me this information was like a revelation so … have patience.


How to get the current reading position in a file of a process on your machine ?

This information can be useful in an avalanche of circumstances

  • you are importing 10G dump.sql into your new database
  • a friend is downloading your last recorded song (copyright free, obviously ;-) ) from your home web-server and you want to know how many bytes you must still send to him before you can turn off the laptop
  • how long you must wait before a grep command finishes its work

Right Answer

Use cat /proc/<process pid>/fdinfo/<file_handle>


For a demonstration keep this micro-program readdy.c and compile it:

// Use dokuwiki graphviz plugin to describe a network

Graphviz plugin allows embedding of .dot graphs into dokuwiki pages, put a graph description inside the tag <graphviz> is enough to accomplish this task, for more info about graphviz and the plugin installation see references below.


Use .dot file to describe graphically a not so unusual network scenario with InterNET, DMZ and LAN.


Hub-like object

To describe a lan where many machines are connected dot provides a primitive type named record.

Each cell of a record is identified by the id surrounded by angle brackets.

To address a cell you must use the syntax “<record id>:<cell id>”.

    INET [shape=record,width=.1, height=.1, label="<0>InterNET        |<1>|<2>|<3>|<4>|<5>|<6>|<7>|<8>|<9>|<10>|<11>|"];

Use ranking to pretty place machines

To allow a good placement of machines items we can use the rank = same attribute to align group of items to invisible rank generator objects.

And then:

     { rank = same; inv1; Alpha; Gamma; }

Graphical vs. logical edges placement

When an arrow has an opposite direction then the diagram (rankdir attribute) I strongly recommend to follow the diagram direction and set the dir attribute with the value back.

    INET:2 -> Alpha [dir=back];


A node port is a point where edges can attach to a node. If you want to specify where an edge is connected to an object you can use headport and tailport attributes specifying the compass point that you prefer “n”, “ne”, … .

    INET:10 -> Gold [dir=back, headport=e, tailport=s];
    INET:11 -> Platinum [dir=back, headport=e, tailport=s];

The code

Here all the code required to compose the diagram.

digraph structs {
    size = "5,5";
    node [shape=box, width=.1, height=.1, layer=all];
    edge [layer=all];
    constraint = false;
    nodesep = .1;
    ranksep = .3;
        node [style=invis];
        inv1; inv2; inv3; inv4;

    INET [shape=record,width=.1, height=.1, label="<0>InterNET        |<1>|<2>|<3>|<4>|<5>|<6>|<7>|<8>|<9>|<10>|<11>|"];
    DMZ [shape=record,width=.1, height=.1, label="<0>DMZ|<1>|<2>|<3>|<4>|<5>|<6>|<7>|<8>|<9>|<10>|<11>|"];
    LAN [shape=record,width=.1, height=.1, label="<0>LAN|<1>|<2>|<3>|<4>|<5>|<6>|<7>|<8>|<9>|<10>|<11>|"];

    INET:0 -> inv1 -> inv2 -> DMZ:0 -> inv3 -> inv4 -> LAN:0 [style=invis];

    { rank = same; inv1; Alpha; Gamma; }
    { rank = same; inv2; Beta; } 

    INET:2 -> Alpha [dir=back];
    INET:5 -> Beta [dir=back];
    INET:8 -> Gamma [dir=back];
    Alpha -> DMZ:2;
    Beta -> DMZ:5;
    Gamma -> DMZ:8;    

    { rank = same; inv3; Gold; }
    { rank = same; inv4; Silver; Platinum;} 

    DMZ:2 -> Silver [dir=back];
    DMZ:5 -> Gold [dir=back];
    DMZ:8 -> Platinum [dir=back];
    Silver -> LAN:2;
    Gold -> LAN:5;
    Platinum -> LAN:8;    

    INET:10 -> Gold [dir=back, headport=e, tailport=s];
    INET:11 -> Platinum [dir=back, headport=e, tailport=s];


Keeping in mind that digraph's diagrams are oriented and that exists some rules to change it's rendering behavior you can reach a great control on its output.