Weird RSpec practice.

Posted by labria on June 25, 2009

I recently found myself doing a wierd thing. While writing specs i add this spec to the end of the file:

 
it "should fail" do
  raise "foo"
end
 

The reason to do it? Simple: every time i have all the specs passing in the current file, autospec begins running all the specs in my project, breaking my red-green cycle for about 30 seconds. Adding a failing spec prevents it from doing it, and speeds up my work.

Am I doing something wrong?

A new version of my First App. *updated*

Posted by labria on April 28, 2009

After quite some time with the docs and google (and help on IRC from some a nice guy named Sidnicious) I finally made my app behave as it should, and now it shortens the URLs you drop on it (as was requested by one of my very few users).

UPD: It now has Growl integration! Hooray!

You can grab the new version here

Seems the last thing to do is to add some configuration (api key for instance).

Heroku pricing.

Posted by labria on April 24, 2009

Heroku announced their pricing today. As with all rails-centric hosting solutions, the price is sky high. You can get a LOT more if you just go and get Amazon EC2 and set everything up yourself. Yes, they do provide you with automatic and painless scaling, but for the price difference I would prefer the pain of scaling, once i get to the point of needing it.

Anybody needs Amazon deployment? Feel free to contact me =)

My first Cocoa app.

Posted by labria on April 20, 2009

I love Objective-C.

I understood that while writing my first app, a dead simple bit.ly client. The app is a bleeding beta yet, but it works.
The thing is simple, you copy a link, run the app (from the dock, its faster to do it that way), and you get a short link in your clipboard to paste.
One of the current limitations is that it only works with URLs without parameters. It will silently fail if the URL is too complex, leaving you with an empty clipboard =)

Update: The new version handles all urls, it seems.

The todo list is as follows:

  • Let the user change the api key used.
  • Handle all kinds of urls.
  • maybe: run in background monitoring the clipboard and shorten urls if found =)

Download it: cocobit.zip

Feedback is welcome =)

At last!

Posted by labria on April 17, 2009

They made it!
Phusion has released passenger with nginx support.
No more bloated apache installs, hooray!
I've been waiting for this since the day passenger was first released.
UPD: well, it has some issues as of now, but I'm sure it's all gonna be fixed soon enough!

Status update.

Posted by labria on March 22, 2009

It's been awhile since I last wrote here. Quite a lot happened in the meantime.

I now work at a really nice russian company named Getalime. It's small, very friendly and cozy. Funny thing is that 2 weeks after joining it I moved to live in Israel, so I never met any of my coworkers =)

I've been involved in a lot of Rails (and even one Merb) projects. My first patch has been accepted to the Rails core. I'm one of the two first russian regular ruby podcasters, with 100+ RSS subscribers and around 400 listeners of each episode. I'm not sure if it's a lot or not, but I'm happy anyway =)

Now I've decided that it was about time to revive this blog, and so I will try! See you soon, i hope.

WordPress migration.

Posted by labria on March 21, 2009

Well, yes. I've done it. I betrayed ruby and rails, and migrated the blog to WordPress.

Mephisto is a nice try, but it's not as useable and powerful as the big player in blogging.

My boss said I should write my own blog in SmallTalk, which I'll probably do one day, but it's much longer to do than adding WordPress to my nginx+php-fastcgi setup =)

PS: I'll add feed redirection a bit later, for now no one will notice the migration for now

Ajaxy rails docs.

Posted by labria on May 10, 2008

I don’t know if i’m the only one with the problem, but i just couldn’t get the “doc:rails” rake task to work with the jaxdoc RDoc template. I finished by running rdoc by hand to create the docs, here’s the code Tell me if I forgot to exclude something.

Sharing sessions between Rails apps.

Posted by labria on March 27, 2008

Sometimes (in my case 2 times) you may have more than one application running off the same database, partially sharing model code. In the first case I had 4 apps (one main and four satellites) running this way, but the userbase was not shared between them (most users didn’t actually know of the other apps), so common sessions were not needed. In the second case (a distrbuted file sharing network) users floated between the main site and satellites and I wanted to include flash[:notices] while redirecting them. As you know, flash messages are kept in the session, so i needed all the apps to share the session data for the user.

There are 2 things you need to do to share sessions (this applies when using subdomains, i’m not sure if it’s doable with totally different domains).

First: make all the apps use the same session key and secret by editing the environment.rb file:

 
  config.action_controller.session = {
    :session_key => '_your_session',
    :secret      => 'some_long_string_of_letters_and_numbers'
  }
 

This is done so all your apps recognize each others session data. Second, you need to alter the session_domain option of ActionController (in one of your initializers files):

 
  ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => ".yourdomain.com")
 

This one is to make the subdomains recognize the main domain’s cookies.

My problem, however, was that this setup worked only one way. I could set session variables in the main app and read from the satellite, but not the other way. As found out later, the problem is that the rails2 default session store is CookieStore. And cookies written by the top level domain can’t be altered by subdomains. To fix this i had to migrate to the ActiveRecord session store.

After a few hours of setting all of this up and testing, I decided that all of this was too much pain and security issues to be used in production, so I’ll just have another way of sending messages between the apps. But I also thought that someone may find this info useful (the CookieStore problem wasn’t evident to me), so I wanted to share it =)

SSL client certificate login pt.4

Posted by labria on February 26, 2008

Well, I made some progress and now the whole thing is a rails plugin, based on the restful_authentication one. You can get it here: git://github.com/labria/restful-authentication.git

The readme has all the info. If something is missing, not working or anything else, please tell me, it’s my first rails plugin ever. By the way if you even bother testing it or looking at the code, please leave me a comment.

Things to do yet:

  • remove some hard-coded stuff.
  • make certificate delivery more natural (if I happen to find a way to do it)
  • dunno, I think much more will come up…