SimplyStored and CouchDB 0

Posted by Jonathan

Yesterday I gave a presentation about CouchDB and SimplyStored, our convenience Ruby library, at the Ruby User Group Berlin.

There is a recording of the presentation at ustream.tv.

Mathias and I wrote SimplyStored in order to easily interact with Ruby objects serialized in CouchDB. We use CouchDB as the main data store for Scalarium and so far it has been great. But it is a bit cumbersome to write all those map and reduce functions yourself.

SimplyStored generates the JavaScript map&reduce functions for handling associations or dynamic finders for you.

SimplyStored offers:

  • Models
  • Associations
  • Callbacks
  • Validations
  • Dynamic finder
  • S3 attachments
  • Paranoid delete

    class User
      include SimplyStored::Couch

      property :login
      property :age
      property :accepted_terms_of_service, :type => :boolean
      property :last_login, :type => Time
    end

    user = User.new(:login => 'Bert', 
                    :age => 12, 
                    :accepted_terms_of_service => true, 
                    :last_login = Time.now)
    user.save

    User.find_by_age(12).login
    # => 'Bert'

    User.all
    # => [user]

    class Post
      include SimplyStored::Couch

      property :title
      property :body

      belongs_to :user
    end

    class User
      has_many :posts
    end

    post = Post.create(:title => 'My first post', 
                       :body => 'SimplyStored is so nice!', 
                       :user => user)

    user.posts
    # => [post]

    Post.find_all_by_title_and_user_id('My first post', user.id).first.body
    # => 'SimplyStored is so nice!'

    post.destroy

    user.posts(:force_reload => true)
    # => []
  

The code is on github and OpenSource: SimplyStored example code

Another thing I talked about is RockingChair. RockingChair is an in-memory CouchDB implementation that understands all of SimplyStored's functionality. We use it to speed up our tests and be able to run them in parallel.

Ruby En Rails 2009 Recap

Posted by Jonathan

The last past days in Amsterdam for Ruby En Rails 2009 were really great.

I arrived on Thursday and had the chance to discuss a possible security vulnerability in Rails I discovered a while back with Yehuda and Mislav during lunch.

Afterwards we went to the conference dinner and met many very nice people and had a long discussion about voting systems, European vs. American culture, gun laws, and political systems.

Friday was the first conference day and started for us with being 40 minutes late as we headed up to the wrong metro station. Yehuda was supposed to give a keynote as the first session... luckily the organizers swapped the sessions. So unfortunately we missed the first session but were in time for Yehuda to give his keynote.

Yehuda talked about the Rails/Merb merge and dissected what was achieved. It was a very good, in-depth presentation about the new features of Rails 3 and what left to do. I really liked the new router DSL, actions being Rack-apps, and the death of Rails Metal (the new, slicker possibility to build simpler/smaller controllers takes care of this.).

After the coffee break I gave my Rails Security presentation about common attacks against web applications and how you can protect against them in Rails. Usually this is quite heavy stuff and people tend to sit quiet and listen as this is new to most. In Amsterdam I had some very good questions and discussions on session fixation, JavaScript high-jacking, and app reconnaissance.

Then we listened to Julio Javier Cicchelli talk about Rubyists.EU, an effort to make the different European Rails communities easier to find and build a common European community.

We went to lunch with James which gave us some time to catch up. Took us a while to find a decent place around the conference hall but we managed to find a restaurant where we tried to estimate the global financial burden due to Internet Explorer and what will happen to Microsoft if they were charged for the extra work needed done.

After lunch Eloy educated us about the current state of MacRuby. I'm really looking forward to spending some time hacking Mac apps in Ruby.

The next session gave an overview about monitoring, performance, and the different tools like request-log-analyzer or Nagios.

The conference was closed by Jeremy giving a keynote about Rails, Ruby, and the current state of things in the community (and a sneak-peak at ActiveRelation and what it will be able to do). It was very well received and a good closing session.

