Do you need a cheap dedicated server?

Sign-up for Firefox Download Day

Download Day 2008

Jun 05 2008 08:24 am | ruby | No Comments »

SOA with Ruby

My eRubycon 2007 slides are on Slideshare. Service-Oriented Architecture with Ruby. Covers open-source libraries that make web services possible on Ruby.

Nov 20 2007 11:53 am | enterprise and ruby | No Comments »

8 things Mac OS could do better

Mac OS TigerAfter 4 years of Ubuntu Linux, I am finally getting comfortable with Mac OS. Here’s my list of things that I think will make Mac OS a better OS for me, a long-time Linux user.

Disclaimer: I not a Mac expert by any means. Please feel free to enlighten me.

1. Better X11 and GNOME support

X11 applications don’t look and feel anything like native OS X applications. Try Inkscape on Mac and you’ll know what I mean. Applications have to be refactored to use carbon, e.g. GIMP and NeoOffice, to make them look native (bad!). The fact that all X11 programs run under the master X11 application is really annoying and unnecessary. I’d like to see the GTK libraries and GNOME infrastructure be available for Mac by default, or at least part of the X11 distribution, so that developers can use tools like autoconf to build the application. I have no idea how difficult GNOME within Mac would be but I really like to see it happen. I want to be able download and compile my favorite GNOME application and have it look and feel like a native Mac OS application, as much as possible. Hey, if you can make GNOME look like Mac OS, why can’t Apple make GNOME look like Mac OS? Another advantage of adding GNOME infrastructure is the ability to run .NET applications through Mono.

2. Better out-of-the box personalization

Metacity is way more customizable than Carbon/Cocoa. Just look at gnome-look.org. I want to personalize my desktop and not have to pay extra. Tiger only comes with two color schemes, blue and gray. Weak! I would like to see real themes, out-of-the-box.

3. Consistent look and feel

For an OS that blazes the trail on UI design, it’s really disappointing to see the inconsistent look and feel. The first thing I noticed after booting up my Mac was that Safari, Finder, iTunes, they all look different, i.e. Brushed metal vs. not. This is being fixed in Leopard.

4. Software package management

Synaptic on UbuntuMacPorts is a start but nothing like the Ubuntu repositories. I do like the .app format. All app related files in one place. I don’t like that Mac installation programs have to scan the harddrive for existing versions or dependencies. I would love to see something like Synaptic and be able to install my software using one-click or one command on a fresh Mac.

5. Make Darwin more Unix-like

I love the fact that bash, vim, grep, awk, ssh, etc. are installed by default. But I find the Mac file structure dis-orienting. For example, why is it so complicated to create a script to run during initialization? A subsystem that supports System V-style init scripts would be great, even if it runs after the core Mac OS-initialization. Better coherence with Linux directory structure will also be very helpful.

6. Make Firefox the default browser

Apple should stop wasting energy on Safari. Firefox runs everywhere. IE dominates the Windows world. We don’t need yet another browser with it’s own little quirks. Apple should embrace Firefox, improve it where it’s lacking and submit the code upstream. If Apple really wants their own browser, they should at least use the Gecko engine so we get consistent behavior. I really don’t think a minor performance improvement is worth all the compatibility trouble.

7. Install NeoOffice by default

Apple is all about giving you everything you need to get going. This is more true for Linux than it is for Mac. Where are my productivity tools on the Mac? Unless legally bound by Microsoft’s investment, Apple should just include NeoOffice. And hire those brilliant NeoOffice guys while they’re at it. Keynote and Pages are nice, they can remain options for paid upgrade.

8. Let Sun take care of Java

As of June 2007, there’s still no Java 6 for Mac. That’s a real shame, considering how important Apple claims Java is to them. My advice, give up and give it back to the experts. I know Apple and Sun work together on this to make Java integrate well with Apple. From what I can see, I don’t think the integration is that special and I see no reason why Sun couldn’t do it themselves. However they want to solve this problem, between Sun and Apple, please keep up with Java releases.

