Nicolas Alpi, Web developer

A blog about productivity, startups and me.

Analyse of a Disaster

Three days ago I was writting about my excitement for this year RailsRumble, so why did I decided on Sunday morning to just gave up.
I mean, it wasn’t just a temporary frustration due to lack of sleep and too much Redbull, that was really hitting the wall so hard that I could not stand up again.
Let me try to analyse this unexpected failure.

Launchanalytics

First let’s go back to my project idea. This is an idea I had few months back, having a API and a dashboard helping project developers to manage their invitation system.
You would be able to create invites, via the API or the dashboard, redeem invites and so track registered users, where they came from, enabling virality, having limited and unlimited invite code for your different invite streams, well a lot of things!
Ho and obviously, for me to be happy, the project would have a nice and appealing public design + a nice dashboard design.
And, a user could manage different projects
And … so on and so on.
I really like the idea, and those who knows me can testify that I’ve put a lot of preparation in this idea.

To big, to fast

I think my first mistake is that I was having a so clear idea of what I wanted to achieve, that I forgot about the 48 hours limit.

My expectations where way to high for this contest, and I could not imagine to deploy a half done project. Maybe I should have, after all you can’t do everything in 48 hours.

Also, when the competition started, I went directly to VIM and started writing all my tests and all my code for the models and a little bit for the controllers, so after 20 hours I was having all the application backbend ready. No views, no design but the backbend.
I didn’t step back when writing my code, I was on the urge of finishing my app as fast as possible, and I didn’t see the wall coming.

The wall

Despite all my preparation, mockups, db schema and so on, I’ve made a very strong mistake, something that after 24 hours would have requires me at least 5 hours code changes if I wanted to have everything working as expected.
At this point I tried to remove features that I knew would have been affected by this problem, but to be honest there was no so much left.
I tried to review my initial plan, moved to not having public website but only an admin section, with a demo application, but well, I was very angry at myself about this stupid mistake, and could not continue anything else but ranting.

Giving up, and after

So I decided to gave up, I shut down the webserver, and went to bed. I can tell you that, when your competing, it’s a really hard decision to give up. And you spend the rest of your day thinking if that was the right decision, and if you shouldn’t have continued instead.
In 3 years of rumbling it’s the first time I give up, and I hope I’ll never do fail again.

Learn from your mistakes they say …

I forgot what was the Rails Rumble

In addition, I think that I forgot very strong parameter: I forgot what was the Rails Rumble.
I forgot how (nicely) intense it was, I forgot that you can’t do everything in 48 hours.
But must of all, I forgot it was all about fun. It’s fun to code, it’s fun to give birth to an application in 48 hours, but I put too much pressure on myself for this one.
I wanted my application ready to use, nearly “perfect”, with this “whaou” effect for the guys who will go on the website and register.

So and now

Well, I still belive that Launchanalytics is a good idea, it was certainly to big to be created during the Rumble, but a beta version will be released soon. Maybe in the next 2 or 3 weeks.
Besides that, I’ll learn from my failure and will be back next year, for this awesome competition.
I’m sure that next year I’ll choose a much more manageable project, and why not, this time, try to do it with a team.
Thanks a lot to all the RailsRumble organisers, you make this competition as awesome as it can be!
Congratulation to everyone who participated, and good luck for the voting period now.

You can have a look to all the awesome applications that were created at http://railsrumble.com/teams.

RailsRumble Tonight

So tonight is RailsRumble night.

It’s going to be my 3rd participation to the contest, and all my ammo are ready

RailsRumble, all my ammo

The rules

The rules are really simple: Create the best application you can, in 48 Hours.
From scratch, including server configuration and deployment. You are allowed to work on any project you want, the code as to be done in Ruby, but you are not allowed to work on any digital assets, tests, user stories, logo … before the competition starts.
And organisers are tracking the teams on Github.

Competition starts at 00:00 GMT, so it’s Saturday 1am here in Bristol.

Why the hell would you work for 48 Hours, on a week end!

It’s a recurring question, every time I mention the Rails Rumble.

To be honest the last 2 years, my projects where more toys than anything else. The kind of project you do and ditch when the competition is over.

But it’s still a real challenge to create an app in 48 Hours, and I like this kind of challenge. I like the moment of happiness than come with it (as well as the frustration ones :/). I like hanging in IRC and see what the others are doing, and it’s really a good time to sharpen your coding skills.