Afterwards a big group headed for dinner. We ended up in a small, very local restaurant. It included very nice food, good discussions with new friends from Finnland, and a waiter/owner who runs the restaurant homepage with Rails and asked Yehuda for help :-)

The next day was titled Geek Day and included many lightning talks (that ended up being nearly full sessions and had very good content). Parallel to the great sessions about MongoDB, DataMapper, or experience reports there was a Rails Rumble featuring five teams going on.

The most notable session of the second day was Justin Halsall, dressed for Halloween, talking about BlockHelpers and view DSLs. It was a hilarious show.

The Rumble was a great idea. In contrast to the usual Rumble the teams got a specific challenge. They should build something that improves the situation with Rails dependencies and out-of-date gems laying around in vendor/gems. The winning team would get two tickets to RailsConf 2010.

One team extended builder to list outdated gems and got their changes even merged back to builder by Yehuda on the same day. Another team extended Webistrano to accept projects dependencies and display them on the stage page. Some teams build a command line tool to extract local dependencies like your gems or even the MySQL version and push those definitions to a central place. The winning team had the the most advanced idea regarding update notification and gem-sets for applications. I could really see something like this being integrated into gemcutter. Congratulations Ludo and Michel!

Ruby En Rails day two was celebrated with a big dinner and drinks. After a very nice evening we headed back to the hotel as everybody had an early flight out. Some were still discussing Rails, some were lucky to be able to enjoy Amsterdam longer.

I really enjoyed the conference and Amsterdam. Thank you Chris and Tim Obdam for organizing the whole event!

GoodBad.me - RailsRumble 2008

Posted by Jonathan

RailsRumble 2008 is over - after 48 hours of hacking I'm proud to announce our contestant:

GoodBad.me - Twitter Till Judgement Day!

GoodBad.me is a twitter mashup that Thomas Metschke and I build over the last two days. Once you follow our bot on twitter, we subscribe to your tweets. We collect all your good and bad deeds by searching for #goodme or #badme (or the shorter #gd #bd) in your tweets.

We keep track of your deeds and generate stats about you. Your deed balance decides your character level. Are you just a boy scout or do you strive for beeing friends with Goldfinger?

All those questions can be answered at http://goodbad.me.

The idea is that you keep tweeting as always and by adding the #goodme tag you let the world know that you did something good.

In later iterations we want to allow others to tag your deeds/tweets and maybe allow you to gain points by donating to charity.

The site is online for a couple of hours and we already have several active users. If you want to keep track of your day's work, go join!

If you like the idea and our implementation, please vote for us!

Upcoming events and talks

Posted by Jonathan

The conference season is starting again for me and I wanted to note where I will be/speak during the next couple of weeks.

First, there is Ruby Fools Copenhagen (April 1st and 2nd) where I will speak in the Ruby Performance track about Rails on AWS and how to leverage EC2, S3, and SQS in your application. The lineup at Ruby Fools looks really good with speakers like Glenn Vanderburg, Michael Koziarski, Evan Phoenix, Dr. Nic Williams, Dave Thomas, and Matz himself. Unfortunately I will not have too much time in Copenhagen as I have to leave early for Scotland on Rails in Edinburgh.

I'm really looking forward to be in Edinburgh again. After living, studying, and working there it feels like a second home. At Scotland on Rails (April 4th and 5th) I will talk about Rails Patterns: typical problems and scenarios in Rails applications like asynchronous operations (image processing, calculations, ..), authentication or deployment and common solutions and best practices.

In Mai I will be at Linuxtag 2008 in Berlin and hopefully talk about Ruby on Rails Security, but this talk has not been confirmed yet. Further, there is a chance that I will be speaking a the iX Cebit Forum 2008 about our internal Software Development Process and Agile Development.

A preview of Webistrano 1.1

Posted by Jonathan

It's been two weeks since the public release of Webitrano . Webistrano was downloded nearly 500 times and I got a lot of feedback. People seem to like the concept and having a tool to manage Capistrano deployments through a Web UI.

A lot of people wanted to tie recipes not to projects but to stages, so Webistrano 1.1 will let you do that. Further 1.1 will interpolate strings in Capistrano variables correctly so that you can refer to other variables inside configuration entries.

