Archive for the 'Mac' Category

This Week in Ruby (April 7, 2008)

Antonio Cangiano April 7th, 2008

The first edition of This Week in Ruby received a warm welcome from the community. A week later, here we are with a second installment of the series. I’ll attempt to repeat these posts approximately every week, so feel free to follow along by subscribing to my feed.

The Ruby community is a tremendously active one. In only seven days, there have been so many noteworthy items popping up, that it would take me hours just to mention them all. I’ll try to pretend that you, the reader, have been on a week-long vacation in a remote place without internet access, and on your return you asked me, “Hey, Antonio what happened in Ruby and Rails land while I was away?”

Some fun on April Fools’ Day

We kicked off the week on a lighthearted note, by fully embracing the endless opportunities offered by April Fools’ Day. Most of the spoofs and jokes were aimed at making fun of Ruby on Rails, one way or another. Testimony to the self-irony that we, as a community, certainly have. I personally announced the soon-to-arrive release of a fictitious (of course) framework called Ruby on Crack. Which was supposedly much faster and productive than Rails. At the heart of the joke were the fake endorsements, chocked full of double-meanings (with apologies to Matz, David Heinemeier Hansson, Dave Thomas, Ezra Zygmuntowicz, Obie Fernandez, Zed Shaw, Tim O’Reilly, Guido van Rossum and Paul Graham). I found the SQL on Rails April Fools’ gag very funny and extremely elaborate. Their screencast is comedic genius and their site a spoof in every minute detail. In my book, on that day, they took the cake. The joke itself was from two years ago (as pointed out by a commenter below) but it resurfaced again this year. The hilarious trend continued with Cobol on Cogs and for the ASP.NET and PHP nostalgic, with Acts as ASP.NET and RHAP (Ruby Ain’t Hypertext Preprocessor). Avdi Grimm even found the final solution to the whole Monkey-patching diatribe: Ninja-Patching, “When you really want to catch a coder by surprise, a monkey doesn’t cut it. What you need is a Ninja.”. :)

mod_rails

Last week I mentioned Passenger (aka mod_rails). This week Hongli Lai published some interesting benchmarks that compared it against Mongrel and Thin for three Rails applications (Typo, Petstore and El Dorado). While still synthetic benchmarks, the results where very encouraging and showed how Passenger was on average faster than Mongrel and roughly on par with Thin. Even just the perspective of having performances that are somewhat comparable with those of Mongrel, would be great news, given that it’d highly simplify the deployment process of Rails applications with Apache. Ninh Bui has announced that the official release date for the project is expected sometime this week and that meanwhile they are working with companies like Twitter and Dreamhost to ensure that the module is fully tested. Speed is only one of the project’s aims in fact, with a lot of focus put on stability and robustness, too. They also caught the attention of Engine Yard who is interested in discussing a possible partnership and contributions to the Rubinius project.

Git

By now you should be aware that the Rails community is fully embracing Git, and github.com is only part of the reason. Michael Bleigh has even created a small library called ruby-github to simplify access to the GitHub API. David has announced that Rails is moving to Git and the ticket tracking system is being switched over to Lighthouse. As David pointed out, this means that both the tracking system and version control are to be run by Rails applications, which is a good bonus if you subscribe to the philosophy of “eating your own dog food”. For those who are still git-challenged, Kurt Schrader has a collection of helpful links to get you started. And if you need a simple issue tracker for git, version 0.1.2 of Ditz has just been released, too.

Conferences

Confreaks has now published the remaining videos from MountainWest RubyConf 2008. They’re very interesting and highly recommended. All of them.

In case you missed the Ruby Fools conference, held on April 1st and 2nd in Copenhagen, you can read an interesting personal account by 41Concepts. The conference also took place on April 3rd and 4th in Oslo.

Speaking of conferences, Sam Ruby will be presenting on Ruby 1.9 at this year’s OSCON. In a recent short post, he mentioned his plans for his talk and really nailed one of the problems that will hinder Ruby 1.9’s adoption, in his own words:

My tentative conclusion at this point based on observations of efforts to get products like Rails working on Ruby 1.9: the biggest obstacle to Ruby 1.9’s adoption is the sheer number of mostly working but essentially unmaintained gems that virtually everybody in the Ruby community depends on. — Sam Ruby

Rails

Amazon has an article on Using SimpleDB and Rails in No Time with ActiveResource. Another interesting article which surfaced this week was a post called simple pages for easily creating “boiler-plate” pages in Rails.

Three interesting plugins where released. You can read about them in Introducing Action Messager: Dead simple IM notifications for your app!, Better Partials Plugin for Rails and A Rails 2.0 Message Forum Plugin.

