Saturday, June 13, 2009

WWDC 2009 - Recap

This year I somehow didn't feel like writing a post about every single day of WWDC (you can look at some pictures, though). It's Friday now, 4:30 pm and I'm on the Caltrain back to San Jose. It has been a fun week. Unfortunately a lot of the sessions were geared towards new iPhone developers, so they tended to be very basic. There were, however, still a lot of in-depth sessions which I really enjoyed.
Snow Leopard will come with some great additions for us developers. Playing around with them and then actually talking to the very Apple engineers that built those things is priceless (actually it's not: you just have to buy a ticket). Catching up with people that I haven't seen for a year as well as meeting lots of new people is one of the nicest things about WWDC. It's a very friendly and helpful community.
I've also realized once more this week that iPhone and Mac development is a lot more fun than web development. It makes my eyes light up to be able to run my code "so close to the hardware". I love Ruby, it's a beautiful language, but optimizing your Objective-C code so that you get the last bit of performance out of this wonderful device that is the iPhone simply is a lot more exciting than writing web apps. The 4 years of writing ANSI C on OS/2 really pay off now: Having a deep understanding of C and of memory management is extremely valuable. Even if you mostly work with garbage-collected dynamic languages: Pick up a book and learn C. It will make you a better developer.
During this conference I also wrote my first native Ruby extension and decided that OpenGL ES is the next technology that I want to learn and master.
The beer bash yesterday was great. The food was good (but not as good as the last 2 years) and they got the band Cake to give a great concert for us. Good times. Two more points of critique: No reception on Monday night and no Espresso guy! What was up with that? I mean Apple must have been doing extremely well because of all of our apps that they sold through the AppStore last year, so this is not the time to get cheap and not offer such essential WWDC essentials like the Espresso guy!
Anyway, greetings to all the interesting people I had the pleasure of meeting and see you all again next year. I'll stay in California for another week: Vacation with my sweet wife!

Tuesday, June 9, 2009

WWDC 2009 - Day 1

The first day of WWDC was pretty nice. The keynote didn't really have any big surprises: iPhone OS 3.0 release date (June 17th) and the announcement of a new faster iPhone with a compass, a better camera and video. The voice commands thing looks cool, though: You'll be able to press and hold the home button on the new iPhone and then say "Call John Appleseed" or even activate Genius by simply saying "Play more songs like this". Nice. Also OpenGL ES 2.0 is supported by the new iPhone, the current one only supports 1.1.
Some Vista bashing was part of the keynote again as well which is always entertaining.
While I was waiting in line for the keynote, some people were handing out invitations for a Symbian hackathon across the street in the Metreon during the lunch break. It said you'd get a free Nokia 5800 smartphone. It sounded as if there had to be a catch to it but there wasn't: I showed up at 1 pm, was handed a "gift certificate", had to sign it and got a free Nokia 5800. Sweet. The guy who welcomed everyone to the event said there'd be prices like netbooks for people who actually build something for Symbian during the hackathon. But he didn't say where to get stated, were to get the SDK, if there's a simulator... nothing. I first set up PyS60 and wanted to port my old and abandoned Springenwerk XSS scanner to Symbian but it turned out that the Symbian Python implementation doesn't include urllib2. Not good.
So I looked if there's Ruby for Symbian and sure enough there is. It is only the core interpreter, though. It comes with close to none system classes. When you try to "require" any library (like 'net/http'), it crashes. Date is not available either. So I built a very very simple ap that prints out the calendar of the current month on the screen. It worked but didn't look good on the phone because it uses variable width fonts. Oh, and the Symbian simulator only runs on Windows. How lame is that? I mean they want iPhone developers to develop for Symbian and they don't even provide an IDE for the platform they all use. Also both the Symbian OS and the very sparse documentation and rudimentary development tools seem so far behind what Apple offers us in terms of tools and technologies. The event didn't attract me to the Symbian platform at all. Actually it discouraged me from developing anything for it.
But because most people just came to get the free phone, hardly anyone actually developed anything. I think only 6 people. The lady handed me a flip cam when I showed her my "app". Then I asked when the drawing for the netbooks would be. She had to go check, came back and asked: "Do you want to trade your flip cam for a netbook?" I said "Sure". So she handed me a brand new Sony Vaio VGN P530H/Q 8" netbook. Wow. That's a pretty nice price for about 15 lines of Ruby code. It run Vista, though. I don't really need it, so I'll see if I'll find someone at the conference who'd like to buy it. I hope I'll find someone quickly so I don't have to drag it around with me all day.
The last two sessions I attended were "Developer Tools State of the Union" and "Graphics and Media State of the Union". The contents is under NDA, so I can't talk about what they actually showed us, but I can say that some really cool stuff is coming your way if you develop for the iPhone or Mac. It's a great platform to develop on and for.

Wednesday, May 27, 2009

Xapian Search Extension for Radiant

I'm working on a project involving the Radiant CMS and a legacy DB2 database. We need full-text search and initially I would have liked to use Sphinx (because Ferret is too unstable) but the available Rails plugins for Sphinx only work with MySql or Postgres. So I came across a little-known search engine called Xapian. It's very fast, it's used by Gmane to index millions of entries every day and (alas!) it works with every DB that Rails works with (which includes DB2).

So in order to use it with Radiant, I built a small extension that makes Radiant pages full-text-indexable. You can check it out on Github. It's still very basic and has lots of room for improvement, but it's a start.

Tuesday, May 26, 2009

Rake: "no such file to load" although it exists

I'm working on a search extension for the Radiant CMS that uses Xapian at the moment. I ran into a weird issue where rake complained about not being able to load a file although it existed. It listed the full - and correct - path of the rake file I wanted to include in another rake file and aborted with "no such file to load". Lies! All lies! Reading the RDoc of Rake revealed that dependencies loaded with "require" are loaded before the Rake targets are evaluated. So alternatively you can use the "import" statement instead of "require". That's what solved my problem. The "no such file to load" error is quite misleading, though.

Friday, April 3, 2009

Ruby Deutsche Bank CSV Converter

I've recently signed up with FreeAgentCentral. It's a really great service, but it didn't like Deutsche Bank's CSV files. That's why I wrote a converter. Check it out on Github.


By the way, if you sign up with this link, you (and I ;)) will get a 10% discount:
FreeAgent sign-up