This year project, Launch[api/analytics?]

This year will be different from previous years. I’ve got a good idea I think. Something that might be useful to a lot of developers.

The name is not really decided yet, it could be launchapi or launchanalytics, or both …

Basically, when we want to launch a web application, there is always a phase of Beta. This can be a closed beta or an open beta.

When it comes to managing those invites, and making useful analytics of them, when always find our self reinventing the wheel.

So my idea is to create an api and a dashboard that will manage the invite system for the developers. The api will takes care of the invite-redeem-registration system, and the dashboard will creates nice and comprehensible results.

In the dashboard, you will be able to:

  • Manage the invites
  • See reports and graphs of number of invites vs amount of registrations.
  • Manage what I’m calling funnels and streams.

Funnels and streams are, I think, a really nice touch.

Your funnel will be used to direct the streams of your invites.

For example you can create a funnel Social Media, and have an different invite code for your twitter feed, your Facebook page and your blog. So you can track which stream is driving more attraction in your audience.

You will be able to create stream with limited invites. Let says you create a Blogger funnel. Your stream will be different bloggers, that will be able to invite their readers with an unique invite code. This invite code will give them a certain number of available invites. The report will shows you which blogger as the best virality.

To me, that sounds like a lot of fun and a good idea, we will see what the judges think about it ;)

So, and after the Rumble?

Well, this year, I am really thinking about keeping the application lives after the rumble, and because that is an application targeted for developers, I assumed that I will have a nice output of what they think about it.

What I want to add, after the Rumble is a third part to application, like a Launch Hub, where beta application developers can promote their creation, and users will be able to request an invite (using the API obviously).

So, wait and see. It should be live and running in a little bit more than 48 Hours from now ;).

Caution, Wet Paint

It’s Sunday, and I’m moving from Wordpress to the amazing Jekyll blog engine.
All the data reimport and blog post from the old Wordpress should be fine, it’s just a matter of polishing my (minimal) design now.

The code used to create this blog will soon be available on github as well.

See you soon.

My Two Weeks Pair Programming Review

The past 2 weeks I’ve paired with Theo Cushion (Theo’s Twitter | Theo’s GitHub).

Was planned some Erlang joy, a lot of system/server maintenance, good amount of Ruby and some JavaScript goodness.

Pair programming?

Pair programming is an agile software development technique in which two programmers work together at one work station. One types in code while the other reviews each line of code as it is typed in. The person typing is called the driver. The person reviewing the code is called the observer (or navigator1). The two programmers switch roles frequently (possibly every 30 minutes or less).

While reviewing, the observer also considers the strategic direction of the work, coming up with ideas for improvements and likely future problems to address. This frees the driver to focus all of his or her attention on the “tactical” aspects of completing the current task, using the observer as a safety net and guide.

Pair programming on Wikipedia

Pair setup

pair programming setup




  • We’ve used Theo’s desk, composed of a Mac laptop and a Dell 22" screen in portrait mode.
  • One keyboard one mouse.
  • 2 chairs.
  • Swapping every hour.
  • 10 working days.
  • 8/9 hours days.
  • 1 break at lunch time + 2/3 little table football breaks while tests passing.

My pair programming experience

First of all, I probably had the most enjoyable 2 weeks programming from a long time!. Lot of work but a lot of fun as well, the kind of fun you can’t have alone in your computer, this was probably the best part of the experience. Next week I’ll pair with Jamie Dyer and I expect the same amount of fun with him!

Theo is a really smart guy, smart enough to makes complicate explanations looks simpler. That was a big plus while pairing on part that I’d never worked before like the Erlang world or the XMPP world.

We found ourselves more productive than usual while pairing. First of all you can’t cheat, you are no going to open your emails/facebook/twitter/another website while the other one is typing. Two people on one computer, and regular switching, there is no way to procrastinate. Secondly, on complex problems, it’s always good to have a second pair of eyes on the proposed solution. Maybe your teammate will find a better/simpler/quicker solution to the problem. And finally it’s always good to have someone spotting the nasty typo while writing – you know forgetting a comma, forgetting to migrate the database, misspelling a word … – this can save a lot of time. So that’s a big plus in terms of productivity.

