Posts tagged with macos - page 5

Getting started with Ruby on Rails on Mac OS X

Choosing your Ruby packages

I have decided to get to grips with Ruby on Rails and get it set-up on my MacBook Pro. There seem to be a variety of options available:

  1. Use Locomotive – an all-in-one standalone developer package
  2. Official sources – configure, compile and install each
  3. MacPorts – package management for free software
  4. Fink – package management for free software

As Scott Stevenson points out this is too many options for a system that is described as Convention over configuration.

As I already use Fink for installing the majority of free software on my Mac I decided I’d go with that. At least until Leopard ships with Ruby on Rails in-the-box.

Preparing Fink

GrinGod gave me a heads-up that we’ll need to turn on the unstable packages to get the gems package and latest version of Ruby. The details are in the Fink FAQ but in summary:

fink configure

And choose the option for unstable trees. Then type:

fink selfupdate
fink index
fink scanpackages

And make sure you have rsync or cvs updating turned on to get the descriptions.

Ruby (via Fink)

Ruby is the language we wish to use and Fink currently supports 1.6 and 1.8 The following commands will install 1.8 for us and the Ruby Gems package management system:

fink install ruby
fink install rubygems-rb18

Rails (via Gem)

Now we need the Rails web framework which will be installed using gem.

gem install rails --include-dependencies

Choosing your web server

There are a number of options available again here including Apache, LightTPD and Mongrel. I wanted to give LightTPD a shot as it is on Fink and less of a beast than Apache. I tried various combinations but even having installed the lighttpd-fastcgi module I couldn’t get the fastcgi gem to do anything but spew errors so Mongrel it is.

Mongrel (via Gem)

Back at that Terminal window type:

sudo gem install mongrel --include-dependencies

Select the mongrel 1.0.1 (ruby) and fastthread 1.0 (ruby) options as prompted.

Testing Ruby, Rails & Mongrel

Again at the Terminal window:

rails mytest

A number of files should be created if Ruby & Rails are working correctly. Now type:

cd mytest
script/server

You should see a line stating Starting Mongrel listening at 0.0.0.0:3000

Open your browser of choice and navigate to http://localhost:3000

Choosing a database

You can go with MySQL, PostgreSQL or SQLite from Fink alone. I went with MySQL for a change.

MySQL 5.0

Whilst Mac OS X Server comes with MySQL the standard edition does not. Rather than use the Fink port I went with the official MySQL 5.0 package primarily to get the preferences pane that allows me to start and stop it as required however it also includes a helpful monitoring widget.

To install download and run the MySQL…x86 package.

Copy MySQL.prefPane to /Library/PreferencePanes and re-open System Preferences. Head into the new MySQL pane and start MySQL up.

MySQL Tools

To manage MySQL and download the Mac OS X version of the GUI management tool.

Run the MySQL Administrator application and connect to localhost on the default port of 3306 with the user name root and a blank password. Don’t forget to change the password by heading over to the Account pane.

Ruby with MySQL

Install the native Ruby to MySQL library to improve db performance by heading back to the Terminal window and executing:

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Select the option for mysql 2.7 (ruby)

Testing the database

As MySQL doesn’t include a sample database head into MySQL Administrator and into the Catalogs pane. Create a new database by pressing the + button and giving it the name mytest.

Select mytest from the left then choose Create Table… from the Table Actions drop-down list.

Enter the table name products then use the + button to create the following columns:

Name Type Primary Key? Nullable? Auto Increment?
id INT Y N Y
name VARCHAR(255) N N N

Click Apply, Execute, OK then Close.

Go to the Terminal window and cd into the mytest folder you generated earlier.

Edit the config/database.yml file using nano or TextEdit and change the database name from mytest_development to mytest. You will also need to enter the password here – either for your root account or ideally a special application-specific account you set-up in MySQL Administrator.

Back at the trusty Terminal execute:

script/generate scaffold product
script/server

Now open your browser to http://localhost:3000/products/ and try creating, editing and deleting some products.

Next steps

And of course trying to find an editor/IDE that supports Ruby as Xcode certainly doesn’t and TextMate costs money (I’m happy to pay for things when I’m committed to the tech – not before)

[)amien

Font rendering philosophies of Windows & Mac OS X

Jeff Atwood asked What’s Wrong With Apple’s Font Rendering? and as I answered in the comments it comes down to philosophy:

The primary difference is that Microsoft try to align everything to whole pixels vertically and sub-pixels horizontally.

Apple just scale the font naturally – sometimes it fits into whole pixels other times it doesn’t.

This means Windows looks sharper at the expense of not actually being a very accurate representation of the text. The Mac with it’s design/DTP background is a much more accurate representation and scales more naturally than Windows which consequently jumps around a lot vertically.

Jeff and Joel both wrote follow up posts agreeing that it is one of philosophy but both are of the opinion that the Windows pixel-grid approach is the better whilst our displays are only capable of low dots-per-inch (DPI).

