Archive for the 'programming' Category

Open rdocs for installed gems

By way of Ruby Inside, this site has a .bash(rc|_profile) function/completion to open rdocs for installed gems on your machine.

I changed it slightly so that it would just open in a new tab in firefox.

Put this in your .bash(rc|_profile):

export GEMDIR=`gem env gemdir`
 
gemdoc() {
  firefox -new-tab $GEMDIR/doc/`$(which ls) $GEMDIR/doc | grep $1 | sort | tail -1`/rdoc/index.html
}
 
_gemdocomplete() {
  COMPREPLY=($(compgen -W '$(`which ls` $GEMDIR/doc)' -- ${COMP_WORDS[COMP_CWORD]}))
  return 0
}
 
complete -o default -o nospace -F _gemdocomplete gemdoc

Then source that file, and try it out.


$ gemdoc acts[tab][tab]

Will show you all the gems you have that start with acts. Then complete the whole thing and it will open the rdoc in a new tab in your already running instance of Firefox.

I probably already told you but…

There is a social networking site just for people interested in Ruby Called acts_as_community.

It’s somewhat interesting, and of course I signed up, but we’ll see how much it gets used.

Firebug on Firefox 3

If you are a web developer and you recently installed Firefox 3 you may have realized that the Firebug extension no longer works. I installed the Firebug-1.2 beta this morning and it seems to be working.

Capistrano Hangs on Upload

If you find that Capistrano is hanging when you are attempting to deploy, adding:

set :synchronous_connect, true

to your deploy.rb file should fix you right up.

A little more on editors

I have been pretty open about my editor use over the last few months. I switched to emacs a while ago, then was trying Open Komodo, etc.

Then I became a consultant. It was cool at first, I have computer mojo, I am into this stuff, I decided to keep messing with my tools. I was spending a lot of time getting Open Komodo, or Gedit to a usable state. Once in a while I was popping back into emacs to see if I could make a go of things.

Then it happened. I realized, oh crap, I really am a consultant, and they really are only going to pay me for N hours on this, I actually have to get this done.

And like a little boy running for his mothers arms, I folded like a lawn chair. Hello tabbed terminal with 4 instances of vim going. For the last several weeks I have been using vim, and vim alone. I really do hope this is temporary, because I think there are things that other editors offer that I’d like to take advantage of. And I like to push myself into new things and ways of thinking. I hope that I have a long and satisfying life with many editors.

Editors and IDE’s

A while ago, I switched from Vim to Emacs. I did this for a couple of reasons. Mostly I was hoping to learn elisp which would enable me to make the editor do what I want, and avoid frustration with limitations. You can do similar things in vim, but vim script is uglier than home made sin. I wanted to avoid that if I could.

I didn’t exactly throw myself into elisp, and as a result had trouble making it do even minor things.

Yesterday I got to spend some time with David. He’s the only person I have ever met who is more chronically dissatisfied with software than I am.

We discussed some of our frustrations with emacs, and by the time the conversation was over, I had decided to play around with some other editors and see what is out there.

To be more specific, I don’t want just an editor; I actually do want an IDE. I have eschewed them in the past, but after using Eclipse and RadRails and most recently ecb with emacs, I really want a decent file browser. I’d also like integration with version control and perhaps some other things. Most of all, I want to script it in a language that I know, or could know pretty easily. I’d also prefer that language not be Python (that’s right, I’m a hater :).

This led me to looking at free IDE’s.

Recently it appears ActiveState made their Komodo Edit editor open source. I installed that last night and played with it until about 2:30 in the morning. It’s actually quite cool.

At this point I have only done a small sub set of tasks in it, so I am unprepared to give it a ringing endorsement, but it’s quite usable.

One of the things I find frustrating with IDE’s is the editor portion is usually quite poor. OpenKomodo has a vi mode which gives you access to a lot of the vi(m) commands you already know. That is clutch.

I still have a lot of things I want to explore, but so far I give it a Nathan Powell “Not horrible” award. I will try to put together something a little more coherent later. I just wanted to scratch out my first impressions here.

P.S.
I think I have found a bug though. In using Visual Block Mode (in command mode: C-v) the cursor highlights properly, but when you operate on the region it behaves like Visual Line. That’s too bad, as I like that feature in vi(m) a lot. Maybe I am mistaken and if you know what I am doing wrong, please leave a comment.

Fun with irb

irb can be a lot of fun. I will usually fire it up to test something out as I am looking over some ruby.

ruby sub-reddit

Just to help the cause, I will post that reddit now has a dedicated sub-reddit for Ruby.

Random array element in Ruby

Was looking for the Ruby way to return a random array element.

  
  array = [foo, bar, baz]
  puts array[rand(a.size)]

My collection

I really like computer books. Well, I really like books. One type of books I buy is computer/programming related bookery.

I recently picked up two new books. K&R’s The C Programming Language Second Edition and Design Patterns by the GoF

I have been reading K&R and it’s very accessible so far, even for a dynamic language junkie like me. I hope to get a little more deft with C…if only for fun.

Anyway, I am happy to have added these two to the collection of books.

Next Page »