Friday, March 27, 2009

WWDC 2009 - Got My Ticket

This year, Apple has waited excruciatingly long to announce the dates for their annual Worldwide Developers Conference (WWDC). Last year they announced the dates on March 13th, 2 weeks earlier. Anyway, yesterday the dates were finally announced: June 8 - 12, just like everyone expected. I got my ticket right away because WWDC sold out last year and I expect it to sell out even quicker this year because of all the new iPhone developers. I really hope they won't just cater to new developers with lots of introductory sessions. But usually they have a good mix. It'll be good. See you there!

Monday, March 23, 2009

Passenger and Ruby Enterprise Edition on Solaris 10

I recently had the pleasure of setting up REE and Passenger on Solaris 10. I set the server up using the ibm_db gem for the IBM DB/2 database. I'm not covering this part in this tutorial and I also haven't replaced it with instructions for MySQL. I'm sure you'll figure out how to set up MySQL on Solaris.

Before you start, some important notes: You can replace "myapp" with - well - your app. Also note that this is a little rough. Please leave suggestions or improvements in the comments. Also one very important tip (this took us quite a while to find): First start your app in development mode my setting the Passenger RailsEnv development directive. In production mode, Rails buffers the logger. If will only write stuff to the log file once it has 1000 bytes. Sometimes something fails right away and those 1000 bytes are never reached and hence nothing is ever written to the log file. So do yourself a favor and run in development mode first. So here we go:
  1. Create httpd.conf:
    cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf
  2. Start Apache:
    sudo svcadm enable http:apache2
    More info here.
  3. Install Ruby Enterprise Edition:
    wget http://rubyforge.org/frs/download.php/51100/ruby-enterprise-1.8.6-20090201.tar.gz
  4. Install GNU Tar (needed for Capistrano, if you use the copy strategy. If not, you don't need it.):
    sudo pkg-get install gtar
  5. If you do use the Capistrano copy strategy, you also need a link from tar to gtar:
    cd /home/myapp
    mkdir capistrano-links
    cd capistrano-links
    ln -s /opt/csw/bin/gtar tar
  6. Unpack Ruby Enterprise Edition:
    gtar -xvzf ruby-enterprise-1.8.6-20090201.tar
    cd ruby-enterprise-1.8.6-20090201/source
  7. Configure:
    ./configure --with-openssl-dir=/opt/csw --with-readline-dir=/opt/csw --with-iconv-dir=/opt/csw --prefix=/opt/rubyenterprise --enable-pthread
    More info at Dark As Light and at Joyent.
  8. Install REE:
    make
    make install
  9. Edit your profile:
    vi ~/.profile
    Then add this:
    export PATH=/opt/rubyenterprise/bin:/opt/rubyenterprise/lib/gems/bin:$PATH
    export GEM_HOME=/opt/rubyenterprise/lib/gems
    export RUBYLIB=/opt/rubyenterprise/lib
    export RUBYOPT=rubygems
    Save and source it:
    source ~/.profile
  10. Install RubyGems:
    wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
    gtar -xvzf rubygems-1.3.1.tgz
    cd rubygems-1.3.1
    /opt/rubyenterprise/bin/ruby setup.rb install --prefix=/opt/rubyenterprise/
  11. Install some gems:
    gem install daemons fastthread gem_plugin rake tzinfo rack passenger
  12. Set some environment variables you that you will need for the passenger installation:
    export APXS2=/usr/apache2/bin/apxs
    export APR_CONFIG=/usr/apache2/bin/apr-config
    More info here.
  13. Install Passenger:
    passenger-install-apache2-module
  14. Create a wrapper script for ruby that sets some environment variables:
    cd /home/myapp
    vi ruby_with_env
    Then enter this:
    #!/bin/sh
    export PATH=/opt/rubyenterprise/bin:/opt/rubyenterprise/lib/gems/bin:$PATH
    export GEM_HOME=/opt/rubyenterprise/lib/gems
    export RUBYLIB=/opt/rubyenterprise/lib
    export RUBYOPT=rubygems
    exec "/opt/rubyenterprise/bin/ruby" "$@"
    I know that this is a bit hackish and not very elegant. More elegant and working solutions and warmly welcomed.
  15. Put the Passenger stuff into the Apache config:
    vi /etc/apache2/httpd.conf
    Add these lines:
    LoadModule passenger_module /opt/rubyenterprise/lib/gems/gems/passenger-2.1.2/ext/apache2/mod_passenger.so
    PassengerRoot /opt/rubyenterprise/lib/gems/gems/passenger-2.1.2
    PassengerRuby /home/myapp/ruby_with_env
  16. Also add this:
    <VirtualHost *:80>
       ServerName myapp.mycompany.com
       DocumentRoot /opt/myapp/current/public
    </VirtualHost>
    Also change Group to myapp and User to myapp.
  17. Create a directory for your rails app:
    mkdir /opt/myapp
  18. Restart Apache:
    sudo svcadm restart http:apache2
    Check that it's online:
    svcs apache2
  19. Add this to the bottom of /etc/ssh/sshd_config:
    # for capistrano
    PermitUserEnvironment yes
  20. Install Rails:
    gem install rails
  21. Change to the shared/config directory:
    mkdir /opt/myapp/shared/config
  22. Copy your database.yml to /opt/myapp/shared/config/database.yml.production and enter your production values. IMPORTANT: remove all other entries, that might use a different database adapter! This prevented Passenger from working for me.
  23. Deploy: (I assume that you have capified your project) On your client machine, in your project directory, run this:
    cap staging deploy:setup
    cap staging deploy:cold
  24. That's it!

If this was useful for you, please take a minute and recommend me:
Recommend Me
Thank you!