h1

Why Ruby Matters ?

March 22, 2007

Last week Alexis was wondering about Haskell becoming the future of Rubyists. Reginald Braithwaite, one of the ex-JProbe suite leader, re-read Why Functional Programming matters ? from John Hugues. Although this paper is 23 years old, it is still up-to-date, and the functional paradigms it describes are still applicable. Reginald found out that there were insights that apply to programming language in general :

In a very real sense, the design of a programming language is a strong expression of the opinions of the designer about good programs. When I first read WhyFP, I thought the author was expressing an opinion about the design of good programming languages. Whereas on the second reading, I realized he was expressing an opinion about the design of good programs.

Then Reginald defines what makes a language better or more powerful.

Any feature (or removal of an [harmful] feature) which makes the programs written in the language better makes the language better.

Making an analogy with Mathematics, Reginald compares factoring with the the act of dividing a program into smaller part. The process of breaking a program into distinct features overlapping as little as possible in functionalities is called Separate of Concern (SoC). Programs that separate their concern are well factored. From this fact, Reginald defines the power of programming language :

One thing that makes a programming language “more powerful” in my opinion is the provision of more ways to factor programs. Or if you prefer, more axes of composition. The more different ways you can compose programs out of subprograms, the more powerful a language is.

Structured programming is a way to promote this.

Reginald illustrates his talk with Ruby examples where you can clearly distinguish the separation of concern between the how and the what.

In the end even if Ruby cannot be called a pure functional language, Reginald showed us notably Why… Ruby Matters.

h1

ScreenCast on Linux

March 17, 2007

I needed to do some screencast on my PC. After reading around the net I found vnc2swf and Istanbul. I decided to give a try first to Istanbul as it had a deb package ready. I am a bit reluctant to installing gnome based software and their lib on my KDE but well…
So well, the usual :
sudo apt-get install istanbul
But at launch I would end with :
Traceback (most recent call last):
File “/usr/bin/istanbul”, line 30, in ?
from istanbul.main import main
File “/var/lib/python-support/python2.4/istanbul/main/main.py”, line 33, in ?
from istanbul.main.gconf_client import GConfClient
File “/var/lib/python-support/python2.4/istanbul/main/gconf_client.py”, line 19, in ?
import gconf
ImportError: No module named gconf

I read that it was fixed with later version of Istanbul, So I went to install the new version. But first you’ll need newer libxml2 library aswell (here link for amd64) :
wget http://http.us.debian.org/debian/pool/main/libx/libxml2/libxml2_2.6.27.dfsg-1_amd64.deb
sudo dpkg -i libxml2_2.6.27.dfsg-1_amd64.deb

wget http://http.us.debian.org/debian/pool/main/i/istanbul/istanbul_0.2.1-3_amd64.deb
sudo dpkg -i istanbul_0.2.1-3_amd64.deb

Later if a software require older version of libxml2, you can overwrite the newer you installed with the previous ubuntu version, istanbul should continue to work correctly.
You’re done, you can launch and record through the icon in tray bar.

It’s really easy to use but the output is only OGG Theora and unfortunately web browsers don’t all handle that format.

That’s why I switched to vnc2swf which produces directly flash format.
Couldn’t be easier to install, you need a vnc server, ie :
sudo apt-get install x11vnc
Then install vnc2swf. I installed pyvnc2swf as it’s the one under development and maintained contrary to the C older version.
sudo apt-get install python-tk
sudo apt-get install python-pygame
wget http://www.unixuser.org/~euske/vnc2swf/pyvnc2swf-0.9.1.tar.gz
tar xzvf pyvnc2swf-0.9.1.tar.gz
cd pyvnc2swf-0.9.1/

Now you can launch vnc server :
x11vnc -localhost -viewonly -wait 10 -defer 10 &
And you can launch vnc2swf :
python vnc2swf.py
You might land on this message :
open /dev/sequencer: No such file or directory
You should install kernel module : kernel/sound/pci/emu10k1 as stated here.

h1

Upgrading to Beryl 0.2.0

March 17, 2007

Beryl 0.2.0 is out with many cool features and fixes :

    New Plugins :

  • Thumbnail: Thumbnails on the taskbar (window list) which show a mini view of the actual window
  • Snap: Allows windows to “snap” to each other, or provide edge resistance
  • Opacify: Makes windows behind the active window transparent
  • Group: Allows windows to be group, to easily switch between a set of windows
    New system requirements check :

  • The improved check has much better accuracy
  • The check is a lot faster
    New Window Decorators :

  • Since 0.1, we have two new window decorators
  • Heliodor: Uses metacity themes
  • Aquamarine: Uses Kwin themes.
    Newly Rewritten Beryl-Settings :

  • Written in Python
  • More user-friendly UI
  • Better profile support
    New Translations :

  • Thanks to all of our foreign speaking users, we’ve had a much better time getting translations

