1. Sep
    26

    Install Mongrel2 on Mac

    Posted in : mac, mongrel2, server, homebrew, and zeromq

    Want to play with Zed Shaw’s Mongrel2 on your mac? Using Homebrew in your home and not in /usr/local ?

    Here’s how to get the ØMQ Homebrew’s install picked up by Mongrel2’s Makefile:

    # install zeromq via homebrew
    > brew install zeromq
    
    # download and install mongrel2
    wget http://mongrel2.org/static/downloads/mongrel2-1.2.tar.bz2
    tar xvjf mongrel2-1.2.tar.bz2
    cd mongrel2-1.2
    
    # to install in your home
    PREFIX=$HOME OPTFLAGS="-I`brew --prefix`/include -L`brew --prefix`/lib" make all install
    
    # to install in the default location (/usr/local)
    sudo OPTFLAGS="-I`brew --prefix`/include -L`brew --prefix`/lib" make all install
    

    Comments

  2. Aug
    15

    Mongomatic

    Posted in : ruby, mongo, and benchmark

    An addition to our series of MongoDB ORM benchmarks, a brand new ruby orm for MongoDB called Mongomatic which claim to wash whiter than washing competitors.

    Mongomatic versus Mongoid

    Our benchmark highlight the fact that Mongomatic let MongoID in the dust in raw speed. I don’t know if Mongomatic is the best orms for MongoDB, but it may actually be the fastest.

    The source for all these benchmarks is freely available on github.

    Comments

  3. Aug
    02

    Compile WSO2/WSF-C and WSO2/WSF-ruby on Snow Leopard

    Posted in : ruby, wso2, wsf, macosx, and snow leopard

    If you tried to compile compile WSO2/WSF-C and WSO2/WSF-Ruby extension on Snow Leopard, you know how painful it is.

    Here’s the configure options for WSO2/WSF-C

    ./configure --prefix=/opt/wso2/wsf_c CC="gcc-4.0" CXX="g++-4.0" CPPFLAGS="-DHAVE_GETIFADDRS"
    

    Then for WSO2/WSF-Ruby, you will have to replace all occurences of:

    axis2-1.4.0 with axis2-1.6.0
    rampart-1.2.0 with rampart-1.3.0
    

    Use the provided script to find rbconfig.rb file:

    ruby find_rbconfig.rb
    

    And add following configs:

    #---------------------------------------------------------------------------------
    CONFIG["WSFC_HOME"] = "/opt/wso2/wsf_c"
    CONFIG["WSF_LOG_DIR"] = "/var/log/"
    CONFIG["WSF_LOG_LEVEL"] = "3"
    CONFIG["WSF_RUBY_HOME"] = "/opt/wso2/wsf_ruby"
    #---------------------------------------------------------------------------------
    

    And run the build script:

    # if you're using rvm
    sh build.sh
    # else
    sudo sh build.sh
    

    Comments

  4. Jul
    24

    Benchmark various MongoDB ORM for Ruby

    Posted in : ruby, mongo_mapper, mongoid, and benchmark

    Inspired by a benchmark of MongoDB versus SQLite by Jeremy Evans, the famous author of Sequel, here is a benchmark of MongoDB via the mongo ruby driver versus Sqlite via Sequel:

    Mongo versus Sqlite

    The faster “select alls” can be easily explained: SQLite ids are simple integers whereas mongo ids look like this:

    BSON::ObjectID('4c4b20a41a221842e3000002')
    

    So there’re simply more data the gather each time. Sqlite is quite fast in fact, but don’t forget that it offers neither concurrency nor scalability.

    More interesting is the following chart featuring MongoMapper versus Mongoid versus plain mongo ruby driver:

    MongoMapper versus Mongoid

    And here’s more ODM bench:

    MongoModel versus Candy versus MongoRecord versus MongoDoc

    The source for all these benchmarks is freely available on github.

    Comments

  5. Jul
    20

    Add routes at runtime on Rails 3

    Posted in : rails and rails 3

    Sometimes you just want to take the forbidden path. We had the case quite recently, while testing a Paypal integration. We did want to add a route to a fake Paypal service with a link back to our website after succesful payment, but at the same time we didn’t want to polute our routes.rb just for test purpose. Hopefully, it’s still possible to add routes at runtime even on Rails 3. The issue is calling Rails::Application.routes.draw clears all existing routes and after that no further route can be defined. The solution is inspired by how Rails is doing route reloading:

    begin
      _routes = Rails::Application.routes
      _routes.disable_clear_and_finalize = true
      _routes.clear!
      Rails::Application.routes_reloader.paths.each{ |path| load(path) }
      _routes.draw do
        # here you can add any route you want
        get "/test#{rand(1000000)}", :to => "sessions#new"
      end
      ActiveSupport.on_load(:action_controller) { _routes.finalize! }
    ensure
      _routes.disable_clear_and_finalize = false
    end

    Please note that using Rails::Application is deprecated and that you should replace it with MyApplicationName::Application everywhere instead. Happy hacking ;)

    Comments