Archive for the 'ruby' Category

How to disable Ruby “Insecure world writable dir” warnings

In your ruby script, start with this line:

#! /usr/bin/ruby -W0

Don’t even think of lecturing me on the wisdom of this. Sometimes I just want to write one-off scripts and have them read files from globally writable directories.

Things that bother me about Ruby

I’m getting past that initial infatuation stage with Ruby. At first, you love a new language. It seems so perfect, flawless. The creators are geniuses! You want to use it for everything, especially that pet project you’ve been meaning to get to. It would be so easy with [insert new language name here], she is so fantastic!

As with any relationship, it’s important to communicate with your partner about flaws you see in each other.

OK, Ruby, you know I love you, but here are some things that really bother me:

1. The community web infrastructure stinks. A very large percentage of the time, when I need to go check online doc or whatever for Ruby, the ruby site is down. And, when it’s not down, it’s S-L-O-W.

2. Ruby is slow. Face it. It is. If you have anything computationally intensive to do, forget it. And don’t tell me to implement those things in C and make Ruby wrappers for them. If I wanted to go back to 1991 and write in C (those were good times, C, we’re still friends, right?), I would do that. There’s no justifiable reason by an interpreted languages should be so slow in straight line execution. I know, programmer time is much more valuable than CPU time, but when you eventually scale to needing several hundred machines or so, it’s not true anymore. Price out hardware, rack space, power and cooling for 200 servers and think about how much programmer time you could buy for that.

3. The online doc needs a lot of work. While there are some great tutorials (e.g. from why the lucky stiff), the online reference doc is weird (four-part scrolling frames? ew.) and incomplete. This one will take the most time to work itself out.

4. The cult of 37signals and rails. I like rails; it’s once of the nicest web app development frameworks I’ve seen. And I really like the software that 37signals has created. Those guys are smart programmers and designers, and I would hire them if given the chance. But there’s a certain arrogance/contrived wisdom building up there. At work, we’ve actually had people comment on our UI in some (generally clueless) way, and cite 37signals philosophy as backing them up. Now, I wouldn’t say that everything we do on our product is the greatest UI or idea. In fact, our development process and philosophy is very similar to that espoused by the “Getting Real”™ crowd. My annoyance stems from the fact that “you should be like 37signals” becomes a euphamism for “i don’t like your UI.”

I’m just old and cranky.

Tips for installing Ruby mysql module in OS X Tiger

I got my new machine and my ruby installation was pretty broken. The ruby that comes with Mac OS X is hopelessly out-of-date, and I had forgotten the things to do to get it to work.

Hand-building ruby from source to get to 1.8.4 is the first thing to do. Then I move the /usr/bin/ruby that comes with mac out of the way and create a symlink to /usr/local/bin/ruby, and ditto for /usr/lib/ruby (symlink to /usr/local/lib/ruby). That way I’m not going to get confused and launch the wrong ruby.

Then, you need to install the Ruby mysql module. I guess I’m a mysql bigot, but don’t most people use mysql? I know that there are lots of choices out there, but mysql is what most people use, just for fooling around with stuff at least. Seriously.

To build ruby mysql, follow the instructions at the tmtm.org. In particular, you want to make sure that the configurator can find your mysql includes and libs, e.g.:

% ruby extconf.rb --with-mysql-dir=/usr/local/mysql

TextMate is a good editor.

I’ve been an emacs user for 20 years. Gosh, that is scary. Every now and then I try to use a different, “modern” editor or IDE for a while. Visual Studio. Borland JBuilder. Eclipse. TPU. (ha! just kidding. I used TPU before I used emacs).

I always end up going back to emacs.

Since I’ve been experimenting with Ruby on Rails, I’m trying TextMate. It has emacs-ish basic bindings, so it’s tolerable out of the gate. It has a nice, simple, but powerful extension mechanism, with a lot of pragmatic tools that cover all the languages I care about. It also has very nice Rails support, apparently because all the Railserati use it. Watch the video demo, and you might want to try it to.

So far, I’ve used it long enough to actually pay the shareware fee. I really like it. Let’s see if I’m still using it in a month.

Ruby, Mac OS X, gems problem

I wanted to add the Ruby gem “termios” which allows setting properties on a TTY so you can to single-keystroke input processing. I found a nice recipe for this here, but I ran into problems with Gems. I could have sworn that it was working fine (and I was right, it turns out.)

The error I got was: “can’t find ruby headers,” and it turns out to be caused by the latest XCode Update which has universal binary support. The fix is pretty mundane; just some symlinks so the headers will be found in the default place:

cd /usr/lib/ruby/1.8/powerpc-darwin8.0
sudo ln -s ../universal-darwin8.0/* ./

Now gems is happy again. This is all in 10.4/Tiger, BTW.