The Rails Jedi posted about two Mac OS X applications for accessing Rails docs in the most efficient way possible. Nookkit.app and RailsBrain are real timesavers, and I highly recommend them to Mac users.

SapphireSteel has announced the Public Beta of their Visual Rails Workbench. With the release of Ruby in Steel 1.2 Beta 3, they have in fact included their drag-and-drop visual environment for Rails. I didn’t have a chance to try it out, but if you are on Windows you may want to give it a shot, starting with reading their online articles.

The ink for printing Ruby and Rails books never runs dry, as I pointed out in my post 7 soon to be released Ruby and Rails books. It turns out that in the months of April and May alone, there will be 8 new Ruby/Rails titles. Check them out, especially if you are looking for updated material relating to Rails 2 or, in the case of the pickaxe 3, to Ruby 1.9.

The guys from Rails Envy, published episode 25 of their Rails podcast. If you are not familiar with their fun podcast, I recommend that you listen to a few episodes by subscribing to it through iTunes.

Ruby

There were countless interesting Ruby articles in the last week, but I’d like to point out the following:

Ruby VMs

In Rubinius for the Layman, Part 1: Rubies All the Way Down, Mathieu Martin has a nice, gentle introduction to Rubinius with some reveling benchmarks too. For those interested in learning more about the current status of Rubinius, InfoQ has a short article with a few pointers.

More remarkably, in the land of alternative Ruby VMs, Jruby 1.1 has finally been released, after months of hard work. The authors are already thinking about what lies ahead for the project. If the subject interests you, feel free to grab a few slides from various presentations on the topic.

RailsConf, Arc, Apple and other Zenbits

Antonio Cangiano January 30th, 2008

Zenbits are posts which include a variety of interesting subjects that I’d like to talk about briefly, without writing a post for each of them.



Ruby and Rails Videos

Blip.TV is now hosting the videos of RailsConf 2007. The audio and video quality is very good even though no slides are shown (but you can always google them). While on the subject, you can also watch the videos for RubyConf 2007 (including slides), Mountain West Ruby Conference, Ruby Hoedown last August, and the fourth edition of RejectConf. If you are in the mood for video learning, also check out Railscasts, RubyPlus, and Rails Envy.



RailsConf ‘08

David has announced that the registration for RailsConf ‘08 is now open. The conference will be in Portland, Oregon from May 26th till June 1st. It’s going to sell out very quickly, so book your spot while they last. I’m almost sure I won’t be able to participate since I’m still dealing with the process of getting my Canadian permanent residency (but we are finally getting really close, and then I’ll be able to travel freely).



Qtrax is a disaster

I’ve been following the (mis)adventures of Qtrax closely. It’s a disaster, the perfect example of how not to launch a product even if they had amazing PR skills and where able to get coverage in the MSM worldwide. The premise was good: share the ad revenue with the artist, and allow users to get music for free. Something that SpiralFrog has been doing for a while. The problem is that SpiralFrog’s catalog is rather limited as far as mainstream music goes. Qtrax claimed to have an agreement with the four major recording labels and a catalog of more than 25 million songs. That was what set them apart and what made the announcement attention worthy. The reality was much harsher. They didn’t have any agreement in place (they essentially lied), they didn’t make the download available when they declared it would be, and the site was unreachable or intermittent all the time. Not only this, but their software is nothing more than a skin on top of Songbird. Downloading songs is basically impossible and the software is unusable at this stage. Don’t even bother getting it. It’s a festival of connection timeouts, 404s and “welcome to Oracle Application Server 10g” messages. A real shame.



Arc: too little, too late?

Paul Graham has finally announced the release of Arc. Graham and Morris have made a forum, a tutorial and installation instructions available on their official ArcLanguage.org site. While Paul clearly states that Arc is still incomplete and requires a lot of refinement, at least it’s out and people can start using it (Paul’s Hacker News has already been adopting it for a while). It’s not vaporware anymore, it’s here. However, amongst the enthusiasm that met this release from curious and early adopters, there are also a great number of people disappointed by Arc’s first (pre)alpha. Keep in mind that many people talked about Arc for several years and had great expectations, perhaps even something close to the mythical hundred year language. What they found is that Arc is currently a skin on top of MzScheme (but not the latest version) that adopts a more concise syntax compared to Scheme or Common Lisp. There isn’t anything too revolutionary, it doesn’t support packages or modules, or Unicode. It uses tables for HTML libraries, and so on and so forth. Paul Graham has a strong influence on the community and I’ve no doubt that many people will put time and effort into learning Arc and will in turn improve it. Heck, even I’m going to give it a shot for fun. However right now it’s not really convincing as an alternative to CL or Scheme itself. Don’t construe this as a harsh criticism towards Arc, it is not. We are talking about a language that it’s in its infancy and that as I said, I plan to experiment with myself. I hope to see it grow rapidly and I congratulate Graham and his team for finally making it available. That said, right now I think it’s a weak release and therefore, in my opinion, the disappointment of many is justified. In any case, good luck Paul, we’ll watch this one closely.



