Christian Hager begynner hos Skalar

Vi har fått en dyktig ny kollega.

Christian_hager

Christian Hager er en rubyist, javascript utvikler og entreprenør. De siste 3,5 årene har han jobbet freelance. Han har bygget www.arcticelvis.com alene. Den sender ut ca 500.000 epost per mnd i dag. Han har også bygget store deler av www.powest.no.

For dette jobbet Christian hos i Stig og Stein Idélaboratorium.

Han er en typisk Skalar utvikler, som jobber med hele stacken, fra oppsett av server, backend og frontend. Teknologien han liker best å jobbe med: Ruby, Rails, Sinatra, TDD med RSpec, jQuery, Backbone.js, css3, html5.

Christian har også en Master of science, Innovation and Entrepreneurship fra Universitetet i Oslo (UIO).

Han starter hos oss 1 mars men vi har allerede "sent him on a mission" for å hjelpe en av våre nye kunder, Schærven Reklamebyrå med deres backofffice Rails app.

 

Skalar skreddersyr effektive løsninger for web, iPad, android og andre digitale flater. 

 Selskapet ble grunnlagt i 2007 og har idag 11 ansatte (de har vokst fra 3 ansatte i 2010) med kompetanse innen webutvikling, interaksjonsdesign, grafisk design & konseptutvikling. For tiden jobber de med teknologier som Ruby on Rails, HTML 5, CSS 3 og Javascript.

 

Peter Skeide begynner hos Skalar

Vi ønsker Peter Skeide velkommen til Skalar. 

Peter Skeide er en engasjert konsulent med stor interesse for både de tekniske og menneskelige aspektene av fagområdet. Han er en dyktig Java- og Ruby-utvikler med fokus på webutvikling og integrasjon, og har bred erfaring med de viktigste Open Source-produktene. Med et brennende engasjement for utviklingsprosesser basert på det smidige manifest, er han også en ressursperson på spørsmål innen smidig utvikling og prosjektgjennomføring.

I Conduct har Peter jobbet på prosjekter for store aktører i det norske markedet. Han er også aktiv utvikler av TimeFlux, Conducts fritt tilgjengelige Open Source timeføringssystem basert på Ruby on Rails.

Peter er Bachelor i Data og Multimedieteknikk, Design og Systemutvikling fra Høgskolen i Gjøvik og Edith Cowan University. Han er sertifisert ScrumMaster, Sun Certified Java Programmer, og har befalsutdanning fra BSLV i Fredrikstad.

Før Peter startet i Conduct jobbet han som systemutvikler for NordPool ASA, europas ledende børs for kjøp og salg av kraftderivater.

Han starter hos oss 1 April.

Skalar skreddersyr effektive løsninger for web, iPad, android og andre digitale flater.

Selskapet ble grunnlagt i 2007 og har idag 10 ansatte (de har vokst fra 3 ansatte i 2010) med kompetanse innen webutvikling, interaksjonsdesign, grafisk design & konseptutvikling. For tiden jobber de med teknologier som Ruby on Rails, HTML 5, CSS 3 og Javascript.

Dyktig interaksjons- og designmiljø melder overgang fra IXD til Skalar, Norges ledende miljø innen Ruby on Rails

 
Thomas Grøndahl (fagansvarlig design), Roger Guttormsen (frontend-utvikler) og Eric Haidara (interaksjonsdesigner) begynner hos Skalar i vår. De kommer fra IXD AS.

Thomas, Roger og Eric er blant Norges beste på frontend-design og utvikling. Vi er veldig heldige som har fått de med på laget, sier daglig leder Victor Sanchez Barrera i Skalar.

Thomas har markert seg som en tydelig og dyktig grafisk designer og interaksjonsdesigner. Som fagansvarlig hos IXD har han de siste årene gjort en betydelig jobb med å skape gode brukeropplevelser for en rekke norske bedrifter.

Roger har bak seg mange års erfaring som interaksjonsdesigner og frontend-utvikler i både IXD og Gazette.

