Rails 3 and Apache X-Sendfile

Tags

, , , ,

The Rails 2 way of using x_sendfile: When using send_file, pass an options hash with options[:x_sendfile] = true. This will take care of streaming the file via Apache freeing up Rails.

Changes in Rails 3:

The x_sendfile option to send_file is now deprecated.

There is a new application configuration “config.action_dispatch.x_sendfile_header” set to “X-Sendfile” defined  in config/production.rb. This means that send_file automatically gets the X-Sendfile headers in the production environment. For other environments, we need to copy this setting manually.

The main backend change done in Rails 3 for send_file is to use the Rack::Sendfile middleware. As documented in the link, a request header need to be set before starting to process the request – “RequestHeader Set X-Sendfile-Type X-Sendfile”.

The log no longer prints “Sent X-Sendfile header..” when send_file is used with X-Sendfile option like it used to be in Rails 2. The message is changed to simply log “Sent file..”.

Note: mod_xsendfile needs to be properly enabled in Apache as a prerequisite. Nginx also has its setting defined in production.rb, but this post dealt only with Apache.

Advertisements

Twitter – Old and New

Tags

What I like in the new Twitter?

  • The Timeline, Mentions, Re-tweets available in tabs.
  • Layout changes causing Trends to move up the page.
  • Search moved to the top bar.
  • A better looking profile page. Way better than the old one!
  • Keyboard shortcuts. Who doesn’t love those?!

And what I don’t?

  • Bugs. For instance, I’m yet to create a list successfully since I got new Twitter.
  • The Search input box retaining the text “Search” even when clicked inside is annoying at the least.
  • When viewing a user profile, the lists that they create, they follow etc are now hidden.
  • Missing  “You both follow” and “Also followed by your follows” information.
  • No notification of direct messages.

Also, why is that the Settings page still has the old UI going back to the old header and footer having old links?

Renaming the Git Master Branch

Tags

, , ,

Recently when I wanted to rename my git master branch (using grb rename), I encountered this error in the step when grb deletes the master branch in the server.

git push origin :refs/heads/master
remote: error: By default, deleting the current branch is denied, because the next
remote: error: ‘git clone’ won’t result in any file checked out, causing confusion.
remote: error: You can set ‘receive.denyDeleteCurrent’ configuration variable to
remote: error: ‘warn’ or ‘ignore’ in the remote repository to allow deleting the
remote: error: current branch, with or without a warning message.
remote: error: To squelch this message, you can set it to ‘refuse’.
remote: error: refusing to delete the current branch: refs/heads/master

A quick search revealed that it is not possible to do the rename, at least without getting into some trouble! So here’s what I did as a work around to rename the master branch.

There is a file “HEAD” located in the git repository containing the line: ref: refs/heads/master. This is apparently the branch to pick whenever the repository is cloned.

Changing this line to point to another branch and cloning the repo proved my guess right. Now, I went ahead with the rename using grb again and this time it went through successfully. Of course, I went and changed the “HEAD” file back to it’s original as I had another branch renamed to master.

Waking up from hibernation

Tags

,

Wow! 100+ days of no activity on the blog. I really had gone underground I guess! I wonder what can explain such lethargy when I had actually resolved to write more at the start of this year. Lots of things had happened in the last 3 months, since my last post when I launched TwitVance, which is doing well, to my surprise and joy 🙂

Changed residence after 17 years; learned a lot in handling relationships; started disliking cricket; followed FIFA’10; watched loads of films and TV shows; saw my nephew grow happily; bid goodbye to MJ as he left for Mumbai; got a big project to work on Rails and Java together. And forgot the rest of my life’s last three months 😛

TwitVance – Twitter Scheduler

Tags

, , , , ,

Remember the extended hiatus ? Well, I have been working on a personal project for most of that time. I have launched TwitVance, a Twitter scheduler application today.

Here’s a quick overview of the application: TwitVance allows users to add any number of Twitter accounts and schedule tweets for the future. The application uses OAuth and avoids getting the Twitter credentials of users. Scheduled tweets can be edited or deleted at any time before it gets published to Twitter. One of the things I most like about the app and loved building is the bit.ly integration for URL shortening. If users have bit.ly accounts, they can provide the API key in the application and track all the URLs they use in their tweets riding on bit.ly’s power!

So, go ahead and sign up now! Start tweeting.. in adVance 🙂

RubyConf India 2010

Tags

, ,

At first I thought I should write about such an event in a formal manner. But pack, there are other people who can do that. I will do this post in my own agile way.

Sometime last week, while chatting with Manu, he told me about RubyConf India and that he is attending the event happening on March 20 and 21. That started an interesting week and several “firsts” for me! Having been to Bangalore only twice before (and both times with loads of people accompanying), I have no freaking clue about the place. I have very few friends in the city and have never travelled alone before! Venkat solved my staying problem by letting me stay in his place. The best thing is that the venue is barely 10 mins away from his home by walk! Now, how lucky is that?! But, the sad thing is that he (and his room-mate) are to come to Chennai for the two days that I need to be there. So I have to stay alone. Hoo! That’s another first! Anyway, reached Bangalore safely and after a minor glitch [ok, got down at cantonment unknowingly :)] reached Venkat’s place only to find a sleepy security guard refusing to let me in. Venkat to the rescue again at 5 in the morning. I OWE the guy, I know!

Fast forward to the conference…

Talks were mostly good! Really enjoyed talks by Matz, Obie and a couple of others. Talked with a few people and listened to quite a lot.

Matz won over people with his awesome presentation in which he tried to foresee Ruby’s future. It was interesting to learn about Ruby’s history from the creator himself. He named it Ruby on Feb 24, 1993 even before starting work and his reason being that he wanted a jewel name and Ruby is small and beautiful and Pearl (Perl) was already taken! Terseness started with the name! There was an interesting revelation: it took him about six months to get “Hello World” running. He also told the conference that Ruby 1.9.2 is getting released this August.

Obie was fun, controversial, opinionated all at once! Loved him asking people to use torrents to download books (even his own) acknowledging the fact that books are costly in India! I should try reading at least a few of the books he mentioned. I was surprised when the organisers asked him to cut down his use of the f-word. Why the hell do we need to stereotype ourselves as culturally superior? To his credit, he apologised publicly. And later when I got a chance to speak with him, he mentioned that had the organisers told him earlier, he would have definitely not used the f-word.

Other talks that I enjoyed touched upon programming languages, Ruby objects, Rails 3 and GlassFish.

Overall, the conference was good and it was a nice weekend spent and yeah, the food was great 🙂