24 Pull Requests

We all (I) are usually in a stage where we really want to contribute to Open Source projects but are not sure where to start or what to do. One solid conclusion that I resorted to was that you need to focus on building stuff with the tools you love and eventually you will automatically start contributing to it. This is a proven and IMHO the right way. That said, we all want to help other developers and projects even if we don’t use those projects quite often just because of the fact that we love how Open Source works! But then we go back to square one where we are not sure where to start. This is where initiatives like 24 Pull Requests come in.

24 Pull Requests (24PR) encourages developers to ‘gift’ code to projects in the days leading up to Christmas in December. They have a nice website where you can see your pull requests and you can select the pull request that you wanna gift for a particular day. I came across this a year ago but never took interest. But this time I badly wanted to contribute somehow and the timing could not have been better. The great thing about 24PR is the way they suggest projects for us to contribute. Most of these projects have amazingly friendly maintainers who would love to have your code. This gave a much needed kick-start and I’ve started contributing albeit in a very small way. But I am sure this is going to give me a great experience that’s gonna help me realize my desire to contribute more to the community which has given me everything as a developer.

I have decided to translate the 24 Pull Requests website into Tamil with help from couple of my colleagues. The work is partly over. Cant wait to see this project in my beloved language!

Go on! Don’t just sit there, there are only a few days left for Christmas. Get some pull requests in!

Super cool way to create Ruby Hash

Today I came across a really cool method in Ruby’s Hash class. I cannot believe I missed it all these days. Its a class method and its syntax is:


Since Ruby is cool, when you do Hash[1,2,3,4] you actually are doing Hash[](1,2,3,4).

So what does it do? It simply creates hashes from Arrays. There are many ways to use this method to create Hashes. We’ll see one by one. The first way is to simply pass an array of elements like this:


When you do that you get the following Hash as the result:

{1=>2, 3=>4}

Neat. Right? So the important point we must note here is the fact that we should always pass in an array with even length else Ruby will raise odd number of arguments for Hash error and you probably understand why this is the case.

The second way is to pass an array of key-value pairs and you will get a hash as the result like so:

Hash[1=>2,3=>4] #=> {1=>2,3=>4}

And the third is especially awesome. Take a look for yourself.

Hash[ [ [1,2], [3,4] ] ] #=> {1=>2,3=>4}

This is very useful when you have an ActiveRecord::Relation object and you want to construct a Hash from the records represented by that object. For example, I have a model called ReferenceDatum. I have three attributes – ref_category, ref_name, ref_value. What if I want to create a hash like {ref_name=>ref_value}? I could just do something like:

Hash[ReferenceDatum.where(:ref_category=>'mycat').map{|r| [r.ref_name,r.ref_value] }]

There are other ways to do this job as well. But I find this pleasing to the eye (barring the part where we do the mapping ofc!).

Have fun!

Connect to FTP server through Windows Explorer

Im one of those guys who say we hate Windows. Its fair enough since we are developers and developing web and other applications on Windows does suck big time. But most of the time our hatred or abuse of Windows comes from ignorance. I left windows years back and started using Linux for development but now in my new job I am having to use windows to develop with the RhoMobile studio. And everytime I use Windows I find out some cool feature that I did not know it existed. Maybe this is an obvious feature for all you Windows users out there but I never knew you could connect to an FTP server right from Windows Explorer. I do this all the time from Nautilus in Ubuntu and I always wished things would be as simple as that in Windows. But I knew windows had a ftp client in it and I thought it can be accessed only via the command line.

Today I got frustrated with Filezilla and thought of using ftp.exe and I googled for some documentation when I found out that I could use Windows Explorer directly. All I had to do was just enter the server’s URL in the address bar and that’s it! So I typed ‘ftp://steve@ftp.myserver.com’ and it opened up a window to ask for my password and I could now browse the server through Explorer.

Neat is it not? So I learned a good lesson to not to blindly hate an OS or anything without properly using it. But at the end of the day Windows does suck for development unless you’re doing something with .NET 😀 I use Powershell + Console2 and Sublime Text to make life slightly better.

Amazing support from Heroku

You must have heard of and used Heroku. They are an amazing cloud hosting company. Their success was and is largely because on the ability to deploy with minimal complexity without much knowledge of setting up a production server. This was a boon to beginner developers who wanted to show case and demo their work. I was one such developer who used Heroku frequently. In September this year I deployed a slightly modified build of Diaspora on Heroku and I scaled it up to use 2 web dynos and a worker dyno. I was playing around with it and I knew that if I scale it down after few hours I wouldn’t incur costs because of the free credit that Heroku offers. But unfortunately I forgot to scale it down and I left it just like that.

Last week I received the credit card bill and I was shocked to see that I was charged $70 (~ Rs. 4300) by Heroku. I was baffled and then I realized that I had scaled up my Diaspora instance and wondered if I had scaled it back down. I opened Heroku’s dashboard and found out that I had failed to scale it down. I was really upset and I checked my account and I saw that I was going to be charged $71 for October as well. I really did not know what to do. 8k for two months for doing nothing is something that is unacceptable. I should have been more careful. I also knew that Heroku would send out an email notifying the usage. I missed that email somehow.

I sat down trying to come up with some explanation to make me feel better 😀 and then the thought of actually contacting Heroku to ask for help struck me. So I opened a support ticket requesting them to help me out. I had not made even a single request to that app and so I had some faith that I would get something out of it. I got a reply from @rhyselsmore saying that the billing team is looking into my issue. At this point the way I looked at Heroku completely changed. It was some hosting company to me before that. All that came to my mind when I thought of was the blue website and the clean and modern dash and the amazing interface to scale your infrastructure and the super awesome CLI tool. But now there was a human touch to it. I realized that Heroku is run by humans and they are awesome people who help those in need! So my confidence rose.

Couple of hours later I got the amazing news from a person called Jen saying that they would cancel the October bill provided I be careful in future. It felt amazing. I was incredibly happy. This maybe something pretty trivial but for me it was quite amazing. Heroku helped me save 4000 rupees and changed the way I look at them and the other amazing tech companies that make the lives of developers enjoyable and comfortable. Kudos to Heroku!