Eric Haidara er en dyktig grafisk designer og interaksjonsdesigner som trives best når han kan lage gode brukeropplevelser for alle. Han har gjort dette både hos IXD og University College Dublin.

Thomas og Roger begynner hos Skalar 1. april 2012. Eric begynner allerede 1. februar.

Skalar skreddersyr effektive løsninger for web, iPad, android og andre digitale flater.

Selskapet ble grunnlagt i 2007 og har idag 10 ansatte (de har vokst fra 3 ansatte i 2010) med kompetanse innen webutvikling, interaksjonsdesign, grafisk design & konseptutvikling. For tiden jobber de med teknologier som Ruby on Rails, HTML 5, CSS 3 og Javascript.

 

MassiveRecord - includes many features

When I started writing the ORM part of MassiveRecord I decided it would be smart to take a tiny winy peak into the code of both ActiveRecord and Mongoid. After all; I had never written an ORM before and it would be really stupid not to take a bit of inspiration from a couple of the well known ORMs. Not only to get inspiration, but also to use same naming and patterns where it made sense so people would feel at home entering MassiveRecord.

I want to share with you a little secret I came across writing MassiveRecord. Its not really that hard! All the free and cool stuff we take for granted, like callbacks, validations, dirty state of attributes, finder methods and persistence - it's all neatly packed up and included into the base of an ORM class. How is it all glued together? What happens when you have a person and asks it to be saved?

Lets keep it simple for a while.

You can't get it any simpler than that. Now, we want our ORM base class to be able to do some operations related to persistence, so well extend our class with this:

Cool! So, let's jump into our dedicated module for persistence and do some magic!

Our ORM can now save and destroy records. It can also delegate to create or update based on the current state of the record. But how can we make our ORM cancel the call to save if the record is invalid? We need someone responsible for validations!

..And we do need to implement it!

That didn't look too complicated, and actually, thanks to ActiveModel, that is more or less the complete validation module which MassiveRecord currently uses. When you call person.save that save call will first hit the save method defined in the Validation module (as it is included last). It takes care of performing validation and based on if that person is valid or not it either returns false right away, or calls super to let a save method "up-the-chain" handle it. And where do we end up? In the persistence module's save which takes care of saving the record now that we know it litterly passed validation.

Saving a new record will persist all of it's attributes to the database, but when we have a persisted record in the database we can keep track of which attributes has changed or not. And, when we know that, we can update only what we need when we call save on a persisted record. So, lets extend our base class one more time:

The next thing we'll need to do is to make our self the Dirty module.

This dirty module is a bit simplified from the one in MassiveRecord. There are two things worth noticing here.

First, lets take a look at save. The save method is defined here as well, but it simply forwards the call to super (Persistence module) without intercepting the call. However, when the call returns it will, based on it's success or not, reset the dirty state.

Second, the update method is overriden here. This method is being called by the persistence module when it decided the record should be updated. When the private update method is being called it begins at the bottom of the chain again, going through the dirty module. The dirty module takes a quick look at the record's changes. If it is empty it simply returns true and we will actually never do a database call (as we don't call update in the persistence module). If it is not empty it calls the update method in persistence module and injects a list of attribute names in the arguments list which should be updated.

 

All of this is pretty neat; keeping conserns tucked together in cute modules. We are also benefitting keeping methods small and simple as it makes it easy to hook into the call chain. And another good point is that you can remove the dirty module without breaking or affecting the records' ability to persist.

I hope you found it interesting, even though this was a simplified and limited example!

Informal talk with Tom Preston-Werner, co-founder of Github

After the dinner party on day 2 of Nordic Ruby 2011 I had a chance to chat with Tom Preston-Werner, co-founder of Github. Lars and I had found a quiet and warm spot where we could get out of the wind and when Tom wandered by I invited him to join us. After scrounging up some sufficiently peaty highland malt I had a chance to ask him about some of the things that make Github unique and interesting and also get some of the background color that goes beyond the purely technical aspects of development.