Also more recent versions of needle/net-ssh will be included so that Webistrano will not blow up if you have newer versions installed.

Apart from this new functionality/bug-fixing the UI got some major enhancements and now looks very promising:



I hope to get 1.1 out of the door shortly after RailsConfEurope here in Berlin. If you are there and have any feedback, I would love to hear it.

Finally switched to Mephisto

Posted by Jonathan

After a long period of painful slowdowns due to Typo's caching I finally switched to Mephisto.

Typo created massive amounts of cached paged for each spammer request and this slowed down the whole machine. I had to manually rm -rf the cache directory every now and then.

The switch to Mephisto should be seemless as I migrated all old URLs with Mephisto's redirect handling:

> tail config/environment.rb

# Typo style article URLs
Mephisto::Routing.redirect '/articles/*' => '/$1'

# Typo pages
Mephisto::Routing.redirect '/pages/*' => '/$1'

# Typo feeds
Mephisto::Routing.redirect '/xml/rss' => '/feed/atom.xml'
Mephisto::Routing.redirect '/xml/rss/feed.xml' => '/feed/atom.xml'
Mephisto::Routing.redirect '/xml/rss/comments/feed.xml' => '/feed/all_comments.xml'
Mephisto::Routing.redirect '/xml/rss20/feed.xml' => '/feed/atom.xml'
Mephisto::Routing.redirect '/xml/rss20/comments/feed.xml' => '/feed/all_comments.xml'
Mephisto::Routing.redirect '/xml/atom/feed.xml' => '/feed/atom.xml'
Mephisto::Routing.redirect '/xml/atom/comments/feed.xml' => '/feed/all_comments.xml'
Mephisto::Routing.redirect '/xml/commentrss/feed.xml' => '/feed/all_comments.xml'

I you experience any problems with the URL handling, please contact me.

My Rails Konferenz 2007 slides

Posted by Jonathan

Rails Konferenz 2007 is over and like last year it was a lot of fun, meeting other developers and learning some new stuff.

My talk on scaling Rails applications with Amazon S3 and EC2 went well and I had some interesting discussions afterwards. The talk was based on my Linuxtag talk but had a lot more info on Switiply and load-balancing.


(Photo by phil76)

The slides are available here as a PDF, a video will soon be available as I’m told.

Skalieren von Rails Anwendungen mit Amazon S3 und EC2 (PDF)

MeinProf featured on the German Amazon Affiliate Blog

Posted by Jonathan

It is not a secret that I am a fan of the Amazon Web Services. Besides EC2 and S3, I also use the Amazon Ecommerce Services (ECS) API at MeinProf.

Our implementation is now featured on the German Amazon Affiliate Blog.

We use the ECS API to let professors and students search for books and study guides on Amazon and then recommend the books to other students. So besides rating a course a student can also recommend supporting literature to others. This is the first step in our plans to increase MeinProfs value to students. We introduced this feature only a short while ago but already have many professors who register and recommend books to their students through our system.

The implementation uses the amazon-ecs ruby library that internally uses Hpricot, the great HTML/XML parser by _why.

The basic usage looks like this:

require 'amazon/ecs'

Amazon::Ecs.options = {
  :aWS_access_key_id => SECRET_KEY,
  :associate_tag => ASSOCIATE_TAG,
  :response_group => 'Medium',
  :country => :de
}

result_set = Amazon::Ecs.item_search('Programming Ruby', {
  :search_index => 'Books' # use Blended if you want also foreign books (usefull in DE and FR)
})

if result_set.has_errors?
  raise "Problem with ECS!" 
end

result_set.items.each do |item|
  puts item.get('title')
  puts item.get('asin')
  puts item.get('detailpageurl')
end

The difficult part is filtering and pre-processing the search term entered by the user in order to reduce the result set.

Linuxtag 2007 slides on Amazon S3 and EC2

Posted by Jonathan

I gave a presentation (in German) on how to scale web applications using Amazon S3 and EC2 at the Linuxtag 2007 in Berlin, Germany.

