Koke’s

My English alter-ego

Finding obsolete templates in Rails

Posted by Jorge Bernal August 17, 2006

Sometimes when you start writing code as a proof of concept, and develop from there, it’s likely that ther will be obsolete code.

I found some unused template files in my last project. That’s because the UI changed (for better, I hope) or some other reasons. So I wrote a simple rake task to see if there wer other pieces of unused code: unused_views.rake

It’s not perfect, it might not be the best solution, but it does the job.

require "application" 

desc "Finds unused or obsolete views"
task :unused_views => :environment do
  # First find controllers
  all_controllers = Dir.glob("#{RAILS_ROOT}/app/controllers/*_controller.rb")
  all_controllers.each do |controller|
    controller_file = File.basename(controller, '.rb')
    controller_short = File.basename(controller, '_controller.rb')
    require controller_file
    controller_name = controller_file.camelize
    controller = controller_name.constantize

    # Find methods
    methods = controller.instance_methods -
               ActionController::Base.instance_methods -
               ApplicationController.instance_methods

    # Find views
    view_files = Dir.glob("#{RAILS_ROOT}/app/views/#{controller_short}/*.rhtml")
    view_files.map! {|file| File.basename(file,'.rhtml')}
    view_files.reject! {|file| file =~ /^_/ }

    view_files.each do |vf|
      unless methods.include?(vf)
        puts "Obsolete view #{controller_short}/#{vf}.rhtml"
      end
    end
  end
end

Of course it could just remove the old files, but maybe you want to check them first (in case you are not using a RCS yet).

Warning: You may still have template files which don’t match any method name. Be sure about what you’re doing before removing anything, and most important don’t blame me if you lose code (only I can do that :P).

AddThis Social Bookmark Button   AddThis Feed Button

WTF IRL

Posted by Jorge Bernal August 16, 2006

No comments…

Next Stop: (null)

Via: Pop-up Potpourri: Announced By God

Note: Just in case you don’t understand the title…

ababol:~ koke$ wtf wtf
WTF: {what,where,who,why} the fuck
ababol:~ koke$ wtf irl
IRL: in real life

AddThis Social Bookmark Button   AddThis Feed Button

Goat Motor Show

Posted by Jorge Bernal August 04, 2006

This not the kind of news I post here, but it’s so surprising that I have to tell it.

Read on Spanish press: Localizan una cabra que circulaba en ciclomotor en Tenerife.

Found a goat running in a motorbike in Tenerife

Local police agents intercepted a motorbike after detecting three occupants on it. In their identification they discovered one of them was a goat, which had been put a helmet.

[…]

After checking they had no documentation at all, the human occupants of the vehicle were sued for not having driving license, insurance and motorbike documentation.

So you know a new option to ride like a wild in Spain. You can be Farruquito or a goat.

Definitely, Spain is different

AddThis Social Bookmark Button   AddThis Feed Button

Honesty in business

Posted by Jorge Bernal August 02, 2006

I was planing to post about this, but I’ve found Seth Godin has explained better first in Three important lessons from Dreamhost.

The DreamHost guys have been suffering some outage problems in their data centers, which turns into problems for all of their customers.

They start by telling

Here I’ll try and go into as much detail as possible about what happened, why, and the steps we’re taking to stop this sort of thing from ever happening again. I can’t excuse what happened, just apologize and hopefully elucidate.

And that’s what they do in a really long post.

I have too tell I might be a little biased on this subject since all of us who belong to the computer industry know sadly well that shit happens (more often than desired). So if you can avoid it, better you handle it the best way possible.

In Seth’s words:

Lesson one: when things get messed up, being clear, self-critical and apologetic is really the only way to deal with customers if you expect them to give you another chance.

AddThis Social Bookmark Button   AddThis Feed Button

SmilePooling is coming…

Posted by Jorge Bernal August 02, 2006

SmilePooling logo
I think it’s time to introduce our new project, in which I’ve been working for the last month: SmilePooling

Simply put, SmilePooling is a web application to order items from Amazon stores for you and your friends and colleagues, so that you can split the shipping costs.

This saving can be ridiculous or even null for people living in the US, UK or any other country with an Amazon local store. But in Europe, the combined rate from US for books is $4.49, in Africa is $6.99, and $8.99 in Middle East. If you can split that by sharing an order with two friends everybody wins.

Right now we are starting our private beta, inviting some friends and polishing it for the public. It’s intended to go public by the end of August (you don’t want us to launch it while we are on vacation, do you?).

If you are interested and want to stay informed, you can enter your email address on http://smilepooling.com/, or visit our blog. There is also a feed for announcements only at http://feeds.feedburner.com/SmilepoolingAnnouncements.

Share the smile box!
The SmilePooling team

AddThis Social Bookmark Button   AddThis Feed Button