Gotchas, Bugs and their Fixes in Kubuntu Jaunty Jackalope (9.4)

April 29th, 2009

Here are my experiences with the brand new Kubuntu Jaunty Jackalope. Of course there are some bugs to fix:

  • Some parts of KDE aren’t repainted. This is a really annoying bug. I don’t know how to describe it so just take a look at the following screenshot:
    KDE display bug

    KDE display bug


    This bug is not really reproducable and I am not sure who to blame for this :) but at least there is a bugfix: Just change the style from Oxygen to something else. I like QtCurve!
  • Make double screen work. Well, I am running an ATI graphics card here on my notebook with the radeon driver:
    $ lspci | grep VGA
    01:00.0 VGA compatible controller: ATI Technologies Inc M64-S [Mobility Radeon X2300]

    Double screen works well if you add the Virtual entry to your xorg.conf:
    Section "Screen"
            Identifier      "Default Screen"
            Monitor         "Configured Monitor"
            Device          "Configured Video Device"
            SubSection "Display"
                    Virtual 3120 1050
            EndSubSection
    EndSection

    . Just sum the widths of your screens as the first parameter and the height of your highest screen as the second one. After this you can move one screen next to the other with: xrandr --output DVI-0 --right-of LVDS

  • Use auth_method: config with phpmyadmin: Entering this:
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = 'foobar';

    in /etc/phpmyadmin/config.inc.php doen’t work as it is ignored completely. I don’t know why, but when you enter

    $dbname='foo';

    in /etc/phpmyadmin/config-db.php it works!

  • Make sure you check out my post Gotchas, Bugs and their Fixes in Kubuntu Hardy Heron (8.4) since some of the points mentioned there are still applicable!

Use rails-footnotes to open files in NetBeans from Firefox

January 16th, 2009

Here is how to use rails-footnotes with NetBeans on linux!

Thanks to José Valim we have a nice new plugin for better debugging of Rails applications! In his blog post he describes how to open links to files on your hard disk with notepad++ on windows. I adapted this idea for opening files with netbeans on linux, and here is your way to go:

open about:config in firefox and add:

  • string network.protocol-handler.app.editor with content ~/.editor.rb
  • bool network.protocol-handler.external.editor and set it to true

create the file ~/.editor.rb and make it executable:

touch ~/.editor.rb && chmod +x  ~/.editor.rb

And here is the content:

#!/usr/bin/ruby
file = ARGV.first.split('file://').last.split('&').first
line = /\&line\=(\d+)/.match(ARGV.first)[1] rescue 0
`"/path/to/your/netbeans-dir/bin/netbeans" "#{file}:#{line}"`
`wmctrl -a "NetBeans IDE"`

install wmctrl

sudo aptitude install wmctrl

We’ll need this to give focus to the NetBeans window.

Use to_money to convert a string to an integer

November 3rd, 2008

Just a quick note: You can use the following code in your helpers/application_helper.rb to convert a string to an integer in your Rails application:

class String
  def to_money
    fee = self.match(/(\d+)(,|.?)(\d{0,2})/)
    if %w(, .).include?(fee[2]) # 56,99 1.00 5,-
      return "#{fee[1]}#{fee[3].to_i.to_s.ljust(2, '0')}"
    elsif fee[1] && fee[2].blank? # 5
      return "#{fee[1]}00"
    end
  end

  def to_money!
    self.replace to_money
  end
end

Now you can do some fancy stuff like the following:

"12 Euro".to_money => 1200
"12 Dollar".to_money => 1200
"12.00 Dollar".to_money => 1200
"12,00 Euro".to_money => 1200
"12,- Euro".to_money => 1200
"1200 Euro".to_money => 120000
money = "12,8 Euro"
money.to_money!
puts money # => 1280

You can read about the motivation why to use integer in favor of decimals in the database here: 7 Top Tips for Coding With Currency.