That said, Mac OS is a great OS for developers. Linux users will find more things in common with Mac as compared to Windows. I was planning to Bootcamp my Mac with Feisty but after a few days of OS X, I ended up staying. Keep up the good work guys. Leopard is looking good!

Related posts:

Jun 26 2007 04:33 pm | apple and linux | 8 Comments »

Leopard delayed. Time to get a Mac.

I was so excited to get a new MacBook Pro with Mac OS X Leopard for my birthday (April). Days went by, no news on the new operating system. Until now. Apple just announced that Leopard is not to be released until October.

This is hard for me because I’ll *have* to upgrade. I can’t tolerate being behind on OS releases and I don’t like paying for OSs either. If my killer Ubuntu Linux OS is free, why pay for others? I guess I’ll make an exception this time and pay up just like the rest of Apple junkies.

Wondering why I am getting a MacBook Pro when I love Ubuntu? Two reasons: (1) I love Apple’s hardware design, and (2) I want to be able to run my favorite Adobe applications natively, not virtualized. I will be dual-booting between Leopard and Feisty.

Apr 14 2007 03:13 pm | apple | No Comments »

Family2.0 Famiva is live, FINALLY!

After many months of working nights and weekends, Famiva is finally ready for public beta! So, what is Famiva anyway? It’s a free social network and collaboration service for families. Basically, it’s a web site that allows you build your family tree. Every relative you add will get the ability to complete their family tree by adding their relatives, and so on. Everyone works together and collaborates to build the “family network”.

Famiva is also a private portal. Features include photo sharing, comments, member profiles, family calendar, maps of photos and people, stories, events, reminders and more. The family network is tightly integrated with tools that let you share information with your extended family, keep track of who’s who and what’s going with everyone. For example, click on a member anywhere to see profile, their immediate family, the 3-level family tree or the entire family network. You can relate photos and stories to people, see them on the world map, etc.

I think Famiva demonstrates how Ruby on Rails can be used to develop complex web applications with non-trivial data structures (graphs) and Java integration. It also a nice use case for Ajax, Google Maps and Flickr integration.

To learn more about Famiva, check it out for yourself at http://famiva.com and visit the Famiva Blog.

Mar 21 2007 01:00 pm | java and rails and ruby and social networks | 3 Comments »

Edgy on Rails? Get compiling!

Love Ubuntu and want to run a Rails server on Edgy Eft (Ubuntu 6.10)? Roll-up your sleeves for some "compiling from source" fun.

Please note that Ubuntu Fiesty Fawn has been released. It comes with Apache 2.2. If you can, avoid all this compiling and just sudo apt-get dist-upgrade!

Rails development on Ubuntu is a breeze, you can apt-get all the stuff you need. From Ruby 1.8.4 and MySQL driver to ImageMagick, the official repositories have got you covered. Deployment is another story. The bad news is that stuff that comes with Edgy just doesn't work, the good news, compiling stuff in Ubuntu, and Debian in general, is really easy.
Where's what we need to compile:

Apache 2.2

Because you can't do serious Rails deployment without a Mongrel cluster, and Mongrel needs a Load Balancing Proxy so that browsers can connect to the standard port 80. Ubuntu comes with Apache 2.0, which is no good because mod_proxy_balancer was not introduced until Apache 2.2. We need to grab Apache 2.2.x from the source and compile it ourselves.

Note: You _can_ use lighttpd but I wouldn't use it's mod_proxy plug-in. Why? Because it's load balancing bit is buggy and Zed says so. If you must use lighty, use Pound to do the load balancing (see below).

No point re-inventing the wheel, the good folks at Starman will show you how to build Apache 2.2. Don't have time to read? Simply get the latest Unix source from the Apache download site. Get some stuff from Ubuntu universe:

CODE:
  1. sudo apt-get install build-essential libpcre3-dev libssl-dev libdb4.3-dev libneon25-dev

Remove existing Apache package, untar the Apache source and run:

CODE:
  1. ./configure --enable-deflate --enable-proxy --enable-proxy-html --enable-proxy-balancer --enable-rewrite --enable-cache --enable-mem-cache --enable-ssl --enable-headers --enable-logio

Followed by

CODE:
  1. make ; sudo make install

