Archive for October, 2008

Cocoa for Ruby(ists) with MacRuby

Tuesday, October 28th, 2008 by Thilo Utke

Apple’s Application Framework Cocoa gained popularity recently, also due to the iPhone. Like many others we started to learn Objective-C to play around with the iPhone a couple of months ago. The basic syntax is fairly easy to learn, also because lots of sources exist to get you up and running. But in my opinion the real challenge is to understand how the interface builder works

The past

But as a Rubyist the C like syntax of Objective-C was quite a pain. So I didn’t enjoy working with Objective-C. The existing Ruby bridge RubyCocoa has its own drawbacks. Especially moving parameter names into the method name to mimic Objective-C’s keyed arguments doesn’t appear future proof to me. This all kept me from getting deeper into the subject.

The future

In March this year MacRuby made its appearance as a successor for RubyCocoa. MacRuby is a port of Ruby 1.9 on top of the Objective-C runtime and garbage collector, which aims to fix all of the RubyCocoa drawbacks and bring the full power of Ruby to the Cocoa framework. With the 0.3 release a couple of weeks ago, MacRuby now supports the Interface Builder, thus making it a full fledged member of the OS X Development tool chain. Since then MacRuby gained serious popularity. An official Apple Developer Connection Tutorial for “Developing Cocoa Applications Using MacRuby” was published recently. More good tutorials can be found on the web, so I just link to them instead of writing another.

During the weekend I went through the first chapters of “Cocoa Programming for Mac OSX” with MacRuby instead of Objective-C to get familiar with the Cocoa library and Interface Builder. It went super smooth so far, I really had fun. Here is just a short example of the very first app out of the book to see how the code compares to objective-c.

^ Ruby vs. Objective-C v

As you can see you don’t need a header file and much less special characters. It even gets better, because you don’t need to call [[NSMutableArray alloc] init] but Array.new or just [] to initialize an empty Array. Isn’t Ruby beautiful? And with MacRuby you can have it for your Cocoa Apps too. So jump on board.

Couch Potato unleashed - a couchdb persistence layer in ruby (updated)

Monday, October 27th, 2008 by Alexander Lang

Update: the gem is now available, see the installation instructions below.

After several weeks of incubating on my computer it’s finally time to get real: I have just open sourced Couch Potato under the MIT license. You can get Couch Potato on github now. For an introduction to CouchDB and ruby please read my previous blog post A CouchDB primer for an ActiveRecord mindset. The following is a very short introduction into using Couch Potato. If you want to know more you can start with the README.

The goal of Couch Potato is to create a migration path for users of ActiveRecord and other object relational mappers to port their applications to CouchDB. It therefore offers a basic set of the functionality provided by most ORMs and adds functionality unique to CouchDB on top.

Installation

Couch Potato is available as a gem from http://gems.github.com, so you can just do

Alternatively you can download the sources from github. If you are using rails just copy the files into vendor/plugins, create a RAILS_ROOT/config/couchdb.yml file (see the README for the format) and you are ready to go. For other applications you will have to require the lib/couch_potato.rb file and then set the database name by calling CouchPotato::Config.database_name = 'name of the db'.

As Couch Potato is still very young you can expect its feature set to grow quite a bit in the near future. What you can download now is the very core together with a few features giving you a glimpse of what is about to come:

Persistence

Create a new class and make its instances persistable by including the Persistence module. As there is no schema in a CouchDB you have to declare the properties you want to persist:

Now you can save your objects:

Properties:

You can of course also retrieve your instance:

Associations

As of now has_many and belongs_to are supported. By default the associated objects are stored in separate documents linked via foreign keys just like in relational databases.

When saving an object all associated objects are automatically saved as well. All these save operations are sent to CouchDB in one operation which means the whole process is atomic across all objects saved, plus only one database roundtrip is required making it much faster.

As CouchDB can not only store flat structures you also store associations inline:

This will store the addresses of the user as an array within your CouchDB document.