But the other side of the coin is that I finished my day way more tired. Because your brain is constantly assailed by requests, when you’re typing you have to deal with the keyboard, the screen, the problem you’re solving + someone on your back watching you and talking to you. When you’re on the back you’ll try to spot this little typo that will cause problem, or find some help in doc/book, or try to imagine a better way to correct the problem … well, basically, at the end of the day your brain is fried and so you are.

Another problem had been the gears. I’m used to work on my Linux + Openbox powered laptop, using Vim to code. Moving to Mac Os + Textmate was a “painful” experience. You have to re-learn a lot of basic commands/shortcuts, your mouse is doing silly things with the windows, and you lost your markers … I’ve asked Theo to do one week on his machine one week on mine, but the response was a loudly “HELL NO” ;).

In a nutshell

So, the dark sides are that I was exhausted and I had to learn how to pilot a Mac Os. But the bright sides were finding myself more productive, less procrastinating and having more fun during the day. No need to mention that I’ll be really happy to renew the experience next week, and I found pair programming a really interesting way to work.

What about you, did you already tried pair programming? Did you enjoy it? Don’t hesitate to share your experience in comments.

Implementing RPX With Clearance in Ruby on Rails in 5 Minutes

When it comes to user engagement, having your users being able to create an account or login with one click is a really “nice to have” feature.

This is where RPX appears to be able a really neat solution.

It allows your users to signin/signup to your website, througth the RPX widget, using their preferred provider (Google/OpenId, Facebook, …).

You can consult the RPX website for a complete list of supported provider.

Expectations

I’ll assume that you already have Clearance setup properly in your app. I presume that this tutorial can be used as a blueprint for implemennting RPX with others authentication system in Ruby on Rails.

What do we want to achieve:


  • A user should still be able to signin/signup with Clearance

  • A user should be able to create a new account throught the RPX widget

  • A user should be able to sign in throught the RPX widget

  • If an existing user sign up via the RPX widget, with an existing email, it should merge the informations

Installing rpx_now gem

First you’ll need to create an account on the RPX website. Then create your application in their application manager.

You’ll be given an access key.

Rpx_now gem is certainly the best RPX API implementation available out there.

Install it as you usually do for a gem in your Rails application, using bundler or config.gem.

Create a migration, use the migration code bellow and then run your db:migrate.

class AddIdentifierToUsers < ActiveRecord::Migration
def self.up
add_column :users, :identifier, :string
end
def self.down
remove_column :users, :identifier
end

end

We are adding the identifier column to the user table in order be know from where the users come from.

Add the RPX key in your config/environment.rb:

config.after_initialize do # so rake gems:install works
RPXNow.api_key = "YOU RPX API KEY"

end

And you’re now ready to implement the code.

New user and login with RPX

RPX doesn’t know if the user already exists in your app database or not. So handling a new user creation or login a user will use the same method.

This method is the one you specify when rendering the RPX widget inside the new session or new user views. Let’s call it rpx_token

The browser will be redirected to the rpx_token method after the RPX login process. It will be posted a token argument and will call the RPX api to retrieve the user profile informations.

Add the RPX_now embed_code method is your new session view and new user view (outside of the form).

[Create an helper is a good idea]

RPXNow.embed_code('MyRPXApplicationName', rpx_token_session_url)

You can see that we are using the rpx_token_session_url route.

This will need to be define in your config/routes.rb

map.resource  :session,
:controller => ‘sessions’,
:member     => {:rpx_token => [:post] }

Then in your sessions_controller add an rpx_token method:

def rpx_token
raise ActionController::Forbidden unless data = RPXNow.user_data(params[:token])
@user = User.find_by_identifier(data[:identifier]) || User.find_by_email(data[:email])
if @user.blank?
@user = User.new(:username => data[:username],:email => data[:email],:identifier => data[:identifier])
@user.email_confirmed = 1
@user.save
end
  1. We are using the clearance sign_in method to do the following behaviour
  2. session[:user_id] = @user.id
  3. @current_user = @user
sign_in(@user) redirect_to root_path

end

If we were only using RPX to handle user login, that would be our last step there.

But because when want to make it play it nicely with Clearance, we’ll need an extra step.

If you try to use it at this point, Clearance will complain that the new user doesn’t have any password. Fortunately there is an existing Clearance method called password_required?

So in our user model we’ll need to super seed this method in order to add our requirement.

