All of the interesting technological, artistic or just plain fun subjects I'd investigate if I had an infinite number of lifetimes. In other words, a dumping ground...

Thursday, 30 April 2009

libxml2 indenting or formatting output

I spent ages trying to get libxml2 and xmllint to format the output of an XML file.
The xml file was:
<?xml version="1.0"?>
<root>content<child1>child1 content<child2>child2 content</child2><child3>child3 content</child3><child4>child4 content<child5>child5 content</child5></child4><child6>child6 content</child6></child1></root>

Here you notice that the nodes that have child nodes also have content - I didn't know this was possible in xml. I guess that's why Daniel Villiard harps on how whitespace is significant.
Anyway I removed the content from the nodes that had children and low and behold:

<?xml version="1.0"?>
<root>
  <child1>
    <child2>child2 content</child2>
    <child3>child3 content</child3>
    <child4>
      <child5>child5 content</child5>
    </child4>
    <child6>child6 content</child6>
  </child1>
</root>

Works like a dream...

Friday, 24 April 2009

OpenMP programming

OpenMP

g++ -Wall -o opm opm.cc -fopenmp

#include <stdio.h>
#include <omp.h>

int main ()  {

int nthreads, tid;



/* Fork a team of threads with each thread having a private tid variable */
#pragma omp parallel private(tid)
  {

  /* Obtain and print thread id */
  tid = omp_get_thread_num();
  printf("Hello World from thread = %d\n", tid);

  /* Only master thread does this */
  if (tid == 0)
    {
    nthreads = omp_get_num_threads();
    printf("Number of threads = %d\n", nthreads);
    }

  }  /* All threads join master thread and terminate */

}

Programming contest questions


Wednesday, 15 April 2009

Tailor CVS to Git migration

Tailor VersionOne

Tailor is a tool to migrate changesets between Aegis, ArX, Bazaar?, Bazaar-NG, CVS, Codeville?, Darcs, Git, Mercurial, Monotone, Perforce, Subversion? and Tla? repositories. There are OtherTools with a similar goal, most of them tied and sometime more specialized on a particular system.

See SourceRepository and TargetRepository for more details on supported version-control systems, and ConfigurationFile for how to describe to tailor what you want it to do.

It perform its job executing several MigrationSteps, using a ReplayMechanism? that basically fetches the changesets from any of the source backends and effectively replay each one on the target system. The process can be configured very deeply in several ways, from tweaking a relatively simple configuration file to writing pre- and post- PythonHooks?.

It was written by Lele and it is implemented in Python.

Be sure to RTFM :-)

Twitter fall

http://twitterfall.com/
Cool push technology.

Local Amazon's EC2 api

EUCALYPTUS - Elastic Utility Computing Architecture for Linking Your Programs To Useful Systems - is an open-source software infrastructure for implementing "cloud computing" on clusters. The current interface to EUCALYPTUS is compatible with Amazon's EC2 interface, but the infrastructure is designed to support multiple client-side interfaces. EUCALYPTUS is implemented using commonly available Linux tools and basic Web-service technologies making it easy to install and maintain.

Tuesday, 14 April 2009

dual screen script

tohare@pts-tohare-laptop:~$ cat /usr/local/bin/dualscreen.sh
#!/bin/bash

#xrandr --addmode VGA 1280x768
#xrandr --addmode VGA 1440x900
#xrandr --output VGA --mode 1440x900
#xrandr --output VGA --right-of LVDS
xrandr --output LVDS --auto --output VGA --auto --right-of LVDS --output TMDS-1 --off

tim's shared items

Add to Google Reader or Homepage