Return to 10to1.be

Under the Hat


Fake data populator

23 Jul 2010

When you’re building webapps, sooner or later you run into a screen where you want to list some data. An index page of all people for instance. There are many other cases where you want a lot of data, but for now, let’s follow this path.

Say, you got thousands of people, you’re not going to show them all on one page, do you? Probably you will use something like will_paginate.

Say, you want to see this pagination stuff in action, in your development environment. Since you are not going to manualy create a couple of thousand people, one option could be to set the number of results per page to 1 or 5 or 6 or … well you know what I mean.

An other option, better option, is to use the populator and/or faker gem(s). The populator gems adds a method ‘populate’ to all Active Record models.

Person.populate(3000) do |person|
  person.first_name = "John"
  person.last_name = "Smith"
  person.number_of_shoes = 1..100
end

This will create 3000 people with the name John Smith. It becomes better when you throw in the faker gem.

Person.populate(3000) do |person|
  person.first_name = Faker::Name.first_name
  person.last_name = Faker::Name.last_name
  person.number_of_shoes = 1..100
  person.email = Faker::Internet.free_email
end

This will create 3000 people with random names, which is better if you ask me.

We grow software

17 Jun 2010

Since 10to1 started (which seems ages ago, and yesterday at the same time), we’ve been telling people that we develop software. Or maybe that we create it, or even build it.

These seem to be the verbs that people use when talking about software. It’s something that you build, like a house, or a car. You take some piece of code from this library and a nice hack from that library, glue it together in your favorite language, et voilà, your software is ready. Everything else in this world is built that way, so it’s only logical software is built the same way.

Completely logical. Except that, well, it isn’t like that.

Creating software is more like creating a painting. You start with an outline of what you want, and then you start adding details, and color, and generally, make it a complete painting. And then, when you’re satisfied with your painting, it’s finished.

Creating software is even more like creating a business. You start with a limited set of functions, and then you add a service here, and a feature there. Your business grows and before you know it, you are Apple.

An even more compelling image is that of a tree. You start by making sure there is a trunk. This trunk is the core of your application: it will support all functionality. Just like the trunk grows with the rest of the tree, your core starts small, and grows.

Once the trunk is in place, the branches are added. You add a bit of functionality here, add some extra-nice usability there. Branches that are seldom used, get less attention than those that are used every day. Branches that are ugly, or not used at all, are cut. You don’t know which branches will be ugly, or will get a lot of attention from the start. But you do know it when you see the tree in all its glory.

We think that the tree analogy matches perfectly on how we believe software should be created. That’s why, from hence forward, 10to1 will describe its activities as ‘We grow software’.

Secret pictures (SPIC)

27 Apr 2010

A couple of weeks ago, ruby-play was imminent and in such a case one should always try some new things. Heroku is hot, so it had to be something I could deploy on Heroku. Sinatra 1.0 was released, so it had to be something using Sinatra.

What else? S3 is always fun and with that in mind I found the CarrierWave gem.

More? Sure. To experiment with something else then ActiveRecord I used Sequel.

Does it blend? Sure!

A new example app was born: SPIC. Spic (secret pictures) allows you to upload files to S3 for your sharing pleasure.

Heroku really is fun to use. One can setup Spic in only a matter of seconds.

git clone git://github.com/atog/spic.git
cd spic
heroku create
git push heroku master
heroku config:add S3_KEY=your_s3_key S3_SECRET=your_amazon_secret S3_BUCKET=your_bucket SECRET=your_own_personal_jesus
heroku open

It was fun. It was short. It is good.

Capfire, post deploy notifications to Campfire

02 Apr 2010

We use github for all our projects, and we use Campfire as our office backchannel. So when we saw this post we (or maybe it was just me, I’m a sucker for this kind of stuff) knew we had to have a way to easily use this on all our projects; so here it is: Capfire

What it does

Besides being a kickass gem name, it sends a message to Campfire each time you deploy an application. In this message is a link to Github’s compare-view, so you can easily scan just what has changed since your previous deployment. Since it’s being sent to Campfire everyone can take a peek. Great !

Installation

First install the gem:

gem install capfire

First run

script/generate capfire -k campfiretoken -a campfireaccount -r campfireroom

This will add a snippet to your config/deploy.rb to include the capfire capistrano script and will create a file in your home folder named .campfire containing your token, account, room and a configurable message (the parts between ##’s are substituted).

Like this (be careful with your spaces):

campfire:
  account: 10to1
  token: thishastobeyourtoken
  room: General
  message: "I (#deployer#) deployed #application#
 with `cap #args#` (#compare_url#)"

If you’re not sure about this automagically thing, you can do it by hand as well, create the ~/.campfire file and add the following to your config/deploy.rb:

begin
  require 'capfire/capistrano'
rescue Object
  # Don't force other users to install Capfire.
end

Subsequent runs

Since a ~/.campfire file already exists you can just run script/generate capfire to add the snippet to your deploy script in each app. You can run this as much you want it will only add the snippet once. No worries.

If someone else on your team doesn’t have capfire installed, he won’t notice a thing (but be sure to mock him).

I hope you, dear reader, like it as much as we do :)

Things are going fast

01 Apr 2010

We all have those periods of time when nothing seems to happen in our lives.

And then, all of a sudden, things go so fast that you’re having trouble to understand what’s happening.

This is how I feel today.

At the end of last year, we decided to find a Ruby on Rails developer. We were psyched when Piet told us he wanted to work with us. We’ve never been more content with an employee.

But after a few weeks, we saw that even Piets addition to the team wasn’t enough to keep us up to speed. That’s why we couldn’t believe our ears when Jelle told us he, too, wants to work with us.

He’s starting today. 10to1 has been 2 people for more than 3 years. Now, we’ve grown to 4 in 5 months.

It’s awesome.


About this blog

You’re reading Under the Hat, a weblog written by 10to1.

Who’s got the mic?