piątek, 10 czerwca 2011

Ruby: installing mysql2 gem on Ubuntu 11.04

I have just faced problem with the installation of the mysql2 gem on my newly installed ubuntu 11.04 natty box.

Fortunately I was abel to solve it by installing the following additional packages:
  • libmysqlclient-dev
  • libmysql-ruby1.9
  • ruby1.9.1-dev
Afterwards the installation/compilation of native code went through fine - although there is some error reported during installation of rdoc but it does not affect the library itself (only the documentation might be corrupted - seems to be a bug). Below the list of commands invoked in my environment:

root@krystianekb:/var/log# apt-get install libmysqlclient-dev
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
  libmysqlclient-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,174 kB of archives.
After this operation, 9,839 kB of additional disk space will be used.
Get:1 http://pl.archive.ubuntu.com/ubuntu/ natty/main libmysqlclient-dev amd64 5.1.54-1ubuntu4 [3,174 kB]
Fetched 3,174 kB in 12s (256 kB/s)                                            
Selecting previously deselected package libmysqlclient-dev.
(Reading database ... 147843 files and directories currently installed.)
Unpacking libmysqlclient-dev (from .../libmysqlclient-dev_5.1.54-1ubuntu4_amd64.deb) ...
Processing triggers for man-db ...
Setting up libmysqlclient-dev (5.1.54-1ubuntu4) ...

root@krystianekb:/var/log# apt-get install libmysql-ruby1.9 ruby1.9.1-dev
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Note, selecting 'libmysql-ruby1.9.1' for regex 'libmysql-ruby1.9'
The following NEW packages will be installed:
  libmysql-ruby1.9.1 ruby1.9.1-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,222 kB of archives.
After this operation, 4,071 kB of additional disk space will be used.
Get:1 http://pl.archive.ubuntu.com/ubuntu/ natty/universe libmysql-ruby1.9.1 amd64 2.8.2-1 [55.8 kB]
Get:2 http://pl.archive.ubuntu.com/ubuntu/ natty/universe ruby1.9.1-dev amd64 1.9.2.0-2 [1,166 kB]
Fetched 1,222 kB in 4s (249 kB/s)         
Selecting previously deselected package libmysql-ruby1.9.1.
(Reading database ... 147898 files and directories currently installed.)
Unpacking libmysql-ruby1.9.1 (from .../libmysql-ruby1.9.1_2.8.2-1_amd64.deb) ...
Selecting previously deselected package ruby1.9.1-dev.
Unpacking ruby1.9.1-dev (from .../ruby1.9.1-dev_1.9.2.0-2_amd64.deb) ...
Setting up libmysql-ruby1.9.1 (2.8.2-1) ...
Setting up ruby1.9.1-dev (1.9.2.0-2) ...
 

root@krystianekb:/var/log# gem1.9.1 install mysql2 
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.2
1 gem installed
Installing ri documentation for mysql2-0.3.2...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.3.2...
Enclosing class/module 'mMysql2' for class Client not known
root@krystianekb:/var/log#

wtorek, 7 czerwca 2011

Ruby: umlify - generate UML model out of the source code

Recently I was looking for some way to generate the UML model out of the source code since I believe this is the best way to keep it up to day (and also the only way ;)). It seems that there is already a gem available that can be used for that purpose - it is called umlify.

In order to install it one needs to invoke:

# gem install umlify
Successfully installed sexp_processor-3.0.5
Successfully installed ruby_parser-2.0.6
Successfully installed umlify-1.2.6
3 gems installed
Installing ri documentation for sexp_processor-3.0.5...
Installing ri documentation for ruby_parser-2.0.6...
Installing ri documentation for umlify-1.2.6...
Updating class cache with 2570 classes...
Installing RDoc documentation for sexp_processor-3.0.5...
Installing RDoc documentation for ruby_parser-2.0.6...
Installing RDoc documentation for umlify-1.2.6...

That's it - now it is only to invoke it. If it is on your path the just invoke:
# umlify ./IpStatistics/*.rb

Afterwards the uml.png image containing the UML model will be generated. Below I enclose example part of the UML generated out of my IpStatistics project.

czwartek, 2 czerwca 2011

Gource: visualization of changes in your project


Today I discovered a nice tool Gource (http://code.google.com/p/gource/) that in a graphical way presents the changes done over time in your project. It currently supports the most popular source control systems (e.g. svn, git, mercurial).

What one needs to do in order to generate a nice looking vid (like the one attached below that represents my IpStats project)? Not much:
  1. Download and install gource from the URL provided above (Windows and Linux versions available)
  2. Checkout the project (e.g. svn co )
  3. Invoke gource: krystianek@ubuntu:~/projects$ gource -800x480 IpStatistics/
  4. Or generate mp4 vid using gource and ffmpeg:
krystianek@ubuntu:~/projects$ gource -800x480 IpStatistics/ -o - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -threads 0 IpStats_800x480.mp4
 

The quality is not perfect but shows the main idea - I guess it is due to the compression used on blogger because the original quality is much, much better ;)

One remark is that the ffmpeg shall support the x264 codec (which was not the case for the package from repository on my ubuntu box). All is needed to do it on ubuntu box can be found here: http://ubuntuforums.org/showthread.php?t=786095