Share your DB2 success stories

ChannelDB2 is looking for DB2 success stories. If you appreciated that great piece of software that is DB2, please share your experience here. If your story gets published, you will receive one of the tokens available in the loot bag: DB2 “paraphernalia”, books, Amazon.com certificates, and so on. If you have a company or a startup, it’s also a good way to get your name out there.



Apple’s quote for $1348.09

A while ago (a couple of months, perhaps) my MacBook Pro was accidentally dropped. It was an accident due to there being far too many cables in my room. It upset me of course, but it’s not the end of the world. It could happen to anyone. Thank Science, the screen is intact and the computer works perfectly. I was lucky. There are a couple of things that bug me though. Aside from a tiny dent in a corner of the top case, when closed down on the base the lid has a slightly wider gap on the left side, than it does on the right side. Also, the the latch on the bottom case must be somewhat damaged because when touched even minimally the lid pops open. These things in no way affect my usage of the laptop, and that’s part of the reason why I didn’t even bother trying to fix it for a long time.

Then a few days ago, for unrelated reasons, I began to question my choice of getting a Mac instead of just buying a top of the line Lenovo T series to be run with Ubuntu. I love Ubuntu and it’s becoming increasingly better with each release. With the exception of Textmate, I started to think that Ubuntu (that I currently use a lot) could easily replace Mac OS X for me. Also, the ergonomic qualities of Lenovo’s notebooks is so nice and as an IBM employee I get a decent discount on them. Okay, perhaps I made a mistake when I reached my purchase decision 7 months ago. I’d never owned a Mac before and I really wanted to. Truth be told, I think that Mac OS X is a very polished operating system and I can’t emphasize my appreciation for it enough. It’s eye-candy on top of Unix. But there are other factors to be considered, especially as a developer, and I feel that Ubuntu could have been just as good as my end choice.

Not only that, but I must also say that my old T42p was a much more comfortable laptop, despite costing half the price. Anyways, it came to my mind that I could either run Ubuntu as my main operating system on the MacBook Pro, or fix the cosmetic issues on the laptop and sell it to buy a nice Lenovo T61p. Cosmetic issues can usually be ignored or easily fixed, but on the second hand market they often impede the possibility of selling it for a good price.

Just out of curiosity I decided to call Apple and ask how much it would cost to get it fixed. The laptop is still under warranty (only 7 months old), but I caused the damage, so I pay, no issues there. The agent on the phone understood the problem very well and quoted me about $200. I specifically asked him if the lid could be replaced independently from the screen (which is in perfect shape) and he confirmed this. So Apple booked an appointment at the Genius Bar at an Apple Store downtown Toronto. I went there on Saturday, by public transportation it took me almost two hours each way. The “genius” confirmed that the latch on the base is somewhat broken and that the upper lid may or may not be slightly warped (hard to tell with the latch issue in place). After a long wait he came back with a quote… $1,348.09. I kid you not. It turns out that the lid is sold as one piece with the screen and the whole display assembly can be replaced for $809. The guy at the genius bar agreed that it’s probably only the base that needs to be replaced. But it’s still $214 dollars for the part, $170 for labour plus taxes. A whopping $437 for a little latch that is not behaving. I wasn’t too happy with being quoted $1350 given the price of the laptop and the fact that I was previously quoted an all-inclusive $200 on the phone. I wasted 4 hours of my Saturday. I’m not repairing an Aston-Martin here for Darwin’s sake.

If you drop an Apple laptop and you break the screen (not my case) you may as well just get a new laptop because it’s going to be cheaper. This is sort of true for any laptop, but I feel that just like Apple makes you pay a premium to get their hardware, they still charge you plenty for any minimal repair. To change the lid they wanted to replace the whole screen. To change a broken latch, they needed to replace the entire base. And $170 plus tax for carrying out the repair!? I’m aware of sites that sell parts and instructions on how to perform the replacement myself and may consider it in the future (changing only the base assembly). For now I’m fine, given that the latch issue doesn’t cause too many problems for me. I must say though that my experience at the yuppie Apple Store made me even more convinced that my choice of getting a Mac in the first place may have been the wrong one. I wonder how long it will take before I’ll follow Mark and Cory and switch back to Ubuntu full-time. The thought both excites and saddens me. Time will tell.