#models/user.rb
…
def password_required?
super && identifier.blank?
end
…

Now, if there is an identifier supplied we can create the new account without password.

[Be sure that you have your tests for not being able to login is password is blank ;)].

At this point you can now create a user, login an existing user or a new user all with RPX and Clearance.

The tests

To test that I used Shoulda and Mocha.

#session_controller_tests

context "on GET :new" do
should "Display RPX widget" do
RPXNow.expects(:embed_code).with(‘MyRPXAppName’, rpx_token_session_url)
get :new
end
end

context "Connection via RPX" do context "from a non existing user" do setup do RPXNow.expects(:user_data).with("123456").returns({:email => "rpxuser@email.com",:identifier => "test",:username => "rpxusername"}) post :rpx_token, :token => "123456" end should_change "User.count", :by => 1 should "create the user with the RPX data" do assert assigns(:user).email == "rpxuser@email.com" assert assigns(:user).identifier == "test" assert assigns(:user).username == "rpxusername" end should "set the session with the newly created user informations" do assert @request.session[:user_id] == assigns(:user).id end should "confirm the email on the user creation" do assert assigns(:user).email_confirmed == true end should_redirect_to("the root page") { root_path } end context "from an existing user" do setup do @user = Factory(:user) RPXNow.expects(:user_data).with("123456").returns({:email => @user.email,:identifier => "test",:username => "rpxusername"}) post :rpx_token, :token => "123456" end should "set the session with the user informations" do assert @request.session[:user_id] == @user.id end should "not create a second user" do assert User.count == 1 end end context "with an invalid token" do setup do RPXNow.expects(:user_data).with("invalidtoken").returns(false) post :rpx_token, :token => "invalidtoken" end should_respond_with :forbidden should_not_change "User.count" end
#unit/usert_test.rb

context "A user" do

should "not request set password_requiered? to false if an identifier is set" do @user.identifier = "test" assert !@user.password_required? end should "set password_required? to true is identifier is not set" do @user.identifier = "" assert @user.password_required? end should "be able to create a user without password if identifier is set" do new_user = User.new(:email => "testgmail.com",:identifier => "test") assert @new_user.save end should "not be able to create a user without a password if identifier is not set" do new_user2 = User.new(:email => "heygmail.com") assert !@new_user2.save end

end

Conclusion

I haven’t play with the PRO features yet, but rpx_now is really simple to implement and it’s really simple to have it working along Clearance.

I hope it was useful. Let me know if you had any trouble with implementing it.

Easy Rounded Corners Working in IE7/IE8

This afternoon I was looking for a solution to (easily) add rounded corners into some elements of a website we are developing.

After having tried Curvycorners, jQuery Corners without any success (it was completely breaking the design under IE) I finally came to DD_roundies, which use Microsoft VML.

DD_roundies

DD_roundies is a really lightweight piece of code that will allows you to add rounded borders to nearly every element of you page by executing

DD_roundies.addRule('.roundify', '10px');

It’s smart enough to only apply if the Browser doesn’t support CSS border-radius styles, so you can just continue to work on your CSS for a proper implementation in other browser than IE.

Because it’s not a dream world

So this implementation is working perfectly in IE7 but doesn’t work in IE8, so if you don’t need IE8 specific functionalities I would recommend you to just add a meta in your head section to for IE7 compatibility mode in IE8.

<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible' />

or if you use HAML

%meta{:content => "IE=EmulateIE7", "http-equiv" => "X-UA-Compatible'"}

And off you go, now you can easily round everything like the cool kids ;)

Superswitcher, a Super Alternative to Alt+tab

I recently came across a fantastic alternative to the alt+tab command on Linux, it’s called Superswitcher.

superswitcher

Nice features on it

Press the command touch (Windows touch on the keyboard) to display Superswitcher.

To switch from a desktop to another press Command + arrow left or right

To switch from available windows in a desktop press Command + arrow up or down

To move a window into another desktop press Command + shift + arrow left or right

To search within all windows name Command + [any text]

Screencast

I’ve just recorded a quick screencast to show all these functionalities

So?

For me it’s now a must have on every computer I use, because it make organizing my desktops really easily.

Accelerate Your Tests in Rails With Ubuntu

I recently came across a blog post about accelerate Ubuntu disk access perfomrance.

