Archive for May, 2007

Laser-Engraved MacBook

Thursday, May 31st, 2007

I want…

Engraved MacBook

More details.

Fedora 7 Released

Thursday, May 31st, 2007

Fedora 7

Fedora, the Linux-based operating system developed as a partnership between Red Hat and the open source community, released version 7 today. This version, code named “Moonshine”, is the first to be 100% developed by the community.

You can get more information about the release and download the new version.

MySQL Surveys

Thursday, May 31st, 2007

InformationWeek has articles about two interesting MySQL surveys.

A survey at last month’s 2007 MySQL Conference & Expo revealed IT specialists’s MySQL wish-list: improved scalability (33%), easier maintenance (23%), increased availability (17%), more throughput (15%). And over 70% would rather have a simple out-of-the-box application rather than custom solutions.

A survey last winter by Evans Data of 517 companies revealed which databases their developers use (obviously, they could pick more than one): Microsoft SQL (61%), MySQL (40%), Microsoft Access (38%), Oracle 10g (22%), Oracle 9i (20%). MySQL’s share rose 8 points from 32% the previous year.

Easy PDFs from Rails

Wednesday, May 30th, 2007

Rails to PDF

Seth Banks at Subimage has made it easy to generate PDFs directly from Rails. Seth uses Prince XML to generate the PDF with some custom Ruby handlers that he wrote. It seems easy, but more importantly, it seems flexible.

I gave it a quick test drive with great results, but I had to make a few modifications that Seth doesn’t make clear. If you want to try it, read his original post, then follow these steps.

(more…)

Rails Documentation

Tuesday, May 29th, 2007

Clip art licensed from the Clip Art Gallery on DiscoverySchool.com

Ruby on Rails documentation has been a source of frustration for many developers.

The official docs at api.rubyonrails.com are a great start. They are generated using RDoc. It’s a pretty slick system that extracts comments embedded in the Rails source code and turns them into HTML pages. Since the documentation exists with the source, it’s easy for the Rails Core team to review the docs while coding and to make quick updates when the source changes. And it’s just as easy for the HTML documentation to include the relevant bits of the actual source code for review.

But there are a few drawbacks in the official documentation too. I’ll review these problems, their solutions and how you can help to improve Rails after the jump. I’ll also show you how you can generate a portable, “offline version” of the documentation.

(more…)

Useful Shell Commands

Tuesday, May 29th, 2007

Nuby on Rails has posted some Useful Shell Shortcuts. I can see how these will come in very handy for me. I’ve been using Unix for over 15 years and I didn’t know all of these tricks!

Never Too Late to Migrate

Friday, May 25th, 2007

Birds Migrating

The O’Reilly Network has an excellent tutorial by Bill Walton on using migrations with Ruby on Rails.

Migrations are a way to manage the evolution of your database schema. (And it will evolve.) As the Rails documentation on migrations explains: “It’s a solution to the common problem of adding a field to make a new feature work in your local database, but being unsure of how to push that change to other developers and to the production server. With migrations, you can describe the transformations in self-contained classes that can be checked into version control systems and executed against another database that might be one, two, or five versions behind.”

Walton’s tutorial steps you through the process using an uncomplicated and conversational approach. You can use Ruby on Rails without using migrations. But if you are in multi-developer or SVN/code-versioned environment, they quickly become essential. If you know they could help you and have been putting it off, then Walton’s tutorial will take all the pain out of getting up to speed quickly.

After his tutorial, you may also want to check out this Migrations Cheat Sheet by Garrett Snider.

Music for Coders

Friday, May 25th, 2007

This week was a slow music week with few new releases of note. Since it is also I long weekend, I’ll keep my post short too.

Notable Music Released This Week

Yep, that’s really it. Because the pickings this week are slim, here’s a list of other somewhat-new releases also worth a listen:

The Good, the Bad and the Ugly

Friday, May 25th, 2007

Kevin Yank has a blog post up at SitePoint about the difference between Good and Bad PHP Code.

Yank says that when he interviews developers for jobs he always asks: “In your mind, what are the differences between good PHP code and bad PHP code?” The answer reveals whether the candidate simply knows the fundamental syntax of the language or whether they understand the additional coding principles necessary to wield that syntax effectively. It also reveals the amount of pain the applicant’s code will cause a development team. He goes on to list “structured”, “consistent”, “portable” and “secure” as some of the key traits of good code and gives a concrete example to illustrate his point.

It’s true for PHP, but his points can also be applied to most programming languages.

Pagination in Rails

Thursday, May 24th, 2007

Pagination

Pagination is extremely important in any web application. Let’s say a client has a database with 10,000 cars for sale. You, the intrepid web developer, are hired to build a web front end to the database. You would never want to return a list of all 10,000 cars at once! When the web browser finished displaying the list (several days later), the user’s eyes would either glaze over from information overload or be left scrolling down the page for miles.

Instead you would opt for a more sensible approach and only return a subset of the list to the user—a “page”. The first page of results might have just 30 cars on it and include a link to the next page. That page would have another 30 cars listed and a link to both the next page and previous page. Or you might decide to show a list of all pages with links to allow the user to skip around. You would probably include a description on the page to communicate what part of the subset a user is viewing (e.g. “Page 1 of 20″ or “Cars 1-30 out of 10,000″). That is pagination.

Google provides a good example of pagination. Search for any word. Look at the top of the page and you’ll see the description of the page results “Results 1 - 10 of about 1,000,000 for…”. Look at the bottom of the page and you’ll see “1 2 3 4 … Next” underneath the expanding o’s in Google. This isn’t the only way to navigate paginated pages, but it illustrates the concept clearly.

Google Pagination

After the jump, I’ll demonstrate three different techniques for performing pagination on database records in Ruby on Rails.

(more…)