Ubuntu 10.04 LTS: First Impression
It took lot longer than I thought to install since my guess is people are slamming the repository, but I finally got new shiny 64-bit Ubuntu 10.04 up and running. The most important part of this release is that it’s LTS, long-term support, so I’ll be using it for long time.
As far as the installation of Ruby, nothing has changed since my post on 9.10. It will install 1.8.7 version of Ruby nicely and I’m extremely happy now that gvim doesn’t throw stupid messages. The key here is that you install Ruby via apt-get and install Rubygems from the source.
What’s really nice is that it now has Ruby 1.9 and 1.9.1. For me, I still prefer compiling my own from source for 1.9.1. For 1.9.x, I’d like to compile in each extensions as needed because it gives me an insight to some of the internals. Oh yeah, I also enjoy reading code without having to be under the gun. e.g. deadline.
I’ll see if I can create a screencast or an instruction on compiling the latest Ruby and Rails over the weekend.
Passing Arguments to Rake, My Way
I’ve seen many interesting ways to pass arguments to rake tasks. The fact of matter is, I really don’t like dicking around with any constant or global variable. Here’s how I like to do it.
rake mytask:do_something setting:WHATEVER user:me
Using the argument facility built into Ruby, just create a hash inside of my task. I can even create a method to do this for all tasks. Below is my implementation.
I think it’s cleaner and easier way to do it, but that’s just my opinion. By the way, $* has an alias, ARGV.
Database During Tests
Since every apps I’ve worked on that deals with a database is in Rails, I really didn’t have to think about transactional fixtures. I also use sqlite3 db in memory, so persistence was never an issue for me. Therefore, I admit that I completely forgot about the state of the test database since Rails’ default is to use transactional fixtures.
Here’s the deal, when you run tests outside of Rails, the fixtures are NOT transactional. Rspec will not clean up after itself by default. Take a look at below.
Before running this, I created a file named rtest.sqlite3 in the same directory.
Now, here’s the test I run:
This test passes without a hitch the first time, but when I run it again, it fails. Why? The record test added is still there. It does not roll back. In order to resolve this, you’ll have to make it transactional. To do this, I rewrite the test as follows. I’d like to thank Remi at remi.org for this.
In Rails, you can turn off transactional fixtures by setting config.use_transactional_fixtures to false, but I really don’t recommend that.
Securing MongoDB
When I created the screencast series on MongoDB, I had no idea people would be so quick to put it into production. I thought I’d share my quick checklist on MongoDB in production environment to make sure it runs securely. While at it, take a look at this article.
1- Secure the host with ssh and make sure it’s not reachable from outside without going through a “gateway”. If you don’t know what this means, email me.
2- Use IPTables to lock down any access from unknown servers. link
3- Create an admin user and set authentication to admin – link
4- Set authentication to my dbs’s.
5- Change the port to something other than default 27017. I know, security through obsecurity.
Just remember that everything gets thrown out the window if you can log onto the server, including the authentication. That’s why you need to pay extra attention to securing it, not that it would be any different from any other servers.
Securing MongoDB is easy and simple. I’m sure there will be plenty of FUD around this.
The Origin of RubyHead
I don’t know if I mentioned before, but the name “RubyHead” came from “CocoaHead”. Many many years ago before the iPhone, I was thinking about going “indie”. At the time, people were saying crap like “oh, Apple is going to declare bankruptcy…” and Michael Dell even said that Apple should return the money to the stockholders.
The reason why I didn’t make the jump was the fact that I got married and had to think about my lovely wife. Being a CTO was very good to my financial health and lifestyle, and it’s really hard to give that up because I wanted to do something I enjoy. How selfish of me. If you want to know what it’s like, take a look at Drunken Batman’s video. Just google it and you’ll see.
This me brings back to today. I have made the jump to do what I enjoy, working with Ruby. Sure, I always work with the code that makes me wonder why they even wrote it in Ruby, but nevertheless I enjoy the challenge, somewhat.
So, next time you meet a “Ruby Guy” or “Java Guy”, ask them where they’ve been, you’ll find it interesting.
Camping 2.0
Rather than talk about it, here’s the entire code. Just love everything about this.
Bad Ruby Practices: Commenting Out Code
Bad Ruby Practices: Commenting Out Code from Joon You.
Screencast: Add & Remove Methods in Ruby
Here’s my first installment of Stupid Rubyist Tricks Series.
Ruby provides metaprogramming feature that’s really powerful when used properly. Here, I show you the technique, but do something stupid so you don’t do it. Enjoy!
Adding & Removing Method in Ruby from Joon You.
Using Amazon S3 with Rails Screencast
I was and still am not a big fan of the whole cloud movement. I just don’t see what the big deal is. However, it’s been demanded by the clients. I was just about to engage in common S3 storage feature and Codeulate’s Amazon S3 screencast just in time for me.
If you saw my screen cast series on MongoDB, I try to explain the underlying features before all the magic. Ben does the same thing with this screencast. He even writes tests to show you the real world example, even dropping down to console. I really appreciated the fact that he even covered the basics in details.
The illustration is simply awesome and the production quality is better than previous Vim episode. Unlike his previous one, he actually covers details and explains/spoon-feeds the bucket and the object concepts as well as the REST. I truly get a sense of complete tutorial, and I’ll even say that it’s almost good as the PeepCode.
As for the price, I initially saw $99 price tag and thought that Ben might have made a mistake. Well, he corrected the price and it’s now $9.
If you’re looking to use Amazon’s S3 in your application, you HAVE to buy this one. I can’t recommend it high enough.