Tom struck me as a warm and outgoing person who was open to sharing stories and anecdotes even though he probably was a bit tired. What I was most interested in was the human aspect of how to grow a business in our domain. What's the correlation between team culture and success? What are the characteristics of individuals who succeed and experience a measure of fulfillment in their daily lives? Nordic Ruby and similar events offer a unique opportunity to exchange experiences and gain insight into the personal side of development in the context of professional and financial success as well as failure. To me, the technical aspects are fairly well documented and can be accessed through various channels. The fuzzy side involving humans is not always as clear. We are in a domain where knowledge of a technical nature is valued and quantifiable. What about the less tangible aspects of development? I was happy to see that this particular event offered quite a bit of focus on topics such as diversity, education, tolerance and sharing the occasional tale of spectacular failures.

My impression of Tom is that he and the other two co-founders are passionate about what they do. They identify needs and execute useful and successful solutions. It started with a way to leverage git and easily incorporate it into our daily lives. They have a strong commitment to open source that extends to their pricing model as well. Open source project repositories are always free. Private repos follow a tiered plan that is still dirt cheap for most. The fact that github enjoys such a strong buy-in from the development community has made it the go-to place when searching and browsing projects. What had been weak in the past was the issues feature, but this has improved to the point that many people are starting to shed their lighthouse accounts. Ours is a discerning community and decisions to adopt or reject are often binary and happen fast. And success is definitely fleeting - here today, gone tomorrow.

So how is github addressing these concerns? Some of the answer lies in the founders' personalities I believe. Tom strikes me as being very serious and respectful about what he does. He's very down-to-earth, likes a good whiskey and tinkers with rebuilding a car with a friend of his. He's married and looking to move to a bigger apartment as their current quarters are pretty small. They are thinking about having children as well. One of his passions is to write. So I saw none of the hubris that could potentially afflict someone who's reached a pretty high level of success in a competitive space. There's a good balance between being diligent and careful before adding new features and a willingness to experiment and having fun. I believe they have along the lines of 32 active internal projects. The ability to also accept failure as a part of evolving seems important in order to remove the fear of being judged and allow creativity and inspiration to flow. He told me a funny story about a bug in the early days where many commits erroneously had Yehuda Katz as the author. Turns out he was an early adopter and had user id 4. In ruby, nil.object_id returns 4 and this took a little while to track down.

Tom also likes to speak at events and does a good job. This along with his writing seems to indicate an enjoyment of communication, probably a significant interest to have. So in closing, there appear to be many factors at play that have a bearing on how a business performs. There is location, timing, execution, consistency, growth, business model, etc. Maybe what lies at the core of it is still the personal traits of the people involved. There's respect for one's craft and one's users, a fearlessness and willingness to experiment. There's having fun and being creative. There's being passionate and thankful for one's situation. There's integrity and honesty. Talking to Tom and people like him serve as reminders to me about those core values. Such qualities may be hard to find in programming books and that's why events such as Nordic Ruby, various user groups and other, non-technical disciplines can serve as useful additions to make us more well-rounded and productive individuals.

Upgrading a small Rails 3.0.5 application to 3.1 rc4

So I played a bit with Rails 3.1 release candidate four the last days. Basically I upgraded a small and simple Rails 3.0.5 app.

The set of gems

The application I'll be upgrading is a small one. Thats good; less dependency which might gets me into trouble. Mainly these are the included gems:

Let the upgrade begin!

Gemset and Gemfile

First of all; I created my own little working space (rvm gemset) so I can maintain the old code base while experimenting in case some things does not work. I kinda expect something to go wrong. You don't have to do this though.

Then I upgraded my Gemfile to gem 'rails', '~> 3.1.0.rc4' and did a complete bundle update.

I also added a few gems to match the default Gemfile of Rails 3.1 generated new application.

  • gem 'sass-rails', "~> 3.1.0.rc2"
  • gem 'coffee-script'
  • gem 'uglifier'
  • gem 'jquery-rails'

Assets directory

