August 12th, 2006
A bunch of cool stuff I found over the weekend that didn’t individually deserve a blog post, but I thought would be worth sharing.
Extract Any Archive with Ruby
This is really neat if you could never remember what commands or command-line arguments you need to extracting archives (.zip, .tar.gz, .tar.bz2 - those kinds of archives).
With this Extract Any Archive script written in Ruby, instead of
tar jxvf DonkeyPr0n.tar.bz2
you can simply do
e DonkeyPr0n.tar.bz2
Instant gratification!
Slim Timer
SlimTimer is one another of those productivity-keep-track-of-your-todo-list type applications - I like it because seeing the time ticking away gets you motivated on sticking to the task at hand. You can stick it into your Firefox sidebar and all that AJAX-y stuff makes it behave like a normal application.
Feedalizer - transform web pages into RSS feeds
Choon Keat pointed this out to me recently: Feedalizer (backed by Hpricot). I played around with it and it was so easy (and fun) to use. Whipped up a Mongrel news feed (code) for Mongrel news (which didn’t have an RSS feed). The hardest part was figuring out which Hpricot methods to use to parse the bits I needed.
Served by Apache 2.2, mod_proxy_balancer, and Mongrel
I got off my butt and set up Apache 2.2 with mod_proxy_balancer to load-balance a cluster of Mongrel processes, if you’re still seeing this, that means it hasn’t crashed, yet :p. Just kidding heh - I’m finding this setup pretty stable, though there was once the mongrel processes seem to have been over-loaded with requests (with 96MB RAM I can only run 2 processes, and even then I run out of memory real fast due to automated comment spam - does anyone have any solutions to blocking automated comment spammers before they even hit your website?).
In any case, I learnt quite a bit as I was setting up my deployment environment for Rails, and hopefully someone will be able to benefit from that when I finish my post on the topic.
August 11th, 2006
If you’re seeing this, that means the new DNS settings have finally resolved and you’re being served by a plain old Mongrel server instance on my Rimuhosting VPS. It’s so much faster than before.
Before you start lecturing me on running just Mongrel, let me just say that now isn’t right time to get a proper setup - I’ll get it done over the weekend. There’re so many choices (combinations of Apache, lighttpd, pound, pen, mongrel, mongrel_cluster), I think I’m due for some reading before making a choice.
If you see any bugs, let me know! Of course, any deployment-related advice will be appreciated.
August 10th, 2006
After being plagued with performance issues running Typo (the blog software on which this blog currently runs) on Dreamhost, I decided it was time to give in and get a VPS once again. I was previously with Linode.com (they have a great control panel where you can drop in the distro you want - still have screenshots somewhere for an unpublished post), and then JVDS (good hosting, usually quick replies to my support tickets, but slow to push out a VPS control panel they’ve been promising), running Gentoo on both VPSs. Right now, I’m on a shared hosting plan with Dreamhost.
Well, Dreamhost has been good to me - I got so many referral credits from them that they paid for my subscription many times over after I posted about their $0.77/month offer. Unfortunately, Typo seems to be quite a monster (compared to Wordpress), and database access is purportedly (and observably) slow on Dreamhost. Still, Dreamhost is a great host for shared hosting, I’m sticking with them for delivering more static content. A VPS just makes sense now that I’ve been tinkering more with Ruby on Rails, plus which geek wouldn’t admit it just feels more right to be in full control of your server (well, it’s root on a virtual machine, but still root).
This time around, I chose Rimuhosting, a New Zealand-based hosting company (servers are US-based, of course), and here’s why (I did some research once again on WebHostingTalk and asked some people their experiences with their webhosts):
Pros:
- Fairly affordable prices - I got their cheapest MiroVPS1 plan, which goes for $19.95/month and get 30GB of transfer and 96MB of RAM (which could be a problem, but upgrading seems easy enough anyway from what they say on their site). Comparing to several other VPS hosts like unixshell, Tektonic.net, ServerAxis, their plans are somewhat mid-range.
- Their reputation is great. Yup, I’ve heard and read only good things about them, something that’s quite hard to find in the world of web hosting. We use them at work to setup servers sometimes too.
- Seems to be run by competent people - they have a bliki (blog + wiki) with some nice posts. The one that really caught my eye is the one on their Ruby on Rails hosting stack. Not that I’d use it since I’m on Ubuntu, but it shows that the folks at Rimuhosting are up-to-date.
- They run Xen, which Deepak, among others, tells me is the most efficient server virtualization software. Yeah, whatever, score one for statistics (and lies).
- Support is reasonably fast - got replies to my pre-sales queries reasonably fast (more than a few hours, but it wasn’t during working hours anyway). Of course, I’ll have to see how it goes now that I’m a real customer.
- A simple web-based control panel where I can reboot the VPS. It’s no Virtuozzo Power Panels, but it’s enough. JVDS didn’t have one and it started to get old sending support tickets to do a reboot.
Cons:
- They don’t support Gentoo, my Linux distro of choice. Only RHEL, Ubuntu, Debian and Fedora Core are supported. I went with Ubuntu, not having much experience with it (excluding a brief affair with Debian). I was wary of this at first, but my fears of bungling around with an unfamiliar distro have vanished after I saw how easy it is to install stuff with apt-get, and things are not placed in weird places in the filesystem hierarchy. I think I could get used to it, this “not compiling everything that moves” idea ;).
- ServerAxis supports Gentoo, and offers much better “value for money”, except that their lowest priced plan is much higher ($30). But you get 512MB RAM, 200GB RAM, and 5 IP addresses… Too bad I’d rather pay out of my PayPal funds.
Well, less blogging, more server migration. Actually the application installs are mostly done. I’ve never had apt-get play so nice back when I was experimenting with Debian - just
apt-get install [package] and things are installed quite cleanly (keyword: “cleanly”). I think this may grow on me (yeah yeah laugh and point at the Ubuntu noob) - perhaps you don’t need to compile everything (gasp, I said it!).
August 10th, 2006
For anyone who cares or who runs a production site on Rails, DHH just announced the release of Rails 1.1.5 with an undisclosed security patch. Time to
gem install rails
and update your config/environment.rb to use the Rails 1.1.5
# Specifies gem version of Rails to use when
# vendor/rails is not present
RAILS_GEM_VERSION = '1.1.5'
August 9th, 2006
Just some notes on reflection and introspection in Ruby
someString = 'http://google.com'
# Print the object's class, methods, superclass and
# ancestors (mixins and superclasses),
p someString.class
p someString.methods
p someString.class.superclass
p someString.class.ancestors
# Print the methods of the String class.
p String.private_instance_methods(false)
p String.public_instance_methods(false)
# Pass true to recurse into parent classes.
p String.public_instance_methods(true)
# Calling instance methods with send().
"Random text".send(:length) # 11
-23.send(:succ) # 22
# Using Method objects and call().
length_method = "Random text".method(:length)
length_method.call # 11
# Another way, using eval().
length_method = %q{"Random text".length}
eval length_method
Check out Distributed Ruby (DRb): it’s a very neat, non-fancy way of exposing object methods as remote services.