Archive by Author

Installation problem Miktex 2.9 on Windows 7

Due to a disc malfunction I  shifted  my complete windows partition to a new hdd, also changing the order of the windows partition. The windows partition is now not the first partition, and although this process took some time, in the end everything worked out.  However, when I tried to install a new Miktex version on this windows partition, the installation process aborted with errors.

I tested all availible solutions I could find, for example this one here. How ever the error remained:

The operation failed for some reason.

Details: \miktex\bin\initexmf.exe”

source file: Libraries\MiKTeX\Core\Process.cpp

Furthermore I knew that the previous Miktex installation was pointing to a Device (D:) that is not existent in the new setup. Hence, prior to the installation, I deleted every reference of this old Miktex installation in the registry, and voila it worked.

Ontology & Initialisation data seed for Chado-On-Rails

A CHADO instance without the use of ontologies is relatively useless, even for basic things such as running some tests in rails. Fixtures are great for minimalistic testing data but the required ontologies exceed those limits easily.

This great blog post by Matthias Marschall and this thread @ stackoverflow give some very good advice, how to load the required data without the usage of fixtures. The basic idea is simple:  Dump the loaded ontologies  from Postgresql/CHADO. Overwrite a Rake task with system calls that load the sql files and finaly run the rake command to populate the db.  Hence the above mentioned solution presents a convienient way to make use of the ontologies while testing an application that relies on CHADO.

A basic example to solve the situation could look something like this:

Create a file in lib/tasks/load_seed.rake with:

namespace :db do
  namespace :seed do

    desc "load the dumped seed data from db/*.sql into the test database"
    task :load => :environment do
      config = ActiveRecord::Base.configurations['test']
      system("psql --username=#{config['username']} #{config['database']} < db/db_ontologies.sql")
      system("psql --username=#{config['username']} #{config['database']} < db/db_initialize.sql")
     end
  end
end

To populate the test database with the data run

rake:db:seed:load

, in addition to

rake db:test:prepare

and

rake db:test:load

I’m using a single sql dump of the ontologies needed, since the download, conversion and load of the ontologies every time  db:seed:load is called would require an enormous amount of time.

(In this post I’m assuming that the database used is Postgresql and that the sql-file db_ontology.sql  represents a data dump of the chado instance  + ontologies loaded. db_initialize.sql is equal to gmod/load/etc/initialize.sql. See the CHADO installation manuel for more information.)

DBD::mysql install

I had quite some trouble to install DBD::mysql on a Ubuntu machine with MYSQL inside the Bitnami Rubystack folder. Hence here a brief description on the solution that got things working for me:

  1. Follow the manual installation described here until the point:
    perl Makefile.PL.
  2. Determine the path of YOUR mysql_config file, it is in the bin folder of your installation, or try to determine it with:
    whereis mysql_config
  3. call:
    sudo perl Makefile.PL --mysql_config="your_mysql_path/bin/mysql_config"
  4. Try to follow the instructions in #1, if an error occours that names a connection problem with:
    tmp/mysql.sock

    set an symlink as follows:

    ln -s /your_path_to_your_mysq/tmp/mysql.sock /tmp/mysql.sock
  5. Try again to run make test, and u should be good to go!

Five things I used to forget about Java

When I re-pick-up Java, after having dealt with really different programming languages in the months before, I encounter these moments of “damn-you-know-this”. So when I came back to java this time, I recorded my top five missing Java pieces:

  1. Conversion from String to Integer
    String example=“1”;
    int value = Integer.parseInt( example );
    

    It is NOT:

    Integer.getInteger( example );

    The getInteger method trys to

    Determines the integer value of the system property with the specified name.

  2. The ? – Operator The Java ternary operator (sometimes referred to as the “questionmark operator”) is an elegeant way to deal with boolean (TRUE / FALSE) decisions or assignments in the programming world. The ternary operator differs from an if-else statement due to the fact that it is an expression that returns a value. While the if-else structure  executes a statement. The following Example assigns the maximum Value of two ints to a new variable:
    int a = 5;
    int b = 10;
    int max  = (a &gt; b ? a : b);
    
  3. instanceof and isInstance The binary operator instanceof checks if an object is a member of a class:
    SampleObject sample = new SampleObject();
    if(sample instanceof SampleObject) {
    ...
    }
    

    Unfortunately though it is not possible to set the type (which the object is tested against) at runtime and use for example a string at the leftside of the instanceof operator:

    SampleObject sample = new SampleObject();
    String sampleStr = "sampleObject";
    

    if(sample instanceof sampleStr) {

    ...
    }
    

    At runtime it is possible though to check the type of an object with the isInstance method:

    // the object where we know what kind of type it is
    SampleObject sampleold = new SampleObject();
    
    // our "unknown" type object
    Object samplenew = new SampleObject();
    
    if(sampleold.getClass().isInstance(samplenew)) {
    ...
    }
    
    

    Attention to the switch of the arguments between instanceof and isInstance !

  4. Comparator

    If I write a Comparator Object I usually implement Comparator<T> and then override  int compare(T t1, T t2). To implement a proper working compare method the following “handrules” apply:

    1. (t1 < t2) ->  return a negative value
    2. (t1 == t2) -> return zero
    3. (t1 > t2) -> return a positive value

    The <, ==, > do NOT have to refer to the standard smaller, greater, etc operators !

Tetris is NP-Complete

During my prep for the upcoming exam in theoretical informatics I stumbled upon this Paper with the proof that Tetris is NP-Complete.  An unsual way to apply theory to practise ;)