What they don’t seem to appreciate is the compromise this causes.

Here is an example of Times New Roman on Windows (left) and Mac OS (right) scaled over whole point sizes with sub-pixel precision:

Font scaling on Windows and Mac OS X

The two thing to note here arising from this “pixel-grid is king” approach are

  1. Windows does not scale fonts linearly as the rough line points out
  2. Windows scales the height and width but not the weight of the font

Neither of these may matter to a casual user but for professionals preparing material destined for high DPI (film or print) then it’s a world of difference. How can you layout a page on-screen and expect the same result on the page when the font isn’t the same width?

The issue is reminiscent of the “I hate black bars on wide-screen films” brigade who believe that the film should be chopped, panned, scaled and otherwise distorted from the artists original intention simply so that it fits better on their display.

Typography has a rich and interesting history developed and honed over centuries. It is a shame to misrepresent typefaces especially as the pixel-grid approach becomes less relevant as displays reach higher resolutions.

Update

Some additional comparisons and a note that the gamma differences between Windows and Mac will affect how you see the “other” systems rendering on your machine.

Further update (21 August 2007)

Thanks to Daring Fireball and ZDNet we’ve had a few more great comments which I’ve summarized here:

George thinks the philosophy idea is wrong because “What percentage of Mac users sit around all day doing nothing but pre-press work?” but as Fred points out Microsoft’s desktop-user optimized rendering ends up on images and videos all over the web, thus escaping the environment for which it was crippled.

George also claims that Vista’s rendering is improved, I can’t vouch for that one way or another but from looking at his screen shots the difference there could simply be the contrast level as adjusted by the ClearType tuner.

Nathaniel believes that it’s not Microsoft’s job to manipulate a typeface and that if you want on-screen readability then choose a font designed for that such as Microsoft’s own Tahoma or Apple’s Lucida Grande.

I’d go further and say that Microsoft’s own aggression in sticking to the grid kills font choice at the regular reading size of 10/11 point by optimizing everything to a generic sans or serif look:

Windows XP

Windows fonts around 11pt in ClearType

Mac OS X

Mac OS X fonts around 13pt in Medium (Best for LCD)

James points to an article called Texts Rasterization Exposures that proposes a combination of using vertical hinting only and calculating horizontally to 256 levels and has some convincing screen-shots showing the benefits. Probably too late for Leopard or Vista SP1 though.

[)amien

More free gems for the Mac

It must be that time again already… here we go!

MagiCal

Everyone needs a calendar to hand. In Windows using the time in system bar seems to be the quickest option although it’s obviously not meant for that and one false click sends you to the future.

Vista and OS X come with widgets to do this but there is something just satisfying about this calendar-in-the-menubar app.

AppDelete

Mac OS X comes with a built-in package installer that won’t uninstall applications. Curiously NextStep had just that but it never came across to OS X with everything else although the installer does still write the receipts (logs).

Perhaps Apple believe dragging the .app to the trash is enough but if you like to also junk the various other files occasionally held in places such as in /Library/Application Support/ then AppDelete is for you.

App Update widget

This cool widget checks Apple, MacUpdate and VersionTracker for new versions of the applications you have installed and lets you download with a couple of clicks.

It’s a little buggy sometimes at recognizing you already have that version especially when the developers use build numbers etc. but the author anticipated this so there is a “yeah that’s the version I have” option to let it know.

kuler color widget

Adobe’s web site exists to help you create sets of 5 matching colors, name them, share them and rate them. It’s the Flickr! of color palettes and comes with a handy widget for OS X.

[)amien

Parallels Desktop 3036 beta build out

Parallels have released a beta build of their excellent virtual machine for the Mac and it’s loaded with cool new features. Once out of beta it will be a free upgrade to existing owners.

The feature list runs something like this:

  • Drag & drop files between Finder & Explorer for copying
  • Boot from the Boot Camp partition (will require another activation and you loose suspend VM)
  • Read/Write to the Boot Camp partition (NTFS or FAT)
  • Use Mac clipboard cut/copy/paste short cuts in Windows (opt XCV)
  • Graphics performance increases of up to 50%
  • Windows auto resizes to Mac window size (about time)
  • Coherence mode puts Windows application on the Mac desktop & DockBar instead of in the VM window
  • Transporter lets you convert VMware and VirtualPC images to Parallels Desktop
  • UI has been revised & polished throughout to be more Mac-like

It’s not all perfect though – some people have been reporting problems with Mac Pro systems and video driver support so waiting for a few days might be a good idea but it’s great progress.

Microsoft have a number of VirtualPC images available including the Visual Studio Orcas preview and the Internet Explorer 6 test platform. With Transporter you should just be able to convert them and get going although I would imagine the copy of XP will balk and require re-activation :(

Now we just need vitalized multi-processors, 64-bit support and hardware accelerated 3D ;-)

Parallels has gained support for hardware accelerated 3D and VMware support for multiple cores/processors since this post was published.

[)amien