When bundle install completed I did a quick copy of app/assets from a generated rails 3.1 application. app/assets looks like:

  • app/assets/
  • app/assets/images
  • app/assets/images/rails.png
  • app/assets/javascripts
  • app/assets/javascripts/application.js
  • app/assets/stylesheets
  • app/assets/stylesheets/application.css

Create the directory structure, and while you are on it feel free to move public/images into app/assets/images. Same goes for public/javascripts - put it under app/assets/javascripts. By default all JS will be packaged up into one JS file, so you might want to update your application layout as well. You no longer need to load rails.js either (if you where using that, that is) as it will be concatinated inside of your application.js file as long as you require jquery_ujs.

 

Configuration files

 In config/application.rb we want to add: config.assets.enabled = true
And I need to remove this from config/environments/development.rb: config.action_view.debug_rjs = true

Are we up?

Kinda - When that is done rails console should start. rails server should too, but the first thing which blew up in my face was an ArgumentError (dump format error (user class)). I "fixed" this by simply clear cookies for the development site.

Gems

Slim

On my first refresh on the page with a Rails 3.1 in action it seems like the html escaping of things had gone a bit mad (btw I got this on Rails 3.0.8 as well). I tried to use latest version from git, but it didn't help.

After some searching I found this (it was not that much of a search) and tried to turn off pretty mode in development. Turned out that it got me a step future with some non-escaped HTML returned by the application. Oh! Btw, Slim now (latest in git) uses doctype html and not !doctype html.

Sass and Compass

The first thing I did here was to delete the initializer for compass. As the gem itself pointed out after doing the bundle update; it now has a Railtie and no longer needs an initializer file.

The next thing which needed to be sorted out was if there was any integration at all up and running between Compass and Rails' new asset pipeline. Turns out there was a work in progress on this. Reading through that issue's thread I was able to digest it down to following changes to the Gemfile:

gem 'compass', :git => 'git://github.com/chriseppstein/compass.git', :branch => 'rails31'

When that was installed I moved all files under app/stylesheets into app/assets/stylesheets. I also removed (did not use at least) the application.css and renamed all my *.sass files to *.css.sass with rename 's/\.sass$/.css.sass/' `find . -name "*.sass"` (you probably wanna change directory into app/assets/stylesheets before executing that).

Susy

The compass-susy-plugin does not seem to work for me. Right now it looks to me like the gem's scss files are not included in sass / assets load path or something, so when you do a @require susy it will fail with (a kinda cryptic) error like: "NoMethodError: undefined method `Error' for Compass:Module". I solved it temporarily by simply copy the sass/susy/_grid.scss file from the gem into app/assets/stylesheets/mixins and loaded it from there. Feel free to drop a comment if you have a better solution, as this sure ain't a pretty one.

Final words

All the other gems my small project has, like devise, cancan and carrierwave seems to be working all fine under Rails 3.1 rc4. I guess there will be some changes on the production server as well to support the new asset pipeline with Coffiescript compilation. Maybe thats for the next blog post. 

 

 

MassiveRecord - How to get started

This is the second post in my blog series about MassiveRecord, an ORM for HBase written in Ruby. If you are interessted in how it all started and a bit more introduction to MassiveRecord please head over to the first blog post.

In this post we'll go through how to set up a Ruby on Rails application using MassiveRecord as our ORM. We'll also go quick over how to set up HBase itself on your local machine for development purpose.

Install and start up Hbase and Thrift

Installing hbase should not be very complicated, espesially if you are like me using a mac with homebrew installed. Simply do a brew install hbase. Head over to http://hbase.apache.org/book/quickstart.html if you are not into home brewed stuff. There is one bit of configuration I would like to do on Hbase, and that is changing the location it stores the database. As a default it will be persisted into /tmp, which is not really that persistent after all. So we'll open up /usr/local/Cellar/hbase/conf/hbase-site.xml and configure it there. My configuration file looks like:

