Sunday, 4 December 2011

Selecting a good Channel for your WiFI, or how to find the WiFi spectrum around you.

why my wifi router in channel 6 is not working properly?..... well seems obvious

root@debian:/home/pablo# iwlist scan | grep Channel
                    Frequency:2.417 GHz (Channel 2)
                    Frequency:2.417 GHz (Channel 2)
                    Frequency:2.412 GHz (Channel 1)
                    Frequency:2.412 GHz (Channel 1)
                    Frequency:2.422 GHz (Channel 3)
                    Frequency:2.422 GHz (Channel 3)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.462 GHz (Channel 11)
                    Frequency:2.462 GHz (Channel 11)
                    Frequency:2.412 GHz (Channel 1)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.442 GHz (Channel 7)
                    Frequency:2.442 GHz (Channel 7)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.412 GHz (Channel 1)
                    Frequency:2.437 GHz (Channel 6)
                    Frequency:2.412 GHz (Channel 1)


I know that there are nice applications to see the the WiFi stations but this is something quick when you don't have the X's started (I like Arch sometimes and my debian without Xs in very old laptops)

root@debian:/home/pablo# iwlist scan | grep "ESSID\|Channel"| \
 perl -lane '($essid)=/ESSID:(.+)/; ($channel)= <>=~/Channel (\d+)/; \
 push @{$h{$channel}}, $essid;  END {print "Chnl\tcount\tESSIDs"; \
foreach (sort {$a<=>$b} keys %h){ $cnt=@{$h{$_}}; \
 print "$_\t[$cnt]\t @{$h{$_}}"}}'

Chnl count ESSIDs
1 [4]  "SKYC4E76" "TALKTALK-431FCD" "SISJ_Net" "virgin broadband"
3 [2]  "FON_ab" "my_place_ab"
6 [8]  "BTHomeHub2-2RQK" "BTOpenzone-H" "BTFON" "SKY8430D" "SKY74103" "ZyXEL_3340ras" "BTHomeHub2-MWCS" "VirginMedia8791617"
7 [1]  "BTOpenzone-H"
11 [2]  "BTHomeHub2-349C" "SKY97946"

Thursday, 30 June 2011

DBI::SQLite and dbish

Today I needed to have a SQLite db with foreign keys and realise that my server's SQLite3 is very old (3.3.6). My perl DBD::SQLite is using version 3.7.6. I read in the DBD::SQLite that you can access to the SQLite db using dbish (a shell wrapper to DBI::Shell).

I wanted to use the same SQLite version in shell and scripts. Before installing a new version of sqlite3 I tried dbish.

dbish is part of DBI::Shell. It will be installed in your local-lib/bin when you install DBI::Shell.

First encounter was disappointing: following the POD it was not working at all

$   dbish dbi:SQLite:test.db

     DBI::Shell 11.95 using DBI 1.611

     WARNING: The DBI::Shell interface and functionality are
     =======  very likely to change in subsequent versions!


     Connecting to 'dbi:SQLite:test.db' as ''...
     @dbi:SQLite:test.db> table_info
     @dbi:SQLite:test.db> quit
     @dbi:SQLite:test.db> exit
     @dbi:SQLite:test.db> help
     @dbi:SQLite:test.db> type_info
     @dbi:SQLite:test.db> help
     @dbi:SQLite:test.db>