You can read it on Smartlogic blog, it’s well explained so I’n not going to copy but I just would like to add some ideas:

You don’t need to boot on a live CD

Where Nick ask to boot on a live CD and mount your partitions, you don’t really need this part.

First open your /etc/fstab file and spot your active partitions.

For example on my development machine, I use /dev/sda1 for my / and /dev/sda6 for my /home

Close the file and run

sudo tune2fs -o journal_data_writeback /dev/sdXY

on each partitions you’ll need to tweak.

Apply noatime and data=writeback to all your working partitions

As you’ve done tune2fs on each partitions, you’ll need to change the mounting options (noatime and data=writeback) in each partitions line inside your fstab.

Do not do it on your server!

Because these modifications make the file system more fragile if crashing, please do not consider doing these tweaks on your production servers.

Enjoy the boost

Where Nick claim a 30% speed gain on his machine, I can claim a gain of more that 55% as I went down from 55 minutes to 25 minutes for the same test suites on one of the biggest application I work on!

Was it useful?

Thanks a lot to Nick Gauthier for his initial blog post, I hope it will be useful to some of you.
Let me know in the comments if you know other tweak that can make my little machine works faster.

I Want to Make 2010 Really Exciting

I’m just back from 10 days holidays in France. Catching up with family and friends was really good, but what I really enjoyed was my disconnection for all development/web platform during these 10 days.
It’s always a good way, at the end of the year, to do a little retrospective on his work/life and give the new year a fresh start.

2009 was a really busy and exciting year

While I was looking back on what happened in 2009 I found that:


  • I moved 2 times.

  • I had 1 bike accident. 2009 was a cycling year for me. I started to cycle everytime, everywhere to ditch the car. In mid year I had an accident with a broken colar bone in results. I spent nearly 3 weeks out of work. It was a really bad time.

  • I’m now engaged. This is a result of the bike accident :D.

  • I launched 3 web app. In the beginning of the year I launched Serialcooking, which is now closed but the blog is still alive. Then in September I launched Tweetcetera, an easy web twitter client. Finally in December I launched Howgoodismyfood.

  • I moved to full time freelance. This is the big change this year, and a big challenge as well as my network, in England, is not as big as it was in France.

So basically 2009 was a really good year, and I’ll work on make 2010 even better.

Make 2010 better and more exciting than 2009

  • My first decision in 2010 is to discontinue the Serialcooking web application (we’ll keep the blog alive). It was supposed to be redo from scratch (because I made a lot of UI mistakes), but finally it’s going to take a lot of time and effort, and in 2010 I really want to concentrate myself on my freelance activity.
  • I’ll blog more as well. This is going to be result of the previous decision. I’ll have more time to update this blog and to create tutorials and smaller apps.
  • Embrace this f* social media**: I’ll try to be proactive on Linkedin, facebook and Twitter.
  • I’ll do my best to attend at a minimum of 1 network/conference event a month.
  • Run the Bath half marathon
  • Release at least 3 plugins/gems: I’ve got some code in the cardboard that I need to clean up before releasing, but I’ll do it

The most important one

Find some interesting work!

As some might know I’m a workaholic, I just love coding, crafting websites, applications. So if you have any project in preparation, do not hesitate to contact me for a chat.

What’s New on Tweetcetera

Last week has been a pretty busy week, but I was able to put some time on Tweetcetera.

Appart for some little bug correction, here are the major update that have been done this week

Realtime update in title and tab bar

When Tweetcetera refresh your tweets, it display a little notification on your page displaying the number of new tweets.

tweetcetera_top_updates

Now it also display this number in your title bar and in you tab bar if you’re using a tabbed browser. That’s really convenient as you don’t need to go back to the page to view is their are updates in your network.

Real time count down

Tweetcetera now display a count down before the next auto update of your timeline, user timeline or search results.

tweetecetera_next_refresh

So you now exactly when it’s going to be refreshed.

Follow cost

Tweetcetera is now using the Followcost api to display the number of average tweets/day and the number of tweets replied on a user page.

tweetcetera_follow_cost

These indications, combined to the “mentioning” sidebar section, give you all the informations you need to decide if you’ll follow a user or not.

What’s next?

Next week I’ll be working on list implementation, and usernames auto completion. Please if you want to see any features, just drop me a message or comment on the getsatisfaction page or on this blog post.