Now how to upgrade your version (mine used to be 0.1.4) on your kubuntu edgy ?
Edit your /etc/apt/sources.list and add the following lines :
deb http://ubuntu.beryl-project.org edgy main
deb-src http://ubuntu.beryl-project.org edgy main

Update the list :
sudo apt-get update
And upgrade the following packages :
sudo apt-get install beryl
sudo apt-get install beryl-core
sudo apt-get install beryl-manager
sudo apt-get install beryl-plugins
sudo apt-get install beryl-plugins-data
sudo apt-get install beryl-settings
sudo apt-get install emerald
sudo apt-get install emerald-themes
sudo apt-get install libberylsettings0
sudo apt-get install libberylsettings-dev
sudo apt-get install libemeraldengine0
sudo apt-get install libemeraldengine-dev

Reboot and enjoy!

h1

Ruby / Rails IDE Comparison : Idea, Netbeans, RadRails

February 28, 2007

Starting BlocksWelcome early-early adopters!
Ruby and Rails are getting more and more popular in the community and well known editors start to get into the business for our pleasure!
While my editor of choice for Java has always been Idea (since v2.6 about 6 years ago) as I always found their product avantgardist and really userfriendly and codingfriendly, I wanted to see what was going on in the Rails / Ruby world where I was historically using RadRails and SciTe because of the lack of serious competitors. The simple editors like vim (for the nostaligcs) or SciTE are likely to fit your needs for short and simple scripts but a full IDE is always better to have when you are working on a more important project. The Ruby language itself eliminated a lot of features you would need from an IDE in other languages like Java (For example I am thinking about the Generating Getters / Setters from fields that you get directly with the attr accessors or some long live template public static final String …). The absence of type and the dynamism makes it also impossible for IDEs to do some operations you would do on typed static language (like Java).
Firstly you must notice that apart from RadRails which has been into Rails / Ruby editing for some time, Idea and NetBeans support for Ruby is really fresh (officially) so you should be lenient. You’ll also observe those IDEs tested here are all written in Java (as Plugins). Now you can wonder why not in Ruby ? There are several reasons I guess, notably a lack of serious good looking cross platform gui framework in Ruby (Tk is far from swing and swt quality and anyway it is not Ruby anyway even if that’s the easiest interface to plug with Ruby or Python); Also making an IDE from a well proven platforms guarantees that you’ll benefit from the history and quality of existing software features.
You should also try those IDEs by yourself as an IDE is a day-to-day tool that you learn to use and adopt with time and not with some simple test. That’s why here I’ll mainly compare features.

Read the rest of this entry »

h1

Installing Eclipse with Ruby / Rails support

February 28, 2007

eclipse_logo.gifAs stated in my blog, I am having a look at the most well-known Ruby / Rails IDE competitors.
Thus I had a try on Eclipse platform as I couldn’t get RadRails 0.7.2 Standalone version to work with latest RDT plugins that come with refactoring notably.
Version we will install :
Eclipse 3.2.1 with RDT Stable Release (to have a stable environment) or Nightly Build Plugin (in my case 0.8.0.702111959NGT) to test latest RDT features, and RadRails Plugin 0.7.2
Once you installed Eclipse, you need to install those 2 plugins.
- Help Software Update / Find And Install / Search for new features to Install /
Then Add the new Remote sites :

  • RadRails : http://radrails.sourceforge.net/update
  • RubyPeople Stable Release : http://updatesite.rubypeople.org/release to test main environment. To test latest features like refactoring module, Nightly Builds : http://updatesite.rubypeople.org/nightly

Eclispe Install RadRails PluginEclispe Install RDT Plugin

Once you parametrized the Ruby SDK in the options, you are ready!

h1

Installing Idea with Ruby / Rails support

February 28, 2007

jetbrains_idea_logo.gifAs stated in my blog, I am having a look at the most well-known Ruby / Rails IDE competitors.
Thus I had a try on Idea which I have been using for years in Java/ JEE.
Version we will install :
Idea 6.0 (Support for Idea Selena (future 7.0) is in the pipes) with Ruby Plugin 0.1.1
You should notice that Idea doesn’t show up when you’re running Beryl on Linux, after switching back to KDE Windows Manager you’ll be able to see the window (You can switch back to Beryl Window Manager after), this a known issue with Java (either 1.5 and 1.6) and Beryl. Eclipse will show up as it is in native swt.
Once Idea installed, you’ll need to install to install Ruby Plugin :
- File / Settings / IDE Settings / Plugins / Right-Click on Ruby plugin.

Idea Install Ruby Plugin

You should also edit bin/idea.vmoptions and increase -Xmx192m