None of the comands worked :-(.


Googling around I found that the book 'Programming the Perl DBI' By Alligator Descartes, Tim Bunce has a chapter about it and discovered that the commnads must be preceded with a '/'.

@dbi:SQLite:srf2cram.db> /help
Defined commands, in alphabetical order: 
  [/;]chistory   display command history 
  [/;]clear      erase the current statement 
  [/;]col_info   display columns that exist in current database 
  [/;]commit     commit changes to the database 
  [/;]connect    connect to another data source/DSN 
  [/;]count      execute 'select count(*) from table' (on each table listed). 
  [/;]current    display current statement 
  [/;]describe   display information about a table (columns, data types). 
  [/;]do         execute the current (non-select) statement 
  [/;]drivers    display available DBI drivers 
  [/;]edit       edit current statement in an external editor 
  [/;]exit       exit 
  [/;]format     set display format for selected data (Neat|Box) 
  [/;]get        make a previous statement current again 
  [/;]go         execute the current statement 
  [/;]help       display this list of commands 
  [/;]history    display combined command and result history 
  [/;]load       load a file from disk to the current buffer. 
  [/;]option     display or set an option value 
  [/;]perl       evaluate the current statement as perl code 
  [/;]ping       ping the current connection 
  [/;]primary_key_info display primary keys that exist in current database 
  [/;]prompt     change the displayed prompt 
  [/;]quit       exit 
  [/;]redo       re-execute the previously executed statement 
  [/;]rhistory   display result history 
  [/;]rollback   rollback changes to the database 
  [/;]run        load a file from disk to current buffer, then executes. 
  [/;]save       save the current buffer to a disk file. 
  [/;]spool      send all output to a disk file. usage: spool file name or spool off. 
  [/;]table_info display tables that exist in current database 
  [/;]trace      set DBI trace level for current database 
  [/;]type_info  display data types supported by current server 
Commands can be abbreviated. 

dbish is interesting because I can interact whith the databases and test the DBI commands interactively, but I think that with SQLite3 I have more control and is better documented. So I ended installing the latest version of SQLite3.

[update]

I downloaded the latest precompiled sqlite3 and it was not working properly in my CentOS release 5.4: the cursor got detached from the line and was able to move through all the screen (not allowing up for previous history). Also was not quiting.

$  sqlite3 test.db
SQLite version 3.7.7.1 2011-06-28 17:39:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .q
   ...> ;
   ...>
   ...>
   ...>
   ...>
I killed manually and compiled from the 'amalgamation' download and now works fine.


[edit2]

After reading this question in StackOverflow about how to set by default the foreign keys for a database, I am having second thoughts about using foreign keys with SQLite:

No, not even with compile-time options.

The only way, so far, is to use pragma foreign_keys=on at run time. The particular danger is that every application that touches the database has to do that.

If a specific application doesn't run that pragma statement, it can insert data that will violate foreign key constraints, and other applications won't know it. That is, turning on foreign keys doesn't warn you of existing data that violates the constraint.

Monday, 27 June 2011

qrcode generator with perl

There are some good pages for genereating QRcode and a lot of not so good ones. There are probably to many to decide which one to use so I decided to create yet another one:
pmg-qrcode




I have used
HTML::QRCode
Imager::QRCode



[...]
use Imager::QRCode;
use HTML::QRCode;

[...]

sub get_html_qr {
  my $text = shift;
  my $qrcode = HTML::QRCode->new->plot($text);
  return $qrcode;
}

sub print_qrimage {
  my $text = shift;
  my $imga_type = shift || 'png';
  my $qr = Imager::QRCode->new(
      size  =>  5,
      level => 'M',
    );

  $qr->plot($text)->write( fh => \*STDOUT, type => $img_type);
}


This is very simple, but .....
the difficult part is to have them working because the prerequisites not very well explained.

If you read the README for HTML::QRCode it says that it works out of the box with an standard cpan install. Well that is true if you have already Text::QRCode, that usually is not the case. Don't panic, lets install T::QRC and all will be fine. Humm... Marvin still depressed. Despite T::QRC also telling you about doing a standard install and all will go OK, again, that will only be true if you have all prerequisites already installed and in the default place. T::QRC needs libqrencode headers and libs and look for them at the root installed paths. The README does not say anything about this but the description of T::QRC gives a hint
DESCRIPTION ^
This module allows you to generate QR Code using ' ' and '*'. 
This module use libqrencode '2.0.0' and above.  

To make the long story short, I tried to install HTML::QRCode in my local-lib environment and failed because Text::QRCode missing. I tried to install T::QRC and failed because no lib-qrencode. Installed locally lib-qrencode and not able to install T::QRC because not knowing how to pass a 'prefix' option to Makefile.pl for the ld_lib and includes. Solved editing the Makefile.PL manually, adding an env-var for LD_RUN_PATH and install manually T::QRC and then cpan install of HTML::QRCode.

Long story:

HTML::QRCode needs Text::QRCode and Text::QRCode needs lib-qrencode:

HTML::QRCode:
t/00-load.t .. 1/1
        #   Failed test 'use Text::QRCode;'
        #   at t/00-load.t line 6.
        #     Tried to use 'Text::QRCode'.
        #     Error:  Can't load '/homes/pmg/.cpan/build/Text-QRCode-0.01-n4g2CG/blib/arch/auto/Text/QRCode/QRCode.so' for module Text::QRCode: libqrencode.so.3: cannot open shared object \
file: No such file or directory at /homes/pmg/pmg-soft/local-perl/lib/5.12.1/x86_64-linux/DynaLoader.pm line 200

I searched for libqrencode and download it:

# download
wget http://fukuchi.org/works/qrencode/qrencode-3.1.1.tar.gz
# extract
# install
[~/pmg-soft/src/qrencode-3.1.1]
$  ./configure --prefix=$HOME/pmg-soft
$ make
$ make install

And obtained a helpful message that I save for later:

----------------------------------------------------------------------
Libraries have been installed in:
/homes/pmg/pmg-soft/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Now I have a T::QRC build extracted somewhere (I can see the path in the error message) [ Error: Can't load '/homes/pmg/.cpan/build/Text-QRCode-0.01-n4g2CG/blib/arch/auto/Text/QRCode/QRCode.so'].

I went there and read the Makefile.PL. It has two places (includes and ld-lib) where I need to add the path for my local lib-qrencode files:

a) the directives for the Makefile

sub MY::post_constants {
  [...]
  return <<"POST_CONST";
  CCFLAGS += $define -I/homes/pmg/pmg-soft/include
  LDDLFLAGS += -L/homes/pmg/pmg-soft/lib -lqrencode
  LDFLAGS += -L/homes/pmg/pmg-soft/lib -lqrencode
  POST_CONST
}
b) the comand for testing that the lib-qrencode exist (testing existence by compilation success)
sub test_libqrencode {
  my $compile_cmd
        = 'cc -I/homes/pmg/pmg-soft/include -I/usr/local/include -I/usr/include -L/homes/pmg/pmg-soft/lib -L/usr/lib -L/usr/local/lib -lqrencode';
  [..]
}
Then exported the environmental variable 'LD_RUN_PATH':
export LD_RUN_PATH=/homes/pmg/pmg-soft/lib
$ make clean
$ perl Makefile.PL 
| Cannot determine perl version info from lib/Text/QRCode.pm
| Checking if your kit is complete...
| Looks good 
| Writing Makefile for Text::QRCode
$ make          
$ make test
| PERL_DL_NONLAZY=1 /homes/pmg/pmg-soft//local-perl/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'inc', 'blib/lib', 'blib/arch')" t/00-load.t t/01-plot.t
| t/00-load.t .. 1/1 # Testing Text::QRCode 0.01, Perl 5.012001, /homes/pmg/pmg-soft//local-perl/bin/perl
| t/00-load.t .. ok
| t/01-plot.t .. ok
| All tests successful.
| Files=2, Tests=3,  0 wallclock secs ( 0.02 usr  0.03 sys +  0.06 cusr  0.04 csys =  0.15 CPU)
| Result: PASS
$ make install
|Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
|Installing /homes/pmg/pmg-soft/local-perl/local-lib/lib/perl5/x86_64-linux/auto/Text/QRCode/QRCode.so
|Installing /homes/pmg/pmg-soft/local-perl/local-lib/lib/perl5/x86_64-linux/auto/Text/QRCode/QRCode.bs  
|Installing /homes/pmg/pmg-soft/local-perl/local-lib/lib/perl5/x86_64-linux/Text/QRCode.pm
|Installing /homes/pmg/pmg-soft/local-perl/local-lib/man/man3/Text::QRCode.3
|Appending installation info to /homes/pmg/pmg-soft/local-perl/local-lib/lib/perl5/x86_64-linux/perllocal.pod