The talk was a broad introduction to S3 and EC2 and had some examples and scenarios using a Ruby on Rails application.

The slides are available as PDF here and there is also a mp3 recording thanks to http://www.digitalwarenmanufaktur.de/blog/.

I will present a more Rails centric variant of this talk at the upcoming Rails Konferenz in Frankfurt, Germany. Further I will be talking about S3/EC2 and Rails at the RailsConfEurope 2007 here in Berlin, Germany.

Skalieren einer Web Anwendung mit Amazon S3 und EC2 (PDF)

Skalieren einer Web Anwendung mit Amazon S3 und EC2 (MP3)

Rails-Konferenz

Posted by Jonathan

Rails-Konferenz was really a success, nearly a hundred people showed up!

Lot’s of interesting talks and I’m looking forward to the next one.

The slides to my talk about JavaScript and RJS in Rails should soon on the Rails-Konferenz site.

There are also available here:

JavaScript und Ajax mit Rails

tooltip online demo

Posted by Jonathan

After several requests I’ve put up an online demo for tooltip.js and it now has it’s own page.

A lightweight prototype based JavaScript tooltip

Posted by Jonathan

For a recent project I needed JavaScript tooltip functionality for showing detail information. All tooltip libraries that I came across were too complicated and bloatet, did just too much and most of the time were still not flexible enough with the tooltip. So I decided to create my own library that is based on prototype.js:

<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/javascripts/tooltip.js" type="text/javascript"></script>

<div id='tooltip' style="display:none; margin: 5px; background-color: red">
  Detail infos on product 1....<br />
</div>

<div id='product_1'>
  This is product 1
</div>

<script type="text/javascript">
  var my_tooltip = new Tooltip('product_1', 'tooltip')
</script>

Now whenever you trigger a mouseOver on the `trigger` element, the tooltip element will be shown slightly below the mouse pointer. On the mouseOut event the tooltip disappears. The script is clever enough to move the tooltip to the top and/or left if there is not enough space left on the screen to display the tooltip.

This way you are totally flexible with the tooltip. It can be any div with any CSS you like.

You can use my_tooltip.destroy() to remove the event observers and thereby the tooltip.

At the moment the tooltip appears and hides with Element.show() and Element.hide() but a future version will use the script.aculo.us effects.

Download it here (BSD license): tooltip-v0.1.js

UPDATE:
I've put up an online demo here. In the future more updates can be found here.

My Baby arrived!

Posted by Jonathan

The 17-inch MacBook Pro is here! (At least at the store)

http://www.apple.com/macbookpro/

The interesting thing is that now the PowerBooks are gone from the Apple store overview.

You can still get the 12-inch PowerBook through the sidebar but I’m sure only until the MacBooks arrive.

I now have to gather my funds and hope for a big student discount…

MeinProf.de 2.0

Posted by Jonathan

We’ve got a new version of MeinProf.de released.

MeinProf.de is a German student site were university courses and professors can be rated and the average ratings can be compared. So far the site has been a great success. We’ve got over 18.000 Ratings in two months and very positive feedback from students and professors. And all without real marketing or advertising! Just the word-of-mouth and some emails to our friend at the start.

The new version features an optional login in order to keep track of your ratings and being able to change them. We implemented a better feedback system, changed the average algorithm a bit, and spent some hours in performance improvements.

We are working on the next version with RSS feeds for universities, professors, and courses, a personal watch list for registered users and tagging for the professor/course focus.

Be sure to check the MeinProf.de-Blog for more information, some nice charts, and regular updates.

Moved to the lucid

Posted by Jonathan

I installed a new theme (The Lucid) for typo and I like it very much.

Gone is the fixed width layout (you can now switch between fixed width and a fluid layout with the buttons in the top right corner) and the heading for each post are very nice. Notice the calendar style date at the beginning. Checkout how the LiveSeach results are presented. Really nice.

Blockquotes are now nicely rendered and the red ist just more rubyish :-)

So how do you like it?