We can start hbase with /usr/local/Cellar/hbase/bin/start-hbase.sh. MassiveRecord communicates with HBase via Thrift (although the plan is to make it support communication using jruby and the native Java API). But for now we also need to start Thrift: /usr/local/Cellar/hbase/bin/hbase thrift -b 127.0.0.1 start.

Setting up a Rails application

MassiveRecord can ofcourse be used without Rails, but since Rails is so widely used I'll set up a new Rails application as an example. You should use Rails 3.0.x for now, as MassiveRecord and Rails 3.1 have some issues with each other.

Install Rails (if you don't have it already): gem install rails. Then create a rails application: rails new massive_record_test_app -O. The -O option tells Rails that we are not gonna use ActiveRecord. Add gem 'massive_record' to your Gemfile and do a bundle install.

MassiveRecord needs to be told where it can find the Thrift server. In a Rails application MassiveRecord will look for a configuration file under config/hbase.yml. This is basically the same as we'll normally have in config/database.yml. So, open up hbase.yml and make it look something like:

In a normal Rails application we'll have multiple databases to keep the development and test databases apart. You can do that with Hbase too, or you can suffix all tables names with the environment we are currently in. At Companybook we suffixed table names, and this can be done by creating an initializer, config/initializers/massive_record.rb:

Creating our first MassiveRecord model

Everything should now be ready to make our first MassiveRecord model. I'll create a simple Car class:

With that in place you should be able to jump into the console and test it out.

So that is MassiveRecord at it's very basic. In the posts to come I'll show some more advanced use of MssiveRecord.

MassiveRecord - a Ruby ORM for HBase

Massive ..what?

This post is the first in a serie which will be about MassiveRecord, but I guess few have ever heard of it so that's why I think you need to get a quick introduction before we'll continue along. I have been working as a consultant at a Norwegian company for some time now called Companybook. The company is a start up which expects ridiculously high load on their infrastructure and database. They are doing a lot of crawling, data analysis in their backend etc. This huge requirement has been clear from the beginning and thus they selected HBase as their main database technology.

All of this data and analytics being stored in their database is to be presented to users on the web. For this to happen they selected Ruby on Rails as the platform to be used. It's about here that Skalar comes in to the picture. They needed some experts on Ruby and on Ruby on Rails. The second thing they needed was for Rails to communicate with HBase and now we are getting closer to MassiveRecord.

The work on MassiveRecord started on 16. november, 2010. Before we actually started on the ORM we took a good look at the wonderful world of Google trying to find an ORM fitting our needs: We wanted an ORM to use ActiveModel as its base, and to really be compliant with the interface used by ActiveRecord and other ORM friends. We found some ORMs, but none that were really up to date and maintained. And who to blame; I guess there are not that many projects seeing the need for a database like HBase.

Anyway, Companybook took the hard decision to create its own ORM. We knew that creating an ORM is not something you normally should be doing, but we also knew that for this project to be sustainable over time we needed a solid base for everything else we built on top of it. We also knew that we wanted to use other gems like Devise for authentication, Carrierwave for handling file uploads, Sunspot Rails for indexing in Solr, Rspec, Cucumber, DatabaseCleaner and all of these other great libraries which makes it so pleasant to work with a Ruby on Rails application. So, by creating an up-to-speed ORM, we knew it would be easy for us to integrate against all of these other gems which would give us a lot of functionality for free. MassiveRecord had been born.

Will you ever be using HBase - why am I reading this?

Now that's a tricky question, but I think it's more likely that you will not. Most of you will be using ActiveRecord, MongoId or other ORMs. Why should you keep reading this then? MassiveRecord has taken a lot of inspiration from ActiveRecord (and some from MongoId). While I'll be writing about MassiveRecord there is a good chance that you'll learn something about ActiveRecord as well. At least I have when I wrote MassiveRecord.

In the next post I'll be taking a quick walk through on the basic of MassiveRecord. How it is built and a quick overview of it's main building blocks.

Want to check out MassiveRecord right now? Go ahead and visit the project on github. There is also an example application which you can try out.