Cursor Art

Have been using a cool product IOGraph for the past few days. The basic feature of this application is to track your mouse movements, and generate a visual, which you can opt to save as an image. Below is a sample result, that I tried.

3.6 hours of mouse activity

The above image was generated after tracking 3.6 hours of mouse activity during my day job.

You can find more images in the flickr album that I have created.

 

2013 in review

The WordPress.com stats helper monkeys prepared a 2013 annual report for this blog.

Here’s an excerpt:

A New York City subway train holds 1,200 people. This blog was viewed about 5,900 times in 2013. If it were a NYC subway train, it would take about 5 trips to carry that many people.

Click here to see the complete report.

List of open files in your Rails Environment

Sometimes when you are processing a huge number of files, you might need end up having the error “Too many open files”. I recently bumped into a similar issue, and the following code helped me solve the issue

ObjectSpace.each_object(File) do |f|
if f.path.include?("rails_app_directory/tmp/uploads") && !f.closed?
f.close
end
end

The above code looks for open file descriptors from the desired directory and closes them. You can definitely change the file path according to your needs. This basically helps you keep the number of open files in your application in control, and in turn also improves the performance of your servers.

Do not depend on rubygems.org when in production

We bumped into an issue lately, while deploying one of our major app in the production environment. Just when we tried to run the command

bundle install

we realized that the rubygems repository was facing a downtime. Hence we were not able to install gems on our production server, which in turn caused a downtime on our side.

In order to overcome this issue we took the decision of caching our gems into our application’s repository(i.e. vendor/cache directory). Below are the steps that we took:

Step 1: On your local machine run the command below

$ bundle package

this command will copy all the ‘.gem’ files and their respective dependencies in your bundle into the ‘vendor/cache’ directory of your rails application.

Step 2: Now after committing your code and running the bundle install command on your production servers, run the command below:

$ bundle install --local

The `–local` parameter will fetch the gems only inside the ‘vendor/cache’ directory of your rails application. Hence not hitting the rubygems servers.

This proves to be very helpful in cases where you want quick deployments on your servers.