You’ll be prompted to set the Ruby SDK. You might encounter problem with symbolic links on linux when browsing to find your Ruby SDK, or when you generate a Rails project with older version of rails that creates symbolic links in vendor/ which will end in infinite parsing of the project.

h1

Installing NetBeans with Ruby / Rails support

February 28, 2007

NetBeans LogoAs stated in my blog, I am having a look at the most well-known Ruby / Rails IDE competitors.
Thus I had a try on NetBeans after seeing screenshot and features from Tor’s weblog, and after having played in Java with UML Module from NetBeans which I found good, I’ll blog about that later…
So, version we will install :
NetBeans 6 Daily Snapshot (I tried from 20070211 to 20070221). For the moment Ruby support is only available for early adopters in the snapshot releases. It was released lately as 6.0 Milestone 7 (and you’ll wait for M8 for some more features)

. Modules I installed (with version I have at the moment) :

  • Common Scripting Language API/Support 0.13.0/0.14.0.1.1.1.1.3
  • Embedded Ruby 0.10.0, JRuby Implementation 0.92.3, Rake-Based Project Support 0.10.0, Ruby IDE Support 0.16.0, Ruby On Rails 1.16.0, Ruby on Rails Project Support 0.13.0, Ruby Projects 0.14.0.1

But latest releases with some more fix/features come with :

  • Common Scripting Language API/Support 0.14.0/0.17.0.1.1.1.1.3
  • Embedded Ruby 0.11.0, JRuby Implementation 0.92.4, Rake-Based Project Support 0.10.0, Ruby IDE Support 0.20.0, Ruby On Rails 1.1600.0, Ruby on Rails Project Support 0.16.0, Ruby Projects 0.17.0.1

You should notice that NetBeans doesn’t show up when you’re running Beryl on Linux, after switching back to KDE Windows Manager you’ll be able to see the window (You can switch back to Beryl Window Manager after), this a known issue with Java (either 1.5 and 1.6) and Beryl.
Once you installed NetBeans Snpashot (or M07), you’ll need to install the Modules :
- Tools / Update Center / Development Update Center (If you don’t have it available you didn’t download a snapshot release).

NetBeans Install Ruby Plugin

After that for some older version of the module you would need to chmod properly the executable from the plugin directory but this has been fixed here.