Then go to cpan and intall HTML::QRCode
cpan[2]> install HTML::QRCode 

That's all, happy hacking.


Pablo

Tuesday, 31 May 2011

from July 2011 KEGG ftp access needs paid subscription even for academic users

Unfortunately the person behind Kyoto Encyclopedia of Genes and Genomes (KEEG) is reaching retirement and the main funding agency that was suporting KEGG has changed and is no longer supporting individual databases.

Therefore starting on July 1, 2011 the KEGG FTP site for academic users will be transferred from GenomeNet at Kyoto University to NPO Bioinformatics Japan, and it will be available only to paid subscribers. The publicly funded portion, the medicus directory, will continue to be freely accessible at GenomeNet.

You can read the rationale behind in this page

We will see how this affects to the Reactome guys.

Sunday, 29 May 2011

What can go wrong when working with UTF8?

Seems that everything if you don't know what UTF8 is about. see this Stack Overflow question and the response of @tchris

Deobfuscating large or complex regular expressions

From time to time you find a large or complex regular expression that has not been coded with //x thus you have a oneliner without comments, and a big headache after some time trying to decoding it.

Recently I found a RE of this class and a module (YAPE::Regex::Explain) that helps you to decompose the RE elements.

regexp:

m{^((\w*)://(?:(\w+)(?:\:([^/\@]*))?\@)?(?:([\w\-\.]+)(?:\:(\d+))?)?/(\w*))(?:/(\w+)(?:\?(\w+)=(\w+))?)?((?:;(\w+)=(\w+))*)$}

This regexp parses URIs like:

mysql://anonymous@my.self.com:1234/dbname/tablename

(NOTE: these URIs are better parsed with URI::Split but this is another story)

And how to decompose it:

#!/usr/bin/env perl

use feature ':5.10';
use strict;
use URI::Split qw(uri_join uri_split);
use YAPE::Regex::Explain;
use Data::Dumper;

explain_RE($REx);

sub explain_RE {
    my $REx = shift;
    my $exp = YAPE::Regex::Explain->new($REx)->explain;
    print $exp;
}

result:

The regular expression:

(?x-ims:
^((\w*)://(?:(\w+)(?:\:([^/\@]*))?\@)?(?:([\w\-\.]+)(?:\:(\d+))?)?/(\w*))(?:/(\w+)(?:\?(\w+)=(\w+))?)?((?:;(\w+)=(\w+))*)$)
matches as follows:

NODE                     EXPLANATION
----------------------------------------------------------------------
(?x-ims:                 group, but do not capture (disregarding
                         whitespace and comments) (case-sensitive)
                         (with ^ and $ matching normally) (with . not
                         matching \n):
----------------------------------------------------------------------
  ^                        the beginning of the string
----------------------------------------------------------------------
  (                        group and capture to \1:
----------------------------------------------------------------------
    (                        group and capture to \2:
----------------------------------------------------------------------
      \w*                      word characters (a-z, A-Z, 0-9, _) (0
                               or more times (matching the most
                               amount possible))
----------------------------------------------------------------------
    )                        end of \2
----------------------------------------------------------------------
    ://                      '://'
----------------------------------------------------------------------
    (?:                      group, but do not capture (optional
                             (matching the most amount possible)):
----------------------------------------------------------------------
      (                        group and capture to \3:
----------------------------------------------------------------------
        \w+                      word characters (a-z, A-Z, 0-9, _)
                                 (1 or more times (matching the most
                                 amount possible))
----------------------------------------------------------------------
      )                        end of \3
----------------------------------------------------------------------
      (?:                      group, but do not capture (optional
                               (matching the most amount possible)):
----------------------------------------------------------------------
        \:                       ':'
----------------------------------------------------------------------
        (                        group and capture to \4:
----------------------------------------------------------------------
          [^/\@]*                  any character except: '/', '\@' (0
                                   or more times (matching the most
                                   amount possible))
----------------------------------------------------------------------
        )                        end of \4
----------------------------------------------------------------------
      )?                       end of grouping
----------------------------------------------------------------------
      \@                       '@'
----------------------------------------------------------------------
    )?                       end of grouping
----------------------------------------------------------------------
    (?:                      group, but do not capture (optional
                             (matching the most amount possible)):
----------------------------------------------------------------------
      (                        group and capture to \5:
----------------------------------------------------------------------
        [\w\-\.]+                any character of: word characters
                                 (a-z, A-Z, 0-9, _), '\-', '\.' (1 or
                                 more times (matching the most amount
                                 possible))
----------------------------------------------------------------------
      )                        end of \5
----------------------------------------------------------------------
      (?:                      group, but do not capture (optional
                               (matching the most amount possible)):
----------------------------------------------------------------------
        \:                       ':'
----------------------------------------------------------------------
        (                        group and capture to \6:
----------------------------------------------------------------------
          \d+                      digits (0-9) (1 or more times
                                   (matching the most amount
                                   possible))
----------------------------------------------------------------------
        )                        end of \6
----------------------------------------------------------------------
      )?                       end of grouping
----------------------------------------------------------------------
    )?                       end of grouping
----------------------------------------------------------------------
    /                        '/'
----------------------------------------------------------------------
    (                        group and capture to \7:
----------------------------------------------------------------------
      \w*                      word characters (a-z, A-Z, 0-9, _) (0
                               or more times (matching the most
                               amount possible))
----------------------------------------------------------------------
    )                        end of \7
----------------------------------------------------------------------
  )                        end of \1
----------------------------------------------------------------------
  (?:                      group, but do not capture (optional
                           (matching the most amount possible)):
----------------------------------------------------------------------
    /                        '/'
----------------------------------------------------------------------
    (                        group and capture to \8:
----------------------------------------------------------------------
      \w+                      word characters (a-z, A-Z, 0-9, _) (1
                               or more times (matching the most
                               amount possible))
----------------------------------------------------------------------
    )                        end of \8
----------------------------------------------------------------------
    (?:                      group, but do not capture (optional
                             (matching the most amount possible)):
----------------------------------------------------------------------
      \?                       '?'
----------------------------------------------------------------------
      (                        group and capture to \9:
----------------------------------------------------------------------
        \w+                      word characters (a-z, A-Z, 0-9, _)
                                 (1 or more times (matching the most
                                 amount possible))
----------------------------------------------------------------------
      )                        end of \9
----------------------------------------------------------------------
      =                        '='
----------------------------------------------------------------------
      (                        group and capture to \10:
----------------------------------------------------------------------
        \w+                      word characters (a-z, A-Z, 0-9, _)
                                 (1 or more times (matching the most
                                 amount possible))
----------------------------------------------------------------------
      )                        end of \10
----------------------------------------------------------------------
    )?                       end of grouping
----------------------------------------------------------------------
  )?                       end of grouping
----------------------------------------------------------------------
  (                        group and capture to \11:
----------------------------------------------------------------------
    (?:                      group, but do not capture (0 or more
                             times (matching the most amount
                             possible)):
----------------------------------------------------------------------
      ;                        ';'
----------------------------------------------------------------------
      (                        group and capture to \12:
----------------------------------------------------------------------
        \w+                      word characters (a-z, A-Z, 0-9, _)
                                 (1 or more times (matching the most
                                 amount possible))
----------------------------------------------------------------------
      )                        end of \12
----------------------------------------------------------------------
      =                        '='
----------------------------------------------------------------------
      (                        group and capture to \13:
----------------------------------------------------------------------
        \w+                      word characters (a-z, A-Z, 0-9, _)
                                 (1 or more times (matching the most
                                 amount possible))
----------------------------------------------------------------------
      )                        end of \13
----------------------------------------------------------------------
    )*                       end of grouping
----------------------------------------------------------------------
  )                        end of \11
----------------------------------------------------------------------
  $                        before an optional \n, and the end of the
                           string
----------------------------------------------------------------------
)                        end of grouping
----------------------------------------------------------------------


and my manual explanation for the URI parsing:

^(
                 (\w*)
                 ://
                 (?:
                   (\w+)  # user
                   (?:
                     \:
                     ([^/\@]*)  # passw 
                   )?
                   \@
                 )?  # could not have user,pass
                 (?:
                   ([\w\-\.]+)  # host
                   (?:
                     \:  
                     (\d+)  # port
                   )?  # port optional
                 )?  # host and port optional
                 /  # become in a third '/' if no user pass host and port
                 (\w*)  # get the db (only until the first '/' is any). Will not work with full paths for sqlite.
               )
               (?:
                 /   # if tables 
                 (\w+)  # get table
                 (?:
                   \?  # parameters
                   (\w+)
                   =
                  (\w+)
                 )?  # parameter is conditional but would have always a tablename
               )?  # conditinal table and parameter
               (
                 (?:
                   ;
                   (\w+)
                   =
                   (\w+)
                 )*  # rest of parameters if any
               )
               $
            


Probably this regular expression was easy but while searching for more examples of YAPE::Regex::Explain I found two interesting links about Perl obfuscation with RE at StackOverflow and perl monks threads

Monday, 9 May 2011

malware web page scam today

A friend had a link is its twitter: http://bit.ly/mcHjaZ and when I followed the first time I ended in a malware scam page, that was very convincing. (The second time onwards I was directed to the right page)



I do not know if it was something to do with bit.ly or twitter or the target page (probably the latter), but the page title in the the browser tab was the same for the original linked page. I assume that this is a hijacking javascript injection in the web server of the target page:

[not put as a link to prevent cliking ;-)]
http://dornob.com/mind-warping-wood-folding-chair-looks-curved-packs-flat/

Very frightening.

[update]
Thanks to Karen from my Systems Team here there is a more detailed explanation
http://www.snipe.net/2011/05/rogue-mac-antivirus/

[update 2011-05-30]
Apple has created an entry about this in support.apple.com:


How to avoid or remove Mac Defender malware

Wednesday, 27 April 2011

nice example of a helping community in CPAN

Reading today the Catalyst mailing list I felt a great satisfaction. I saw how having the right attitude, asking the right questions, listening to people, doing your homework and reporting to CPAN authors sometimes gives you satisfactory results.

All happened in this thread:

[Catalyst] building 'local' lib with dependencies for shipping

where Fernan Aguero asked how to pack a catalyst application with all the needed dependencies. The problem is that if you want to do it platform independent you need to do it by setting list of dependencies (and your current versions of modules) and and use a method to automatically install all of them.

One of the solutions was to use Shipwright, created by Best Practical. It didn't work the first run but seemed the right tool so after a few messages more in the list, Fernan contacted with one of the developers and:
[Fernan]
I contacted sunnavy (one of the Shripwright developers) and this is
what he said:

"I found the archive( PerlMagick ) has an interesting files format, which
shipwright didn't handle before.

I just released 2.4.25 to fix this, which will show up in cpan soon.
in case you are hurry, here it is: http://goo.gl/6Jtzz";

Just tested 2.4.25 and shripwright now imported all of the
dependencies for my cat app correctly.

I'm now building my ship :) and will get into testing the catalyst app
running from the vessel soon.

It is nice to see that collaboration works in the Perl world.

Thursday, 21 April 2011

converting ANSI to HTML. How to convert to html the colored shell output

The main aim of this was able to put in html the ouptut of git log and diff.


Googling around I have found that Perl CPAN has the HTML::FromANSI module. Also, this module installs ansi2html which accepts input from stdin.  

ls --color | ansi2html -p > my_web_page.html

ls --color | ansi2html > my_snpipet_code-no_header-footer.html


But I prefer the default output from ansi2html.sh from pixelbeat


Unfortunately the ls --color get properly converted to HTML but the git one not. No matter which script I use. Could it be bacause the color is defined in the config as color.ui=auto?


git diff HEAD master -- ensembl/sql/CVS/Tag | ansi2html -p  > ~/public_html/htdocs_dev/diff1.html

git diff HEAD master -- ensembl/sql/CVS/Tag | ansi2html.sh --bg=dark  > ~/public_html/htdocs_dev/diff2.html


[UPDATE]
Yes! the problem would be that I have in the configuration color.ui=auto because explicitly having --color in the command make it work:

$ git diff --color HEAD master -- ensembl/sql/CVS/Tag | ansi2html.sh --bg=dark > ~/public_html/htdocs_dev/diff3.html

Tuesday, 19 April 2011

new R-pkg version: R 2.13.0

The new R 2.13 is out and contains the package 'compiler'

o Package compiler is now provided as a standard package.  See
      ?compiler::compile for information on how to use the compiler.
      This package implements a byte code compiler for R: by default
      the compiler is not used in this release.  See the 'R
      Installation and Administration Manual' for how to compile the
      base and recommended packages.


See this page for benchmarking on the use of 'compiler' and it also show how the syntax that you use could affect the efficiency of your code! interesting!

This is like the perl /o option in regular expressions,  you compile your function and from now on it run much faster


  > library(compiler)
  > lf <- cmpfun(f)

Some links with tricks for updating your installed modules

Windows
http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/
http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r
Linux

http://nsaunders.wordpress.com/2011/04/15/r-2-12-to-2-13-package-upgrade/



Mac
http://onertipaday.blogspot.com/2008/10/r-upgrade-on-mac-os-x-1055-leopard.html

Sunday, 10 April 2011

git branching model

This is a nice article about git branching model
http://nvie.com/posts/a-successful-git-branching-model/

A Sampling of Linux Desktops/Window Managers

Copied from Linux Journal

The Second-String Desktop

Mar 31, 2011  By Shawn Powers

http://www.linuxjournal.com/article/10946?page=0,2


Table 1. A Sampling of Linux Desktops/Window Managers
Desktop/Window Manager Description Design Goals Based On Advantages Disadvantages
KDE Full desktop environment Full system integration, including applications Uses KWin window manager and Qt libraries Great application integration, highly customizable Distinct look; non-KDE apps often seem awkward
GNOME Full desktop environment Full system integration, including applications Uses Metacity window manager, based on GTK+ libraries Wide variety of native applications, wide adoption in corporate environments Non-GTK apps often look odd and use more RAM
LXDE Lightweight desktop environment Speed and beautiful interface Uses Openbox window manager and GTK+ libraries Works well on older/slower hardware, maintains compatibility Lacks some of the features found in GNOME or KDE
XFCE Lightweight desktop environment Full-featured desktop environment, but light on resources Usually uses XFWM4, but works well with other window managers Somewhat lower system requirements than GNOME or KDE Possibly a bit too resource-hungry for low-end systems
Enlightenment E17 Window manager with the features of a desktop manager Speed and eye candy with integrated functionality A window manager plus a set of libraries for developing apps Fast without sacrificing style Still in beta but quite stable
ROX Desktop Desktop manager based on the ROX-Filer Approaches the OS in a file-centric way ROX-Filer file manager and the OroboBox window manager Unique file-based design makes installing apps drag and drop ROX Desktop is either a love or hate affair
IceWM Hybrid window manager and desktop manager Speed and simplicity Simple menu and taskbar design Fast and easy to make system-wide configuration changes No way to make desktop icons, requires additional software for some features
Blackbox/Fluxbox Very minimalistic window managers Speed and small memory/CPU footprint Fluxbox is based on Blackbox (it's a fork) Blazingly fast Very limited in features, but by design not immaturity
Openbox Very minimalistic window manager Speed and small memory/CPU footprint Originally based on Blackbox, original code since version 3.0 Simple and fast Limited in features by design
AfterStep/Window Maker Clones of the NeXTSTEP interface Functions and looks like NeXTSTEP Designed after the unique design of the NeXTSTEP interface Unique Often difficult to configure, and the interface is an acquired taste
Ratpoison A window manager that doesn't require a mouse Kills the need for a mouse Designed after GNU Screen No need for a mouse Very limited in features, which the developers consider a feature
DWM An extremely minimalist window manager Manages windows and nothing more The ideas of other minimalist window managers Small and fast No configuration files, must edit source code to coconfigure



Resources
AfterStep: www.afterstep.org
Blackbox: blackboxwm.sourceforge.net
CrunchBang Linux: www.crunchbanglinux.org
DWM: dwm.suckless.org
Elive: www.elivecd.org
Enlightenment E17: www.enlightenment.org
Fluxbox: www.fluxbox.org
GNOME: www.gnome.org
IceWM: www.icewm.org
KDE: www.kde.org
Lubuntu: www.lubuntu.net
LXDE: www.lxde.org
Macbuntu: macbuntu.sourceforge.net
Openbox: www.openbox.org
Puppy Linux: www.puppylinux.org
Ratpoison: www.nongnu.org/ratpoison
ROX Desktop: roscidus.com/desktop
Ubuntu: www.ubuntu.com
Window Maker: www.windowmaker.org
XFCE: www.xfce.org
Xubuntu: www.xubuntu.org

Monday, 7 March 2011

Interesting databases in the 2010 NAR issue

NAR 2010 databases


  • Daniel Glez-Peña, Daniel Gómez-Blanco, Miguel Reboiro-Jato, Florentino Fdez-Riverola, and David Posada
            ALTER: program-oriented conversion of DNA and protein alignments
          Nucl. Acids Res. (2010) 38(suppl 2): W14-W18 doi:10.1093/nar/gkq321
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF Supplementary Data
  • Alexey V. Antonov, Esther E. Schmidt, Sabine Dietmann, Maria Krestyaninova, and Henning Hermjakob
R spider: a network-based analysis of gene lists by combining signaling and metabolic pathways from Reactome and KEGG databases
          Nucl. Acids Res. (2010) 38(suppl 2): W78-W83 doi:10.1093/nar/gkq482
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Kunlin Zhang, Sijia Cui, Suhua Chang, Liuyan Zhang, and Jing Wang
i-GSEA4GWAS: a web server for identification of pathways/gene sets associated with traits by applying an improved gene set enrichment analysis to genome-wide association study
Nucl. Acids Res. (2010) 38(suppl 2): W90-W95 doi:10.1093/nar/gkq324

  • Vivek Kaimal, Eric E. Bardes, Scott C. Tabar, Anil G. Jegga, and Bruce J. Aronow
ToppCluster: a multiple gene list feature analyzer for comparative enrichment clustering and network-based dissection of biological systems
Nucl. Acids Res. (2010) 38(suppl 2): W96-W102 doi:10.1093/nar/gkq418
  • Jignesh R. Parikh, Bertram Klinger, Yu Xia, Jarrod A. Marto, and Nils Blüthgen
Discovering causal signaling pathways through gene-expression patterns
Nucl. Acids Res. (2010) 38(suppl 2): W109-W117 doi:10.1093/nar/gkq424
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF Supplementary Data
  • Y.-T. Wang, Y.-H. Huang, Y.-C. Chen, C.-L. Hsu, and U.-C. Yang
PINT: Pathways INtegration Tool
Nucl. Acids Res. (2010) 38(suppl 2): W124-W131 doi:10.1093/nar/gkq499
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF Supplementary Data
  • Ludovic Cottret, David Wildridge, Florence Vinson, Michael P. Barrett, Hubert Charles, Marie-France Sagot, and Fabien Jourdan
MetExplore: a web server to link metabolomic experiments and genome-scale metabolic networks
Nucl. Acids Res. (2010) 38(suppl 2): W132-W137 doi:10.1093/nar/gkq312
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Marija Cvijovic, Roberto Olivares-Hernández, Rasmus Agren, Niklas Dahr, Wanwipa Vongsangnak, Intawat Nookaew, Kiran Raosaheb Patil, and Jens Nielsen
BioMet Toolbox: genome-wide analysis of metabolism
Nucl. Acids Res. (2010) 38(suppl 2): W144-W149 doi:10.1093/nar/gkq404
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Richard Côté, Florian Reisinger, Lennart Martens, Harald Barsnes, Juan Antonio Vizcaino, and Henning Hermjakob
The Ontology Lookup Service: bigger and better
Nucl. Acids Res. (2010) 38(suppl 2): W155-W160 doi:10.1093/nar/gkq331
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Xin He, Yanen Li, Radhika Khetani, Barry Sanders, Yue Lu, Xu Ling, ChengXiang Zhai, and Bruce Schatz
BSQA: integrated text mining using entity relation semantics extracted from biological literature of insects
Nucl. Acids Res. (2010) 38(suppl 2): W175-W181 doi:10.1093/nar/gkq544
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Scott F. Saccone, Raphael Bolze, Prasanth Thomas, Jiaxi Quan, Gaurang Mehta, Ewa Deelman, Jay A. Tischfield, and John P. Rice
SPOT: a web-based tool for using biological databases to prioritize SNPs after a genome-wide association study
Nucl. Acids Res. (2010) 38(suppl 2): W201-W209 doi:10.1093/nar/gkq513
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Ignacio Medina, José Carbonell, Luis Pulido, Sara C. Madeira, Stefan Goetz, Ana Conesa, Joaquín Tárraga, Alberto Pascual-Montano, Ruben Nogales-Cadenas, Javier Santoyo, Francisco García, Martina Marbà, David Montaner, and Joaquín Dopazo
Babelomics: an integrative platform for the analysis of transcriptomics, proteomics and genomic data with advanced functional profiling
Nucl. Acids Res. (2010) 38(suppl 2): W210-W213 doi:10.1093/nar/gkq388
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF Supplementary Data
  • Miguel Vazquez, Ruben Nogales-Cadenas, Javier Arroyo, Pedro Botías, Raul García, Jose M. Carazo, Francisco Tirado, Alberto Pascual-Montano, and Pedro Carmona-Saez
MARQ: an online tool to mine GEO for experiments with similar or opposite gene expression signatures
Nucl. Acids Res. (2010) 38(suppl 2): W228-W232 doi:10.1093/nar/gkq476
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF Supplementary Data
  • Maria José Nueda, José Carbonell, Ignacio Medina, Joaquín Dopazo, and Ana Conesa
Serial Expression Analysis: a web tool for the analysis of serial gene expression data
Nucl. Acids Res. (2010) 38(suppl 2): W239-W245 doi:10.1093/nar/gkq488
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF Supplementary Data
  • Haim Ashkenazy, Elana Erez, Eric Martz, Tal Pupko, and Nir Ben-Tal
ConSurf 2010: calculating evolutionary conservation in sequence and structure of proteins and nucleic acids
Nucl. Acids Res. (2010) 38(suppl 2): W529-W533 doi:10.1093/nar/gkq399
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Gilad Wainreb, Haim Ashkenazy, Yana Bromberg, Alina Starovolsky-Shitrit, Turkan Haliloglu, Eytan Ruppin, Karen B. Avraham, Burkhard Rost, and Nir Ben-Tal
MuD: an interactive web server for the prediction of non-neutral substitutions using protein structural data
Nucl. Acids Res. (2010) 38(suppl 2): W523-W528 doi:10.1093/nar/gkq528
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF Supplementary Data
  • Jiten Bhagat, Franck Tanoh, Eric Nzuobontane, Thomas Laurent, Jerzy Orlowski, Marco Roos, Katy Wolstencroft, Sergejs Aleksejevs, Robert Stevens, Steve Pettifer, Rodrigo Lopez, and Carole A. Goble
BioCatalogue: a universal catalogue of web services for the life sciences
Nucl. Acids Res. (2010) 38(suppl 2): W689-W694 doi:10.1093/nar/gkq394
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Mickael Goujon, Hamish McWilliam, Weizhong Li, Franck Valentin, Silvano Squizzato, Juri Paern, and Rodrigo Lopez
A new bioinformatics analysis tools framework at EMBL–EBI
Nucl. Acids Res. (2010) 38(suppl 2): W695-W699 doi:10.1093/nar/gkq313
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Huabin Hou, Fangqing Zhao, LingLin Zhou, Erle Zhu, Huajing Teng, Xiaokun Li, Qiyu Bao, Jinyu Wu, and Zhongsheng Sun
MagicViewer: integrated solution for next-generation sequencing data visualization and genetic variation detection and annotation
Nucl. Acids Res. (2010) 38(suppl 2): W732-W736 doi:10.1093/nar/gkq302
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF
  • Dougu Nam, Jin Kim, Seon-Young Kim, and Sangsoo Kim
GSA-SNP: a general approach for gene set analysis of polymorphisms
Nucl. Acids Res. (2010) 38(suppl 2): W749-W754 doi:10.1093/nar/gkq428
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF Supplementary Data
  • Zefeng Zhang, Hao Lin, and Bin Ma
ZOOM Lite: next-generation sequencing data mapping and visualization software
Nucl. Acids Res. (2010) 38(suppl 2): W743-W748 doi:10.1093/nar/gkq538
Abstract FREE Full Text (HTML) Full Text (PDF) Screen PDF

Sunday, 20 February 2011

Tell emacs to use git instead svn or cvs when a file is managed by both versions systems.

Stack overflow is wonderfull, I posted a question and it was answered in less than a minute. Was so quick that I needed to wait for 4 minutes before being able to accept it!.

http://stackoverflow.com/questions/5059804/howt-to-tell-emacs-vc-that-i-want-a-file-to-be-managed-by-git-not-by-svn-when-the/5059848#5059848

In short: if you have a file managed by Git and several other versions systems and you want to use emacs VC shortcuts with Git, you need to edit vc-handled-backends and move Git the first one.

'(vc-handled-backends (quote (Git CVS SVN SCCS Bzr Hg Arch MCVS)))

I have also added git.el to my site-lisp

$ cp /usr/share/doc/git/contrib/emacs/git* ~/.emacs.d/site-lisp/

And then added to my .emacs
;; from git.el (complement to vc-git.el)
(require 'git)
(require 'git-blame)

then creating a keybinding (from http://www.michael-hammer.at/blog/emacs_git/)
;keybindindings for git
(global-set-key "\C-xgs" 'git-status)

git.el shortcuts
m - mark the file the cursor is on ATM
M - mark all files in buffer
u/DEL - unmark file below/above
R - resolve conflicts during merge
a - add file to repository
r - remove file
i - add file to ignore list
c - commit
U - Undo -> revert file
l - see log file
g - refresh the status buffer
q - quit status buffer
? - get help!