(more…)

Barcamp Berlin 3: looking back

Monday, October 20th, 2008 by Alexander Lang

Last weekend was Barcamp Berlin 3 and I was there, too. This year’s location was the Deutsche Telekom Haupstadtrepräsentanz - an awesome place.

Anyway, the purpose of this post is to summarize the sessions i attended and found worthy to write about. So here we go. Slides are mostly posted in the barcamp wiki.

How to promote your Web 2.0 Application

This first session was held by Michael Sliwinski of nozbe.com - a very energetic talk presenting a couple of tips and tricks to turn the visitors of your web tool into caring users and finally paying customers. Michael has built nozbe for himself and only later started turning into and app for others. His idea(l)s are heavily influenced by the 37signals guys - looks like we operate on the same level as he does :)

Back to his talk, some of his points were: show people how to use our site, show them the benefits hey will have from using your product (not your features, their benefits), tell them why to use this app and not the competition, testimonials are important even though nobody reads them, email still works - send newsletters and special offers - much higher impact than blog posts, people still don’t use or even understand RSS. And most importantly: love your app and show that love to others.

doingtext

We skipped the next session in order to prepare go through our own presentation titled “getting things written” one last time (ok seriously we had started working on it the day before). We ended up with around 70 slides for a 30 minute talk. I had added a presentation feature to doingtext the week before so we did the entire show straight from the website. We had decided to make this an entertainment show so we started explaining what paper was and how to use it and then applied the principles people use to work on texts with paper (show text to others, comment, highlight, talk about it, view history, merge changes) to the various online tools available (sending ms word documents by email, google docs, writewith, adobe buzzword), then text editos with collaboration features (gobby, subethaedit) and finally presenting doingtext and its communication focused approch to text collaboration.

It looks like the talk was good - we had around 60 people attending and staying until the end of a longer discussion following our presentation.

Today I repeated the same talk at the Webmontag Berlin. Having only 8 minutes of time I ended up rushing through the 70 slides and almost rapping the words in super high speed - earning quite a bit of praise - thanks everyone.

books for freaks

This wasn’t really a presentation but more a everyone talk about their favorite books thing. Here comes everybody (great book about how people gather on the internet, how communities work, how the economy shifts from limited production capabilities to limitless production and much more), but also fictional books. Charles Stross was mentioned as the author of a couple of weird (in the positive sense) sci-fi books (The Atrocity Archives) - will buy one of those soon.

jquery tips & tricks

The presentation itself was actually a bit lame (sorry guys) but it reminded e that I really wanted to try out jQuery. On the next project - promised. $('.item').show().siblings().hide() - pretty slick eh?

our favourite tv series

Very good session for leaning back and watching funny scenes from a couple of tv series. They even mentioned Top Gear - the funniest and most overproduced car magazine ever.

death to the ipod

This one was mostly about a pretty cool gadget called the pacemaker - basically a mobile dj tool that fits in your hand. Comes with 2 decks, crossfader, equalizer, effects, beatcounter, prelistening via a separate headphone out etc. - pretty cool, I even got to test it out for a couple of minutes.

How to get resource route methodes for custom templates in rails

Wednesday, October 8th, 2008 by Thilo Utke

If you write a custom template handler, e.g. for pdf templates you might want to use the rails resource route methods e.g. new_users_path. Here is the way how to get this working for a imaginary PDF template handler.

Product Launch: doingtext.com

Wednesday, October 1st, 2008 by Alexander Lang

We have just launched the closed beta of a new product: doingtext.com.

Doingtext is a text collaboration tool. After entering your invite key you will be able to start a new discussion about a text that is already there or to be written. You can send the URL of this discussion to anyone you want (they don’t need an account or invite) and they can comment on every line of your text and suggest changes.

If you are working with texts please head over and get a beta invite and help us turn doingtext into a great product. We rely on your feedback.

We are posting regular updates on twitter and the doingtext blog.