When you will try to create a rails project directly after NetBeans install and plugin-install you would end with the error :
rubygems.rb:301:in `report_activate_error': Could not find RubyGem activesupport (= 1.3.1) (Gem::LoadError)
The gems activesupport and activerecord are missing, I found it rather strange as I had them installed on my machine.
In fact NetBeans Ruby Module is using an embedded JRuby, that come with some gems (rails, actionmailer…) used for your future NetBeans Ruby / Rails projects. I wonder why activesupport and activerecord have not been included, but anyway with our project we will need to complete this rubygems repository. It’s important to get that well set as it will be scanned and some features like autocompletion will be based on it.

There is an option in Tools / Options / Miscellaneous / Ruby Application to configure Ruby binaries used by the module.

NetBeans Tools / Options / Miscellaneous / Ruby Application

Still options won’t be saved on Windows, you have to manually edit \.netbeans\dev\config\Preferences\org\netbeans\modules\ruby\project.properties to point to your binaries :
ie, for me :
ruby=D:/bin/ruby/bin/ruby.exe
rails=D:/sa/bin/ruby/bin/rails
rdoc=D:/sa/bin/ruby/bin/rdoc
ri=D:/sa/bin/ruby/bin/ri

Congratulations! You are ready, you can relaunch NetBeans and enjoy!
At first launch, the plugin will index Ruby SDK and gems thus taking some minutes.

You’ll find Project Mailing List here.

[EDIT] You can ignore the following workaround as it seems to be corrected with latest versions of the Module since I reported it.[EDIT]

Read the rest of this entry »

h1

Adding a folder to System Menu applet from KDE Task Panel

February 18, 2007

I found it frustrating not being able to add a folder to System Menu in KDE by just right-clicking or through the KDEMenu Editor. After some search, in fact the folders you see in this menu are located in /usr/share/apps/systemview/. To add one you’ll need to :
mkdir ~/.kde/share/apps/systemview/
And copy an existing .desktop, for example media.desktop
cp /usr/share/apps/systemview/media.desktop \
~/.kde/share/apps/systemview/somestuff.desktop

Then just edit the newly created somestuff.desktop by changing Name= and Path= to point on the folder.
On next login to your session it will appear!

New System Menu View

h1

Installing RadRails on Ubuntu Edgy amd64

February 13, 2007

For a future post about Ruby IDE I needed to install RadRails. I did it in the past without problem on windows. Unfortunately the official (and snapshot) versions come with a 32 bits shared library (libswt-pi-gtk-3232.so). So I was landing on an error message quoted later. The only solution I read while investigating on the net was to use RadRails the oldway : install Eclipse and add RadRails and RDT Plugin to it… I didn’t want to download the overbloated eclipse platform while a standalone RadRails version exists which is lighter (still 40MB…) So I convinced myself to get those bloody 64 bits shared libraries to work.
The laziest way is to find a solution without any compilation (compilation of such libraries can be a nightmare when they depend on zillions of projects and I have no fun messing with that anymore).
So let’s go!
Download Eclispe RPC eclipse-RCP-3.2.1-linux-gtk-x86_64.tar.gz from eclipse site.
wget http://sunsite.informatik.rwth-aachen.de/eclipse/downloads/drops/R-3.2.1-200609210945/eclipse-RCP-3.2.1-linux-gtk-x86_64.tar.gz
Untar
tar xzvf eclipse-RCP-3.2.1-linux-gtk-x86_64.tar.gz
Get RadRails (0.7.2 or snapshot) from RadRails site
wget http://www.web20.com/downloads/radrails-0.7.2-linux-gtk.tar.gz
Untar
tar xzvf radrails-0.7.2-linux-gtk.tar.gz
Launch RadRails once (you need to do that to init RadRails configuration)
./radrails/RadRails
An error message will popup :
An error has occurred. See the log file
/del/radrails/workspace/.metadata/.log.

By editing this file you’ll read that a 32 bits shared library is doing some mess
!STACK 1
java.lang.UnsatisfiedLinkError: /del/radrails/radrails/configuration/org.eclipse.osgi/bundles/59/1/.cp/libswt-pi-gtk-3232.so: /del/radrails/radrails/configuration/org.eclipse.osgi/bundles/59/1/.cp/libswt-pi-gtk-3232.so: wrong ELF class: ELFCLASS32
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1660)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)

Backup the existing faulty jar containing the bloody 32 bits library.
mv radrails/plugins/org.eclipse.swt.gtk.linux.x86_3.2.0.v3232m.jar radrails/plugins/org.eclipse.swt.gtk.linux.x86_3.2.0.v3232m.jar.backup
And replace it with the jar you downloaded from eclipse site containing 64bits shared libraries (like libswt-pi-gtk-3235.so)
cp eclipse/plugins/org.eclipse.swt.gtk.linux.x86_64_3.2.1.v3235.jar radrails/plugins/org.eclipse.swt.gtk.linux.x86_3.2.0.v3232m.jar
You can finally relaunch RadRails!

h1

Installing Miro PCTV Remote Control to run with xdtv

February 8, 2007

I was missing my PCTV Remote control from Windows so I couldn’t lazily switch off my pc by air anymore :)
So I decided to install lirc.
I though a simple sudo apt-get install lirc would be enough, but that was not. I wouid get the error message :
could not get file information for /dev/lirc
And indeed /dev/lirc didn’t exist.
So I looked again on the quality ubuntu forum to find the solution that I updated a bit here.
So I decided to install middle-way from apt and oldway.
wget http://prdownloads.sourceforge.net/lirc/lirc-0.8.1.tar.bz2
tar xvjf lirc-0.8.1.tar.bz2
cd lirc-0.8.1/
./configure
# here setup will prompt you
# for your hardware settings :
# PCTV / COM port…
# with a sweet dialog display
# else you should edit /etc/lirc/hardware.conf
# and
# sudo cp /usr/share/lirc/remotes/\
# pinnacle_systems/lircd.conf.pctv \
# /etc/lirc/lircd.conf
make
sudo make install
# backup
sudo mv /usr/sbin/lircd /usr/sbin/lircd-original
sudo mv /usr/sbin/lircmd /usr/sbin/lircmd-original
# if you installed lirc through apt-get previously
sudo rm /dev/lirc
# install the apt-way
sudo apt-get install lirc
# finish the oldway install
sudo make install
# and replace the apt binaries
sudo cp /usr/local/sbin/lircd /usr/sbin
sudo cp /usr/local/sbin/lircmd /usr/sbin

Now that all is installed it’s time to test it.
Launch in one terminal :
sudo /etc/init.d/lirc stop
sudo lircd –nodaemon

And launch in another terminal lirc tool :
irw
Now you can type on your pctv remote and you should see in this terminal some things like :
00031 00 1 PinnacleSysPCTVRemote
00031 00 1 PinnacleSysPCTVRemote
00031 01 1 PinnacleSysPCTVRemote
00031 02 1 PinnacleSysPCTVRemote
00032 00 2 PinnacleSysPCTVRemote

Now you can edit your settings (~/.lircrc) to make it work with xdtv. (.lircrc content doc)
Ok so now you can restart it correctly as daemon.
sudo /etc/init.d/lirc restart