This will install Apache 2.2.3 in /usr/local, which is where I like it because it doesn't get confused with Ubuntu maintained stuff. You will have to point your /etc/init.d/apache to the new apachectl.

Pound

Pound is a decent standalone load balancer. You can learn more about using Pound with Mongrel here. One advantage here is that you can use lighttpd as a web server + proxy and let Pound do the balancing. It is quite configurable and comes standard with Ubuntu. Well, sort of. The Ubuntu Edgy package doesn't work very well. In my case, it kept crashing without any warnings. If you do want Pound, you will have to compile from source. Rob Orsini explains how to setup lighty, Pound and Mongrel here. Long story short, download Pound and untar (tar xfz) it.

CODE:
  1. sudo apt-get install libpcre3 libpcre3-dev
  2. ./configure; make ; sudo make install

Memcached

Memcached is an in-memory cache that can help take the load off your database. I was attempting to use memcache as my Rails session store but the standard Edgy package refused to work for me. Rails would complain that my session was expiring within a few navigations. This would only occur under a Mongrel cluster; a single Mongrel or Webrick would have no problems. Strange.

So I got the latest memcached source and repeated the compile drill:

CODE:
  1. sudo apt-get install libevent-dev
  2. ./configure; make; sudo make install

This fixed the problem but for some reason memcached would occasionally halt for several seconds, making my site slower rather than faster. I finally gave up on memcached and decided to settle for SqlSessionStore, which works like a champ! If any of you have insight or experience with this issue, please let me know.

All this compiling, albeit easy, should not be needed. The biggest downside of compiling is that you don't get to apt-get upgrade things. You could be missing out on a critical patch. If only the Ubuntu package maintainers would stay current, or someone (like you and me) would just take some time to build DEBs and publish a "Ubuntu on Rails" repository.

Jan 11 2007 10:58 pm | linux and rails and ruby | 4 Comments »

SD Times - Rails for Tactical Business Applications

SD Times recently published my article on Tactical Business Applications with Ruby on Rails. It discusses the advantages of using Rails to fulfill enterprise business needs.

Get the full article here: SD Times - Rails for Tactical Business Applications

Jan 11 2007 10:44 pm | enterprise and rails and ruby | No Comments »

Using MySQL Full Text Search with Rails

MySQL offers powerful out-of-the-box full text search capability. It allows you to do advanced search on text columns such as:

apple +computer -fruit

As of Rails 1.1.6, working with MySQL Full Text search is not that straight forward. The first problem is that Migrations doesn't support the SQL syntax for full text indexes. Your create table class has to to two things.

  1. Set the table options to "ENGINE=MyISAM"; the default InnoDB doesn't support FULL TEXT.
  2. Execute the native DML to create the INDEX.

Here's a complete example:

RUBY:
  1. create_table("stories", :force => true, : options=> "ENGINE=MyISAM") do |t|
  2. t.column("subject", :string, :limit => 150)
  3. t.column("created_at", :timestamp)
  4. t.column("created_by_member_id", :integer, :limit => 10)
  5. t.column("happened_on", :date)   t.column("body", :text)
  6. end
  7. add_index "stories", ["created_by_member_id"]
  8. #Create MySQL specific full-text index
  9. execute "CREATE FULLTEXT INDEX FullText_Stories ON stories (subject, body)"

That takes care of the Migration part. No big deal, you can't expect Migrations to support all the specific features of all database engines. The second problem has to do with Unit Testing. Rails schema dumper will fail to recognize the full text index and will try to generate a regular index. However, MySQL will not like creating an index on the TEXT data type, and your full text tests will fail as well.To resolve this problem, we will have to fixenhance the schema dumper located at ./active-record-1.*.*/lib/active_record/schema_dumper.rb under your Ruby gems or vendor (if you've frozen Rails) directory. The adapter can not tell us if we are using full text index, so we'll have to improvise and use a naming convention. Assuming all your full text indexes are prefixed with "FullText_", we can check for it and generate the appropriate schema.rb.

Here's the replacement code for the indexes method in schema_dumper.rb:

RUBY:
  1. def indexes(table, stream)
  2. indexes = @connection.indexes(table)
  3. indexes.each do |index|
  4. if index.name=~/FullText_/ and @connection.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
  5. stream.puts <
  6. execute "ALTER TABLE #{index.table} ENGINE = MyISAM"
  7. execute "CREATE FULLTEXT INDEX #{index.name} ON #{index.table} (#{index.columns.join(',')})"
  8. RUBY
  9. else
  10. stream.print "  add_index #{index.table.inspect}, #{index.columns.inspect}, :name => #{index.name.inspect}"
  11. stream.print ", :unique => true" if index.unique
  12. stream.puts
  13. end
  14. end
  15. stream.puts unless indexes.empty?
  16. end

We check to make sure the database adapter is MySQL for good measure. That should do the trick. But wait! Don't modify the Rails code, use the plug-in instead! You can download the Rails 1.1.6 plug-in here. Drop it in your Rails vendor directory and enjoy full-text search with MySQL.

ActiveRecord MySQL Full Text Plugin

Nov 20 2006 04:40 pm | rails and ruby | 6 Comments »

Making Firefox work with Dual Screen on Linux

While attemping to use Firefox in dual screen mode on my Ubuntu Linux, I encountered this annoying problem: If you launch Firefox on one screen, you can't launch it on the second screen (unless you are using Clone to Big mode). When you launch Firefox on the second screen, it complains about the profile being in use.

Here's quick solution:

  1. Close all Firefox windows and run the following on your terminal:
    firefox -ProfileManager
  2. Create a new profile, say "Second Screen." Keep the checkbox "Don't ask on startup" selected and click "Exit".
  3. On your secondary monitor, modify the Firefox launcher by right clicking on the icon on your Panel and selecting "Properties". Change the "Command" to:
    firefox %u -p SecondScreen
  4. That's it. Enjoy indepently configurable Firefox on both screens now!
Oct 20 2006 01:57 pm | linux | 3 Comments »

Publising Rails Plug-ins with Rake

Problem: The Ruby on Rails plug-in installer's RecursiveHTTPFetcher makes certain assumptions about web servers that does not hold true from server to server. For example, it assumes:

RubyForge web server is an example of where these assupmtions don’t hold true. As a result, you can not simply copy your files to a web server and expect Rails HTTP plugin installer to just work.

Solution: Rails Plug-in Package Task

RailsPluginPackageTask is a Rake task designed to automate the publishing of Ruby on Rails plug-ins. It helps fill the gap by conforming to the Rails plug-in script's assumptions. Following the Rake package task conventions, it defines the "rails_plugin" task that recurses through your package_files, generates compliant index.html for each folder (that contains a file), and creates a directory structure that you can publish as a set for your plugin.

Example

The following example uses the Rake::RailsPluginPackageTask to create the package. It then uses the Rake::SshDirPublisher to publish the plugin directory to RubyForge.

RUBY:
  1. Rake::RailsPluginPackageTask.new(ProjectInfo[:name], ProjectInfo[:version]) do |p|
  2. p.package_files = PluginPackageFiles
  3. p.plugin_files = FileList["rails_plugin/**/*"]
  4. p.extra_links = {"Project page"=>ProjectInfo[:homepage],
  5. "Author: #{ProjectInfo[:author_name]}"=>ProjectInfo[:author_link]}
  6. p.verbose = true
  7. end
  8. task :rails_plugin=>:clobber
  9.  
  10. desc "Publish Ruby on Rails plug-in on RubyForge"
  11. task :release_plugin=>:rails_plugin do |task|
  12. pub = Rake::SshDirPublisher.new("#{RubyForgeConfig[:user_name]}@rubyforge.org",
  13. "/var/www/gforge-projects/#{RubyForgeConfig[:unix_name]}",
  14. "pkg/rails_plugin")
  15. pub.upload()
  16. end

You can download the ZIP package for this task and place it in your gems or project folder. For a complete working example, checkout ROXML from CVS.

Note: This release has only been tested on Linux. If it doesn't work on your OS, please let me know.

Jul 03 2006 11:05 am | rails and ruby | 2 Comments »
Next Page »