How to install Django with MySQL on Mac OS X

Antonio Cangiano December 22nd, 2007

Installing Django on Mac OS X Leopard is supposed to be very straightforward, but if you are new to it, you may encounter a few puzzling questions and, in the case of MySQL, even a couple of headaches. I’m writing about this for the benefit of those of you who may attempt and struggle with this feat. MacPorts is not required for this how-to.

First and foremost, we are going to install Django from its svn repository, as opposed to obtaining the 0.96 release archive. The reason for this is that the trunk version implements a few new features. The development code is also rather stable and used by most people in production mode, even for sites like the Washington Post.

Checkout Django

svn co http://code.djangoproject.com/svn/django/trunk django_trunk

Tell Python where Django is

Mac OS X 10.5 already ships with Python 2.5.1, thus you won’t have to install it. You can verify this by running python in the Terminal (use exit() to get out of the python shell). What you need to do is inform Python about the location of your django_trunk directory. To do this create the following file:

/Library/Python/2.5/site-packages/django.pth

Within this file, place only one line containing the path to your django_trunk folder. In my case, this is:

/Users/Antonio/Code/django_trunk

Of course, change it to the full path location of the directory on your filesystem.

Add django-admin.py to your PATH

The bin directory within the django folder (which is inside django_trunk itself) contains several management utilities. We need therefore to add the following to the PATH (again, change it to your own location):

/Users/Antonio/Code/django_trunk/django/bin

How you go about doing this, depends on the shell you are using, and I’m assuming you are able to export a shell variable on your own. In case you are using the bash shell (as I do) then you should have a .profile file in your home directory. Alternatively, you could just create a symlink to the utility django-admin.py in /usr/bin, but I recommend the former approach.

Grab and install MySQL

I would normally recommend PostgreSQL, at least until we have DB2 on Mac, but I realize that many of you use and prefer MySQL, which also seems to be the only one that requires special instructions due to a few installation issues when trying to get MySQL and Python to work together. You can install MySQL by grabbing and running one of the packages that are available on the official site. Choose the one for x86 and Mac OS X 10.4.

Install the MySQLdb driver

Get MySQL-python-1.2.2.tar.gz from SourceForge. Please follow these exact instructions because the source code won’t compile out of the box and will give you the following error when trying to build it:

/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types
in declaration specifiers
error: Setup script exited with error: command ‘gcc’ failed

Run the following:

tar xvfz MySQL-python-1.2.2.tar.gz
cd MySQL-python-1.2.2

At this point, edit the _mysql.c file and comment out lines 37, 38 and 39 as follows:

//#ifndef uint
//#define uint unsigned int
//#endif

Now, from the MySQL-python-1.2.2 folder run:

python setup.py build
sudo python setup.py install

If you still get an error (and only in that case) you’ll need to edit the site.cfg file within the same folder and set threadsafe = False, before running the two commands above once again.
If instead, you don’t receive an error but you see warnings about files not required on this architecture, don’t be concerned about them. The last step required is to create a symbolic link with the following command:

sudo ln -s /usr/local/mysql/lib/ /usr/local/mysql/lib/mysql

All these adjustments are required because we are building and installing the driver on Mac and not on Linux.

Verify the installation

You should be all set now, but let’s verify this right away. Open Terminal and run the following commands in the python shell (start this with the python command).

Verify that MySQLdb is correctly installed:

>>> import MySQLdb
>>> MySQLdb.apilevel
‘2.0′

Now, verify that Django is working:

>>> import django
>>> print django.VERSION
(0, 97, ‘pre’)

By running exit() get out of the python shell, and verify that django-admin.py is in your path:

django-admin.py
Type ‘django-admin.py help’ for usage.

If you obtain a similar output for all three of them, you are really set to write the next YouTube.

Where to go from here

Now that Django is installed, you can go read the Django Book 1.0 that’s available for free online. Something equally well done and useful is really missing from the Rails community. Above all, experiment, Django (and programming in general) is learnt by doing. The Definitive Guide to Django: Web Development Done Right is also available for purchase in its deadtree version, which just came out. It’s cheap and it’s already a best seller on Amazon. Despite the availably of a free version online, I like having paper versions of tech books so that I can read without staring at the monitor. Furthermore, I feel like rewarding the authors (who are also the framework creators), while encouraging publishing companies that are willing to allow authors to make their books available for free on the web. Well done guys!

Next »