Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 16:59:00 GMT)

Upgraded to Typo trunk

Posted by Wed, 31 Aug 2005 20:52:00 GMT

I haven’t taken the time to upgrade my Typo install in a while… mainly because I knew that I’d have to work on the theme a bunch to get it right.

Well, I fiddled for a bit and here it is… latest typo trunk.

Some css stuff to fix here and there, but I might hold off as I have a new design coming soon, when I announce some other fun news. :-)

DHH interviewed by O'Reilly

Posted by Wed, 31 Aug 2005 10:46:00 GMT

I just finished reading a very nice interview of David by O’Reilly

You can read it here.

While reading it, I recalled a brief conversation that I had the other day, when someone said that they didn’t like Rails because, “it assumes things” which translated to the fact that they didn’t like that it had a uniform directory structure, pre-defined naming conventions, etc.

After spending this whole year, teaching myself Rails, reading the documentation pages… (probably at the API site a few hours a day), this concerned me. A lot of people are quickly turned off by the fact that Rails has opinions. But, let’s think about this for a moment. Rails has opinions built-in that help speed up the development process when you accept those opinions. If you don’t, you don’t have to pspend any more time than you did prior to using Rails. So, their argument is, “why bother with Rails?”

At first, the answer isn’t so obvious…. but if you consider all the opinions that Rails expresses, do you honestly feel that every one of them is wrong? If so, Rails is probably not for you. If you find a good portion of them to be quality opinions, then… Rails just might be your cup of tea afterall.

Pluralization make you feel weird? Turn it off. (one line of code will do this for your whole application.

Wait, you want to use category_id as your primary key?

class Category < ActiveRecord::Base
  set_primary_key "category_id"

Yes, I know… it’s tough. ;-)

Another thing that I am wondering now… what is the conductor?

My guess? Some added bonus for Rails that allows you to run a Rails application off of one or many servers… now that would be nice. That’s my guess though… what is yours?

Ajax versus Wink, the battle begins

Posted by Thu, 25 Aug 2005 21:50:00 GMT

I am sorry. I am so sorry. I helped spread the wink and what happened… the wink has a problem with ajax.

That’s right.

AJAX and WINK do not like each other. It’s a battle between good and evil, but we don’t know which one is good.

Rumor has it that _why is working on breaking up the cat fight, but until that happens, my lovely blog and other lovely typo blogs are going to be wink less.

I also heard that he is blaming someone named json parser for the trouble.

UPDATE as it stands right now. There are TWO winks on this blog… and until the _why overlord fixes the problems created by our new enemy json parser we will be forced to sit on our hands and wait for new wink-compliance relases.

I have also heard rumors that three small animals in Jerey were wink’d and never returned home. In Boise, a woman by the name of Ruby has filed a lawsuit against the wink overlord.

Thank you hoodwink.d

Posted by Thu, 25 Aug 2005 14:02:00 GMT

So, a few days ago… I accepted the rules of the wink and have been an active winker since Tuesday… when the winking began.

If you haven’t winked yet… it might be a good time to start doing so. (while it’s cool… )

Hipster is out.. Winkster is in.

Thanks _why!

...35 winks to date!

harrisj> robbyonrails: yes, you're winking all over the place... keep it up and you'll go blind. ;) 

robbyonrails> harrisj: i saw that you winkd last night

harrisj> robbyonrails: been doing it here and there this morning... have to get it out of my system before i head off on vacation...

I have just joined #hoodwinkd on freenode.

Boys from the Hoodwink.d

Posted by Tue, 23 Aug 2005 16:43:00 GMT

hoodwink.d is going to change the world… or at least how we talk about you when you’re not looking. :-)

hint: _why

(click to view large version)

PL/Ruby loves RubyGems and DRb

Posted by Mon, 22 Aug 2005 20:09:00 GMT

I admit it. I have had a torrid love affair with procedural languages ever since I started playing with PostgreSQL. The ability to share logic amongst all the applications touching the same database server.. was…well… a breath of fresh air.

What is a procedural language in Postgresql?

PostgreSQL docs describe them as, ”…allows user-defined functions to be written in other languages besides SQL and C. “

Well, PostgreSQL has PLs for Perl, Python, Java, C, PHP… and even RUBY!

CREATE FUNCTION ruby_max(int4, int4) RETURNS int4 AS '
    if args[0].to_i > args[1].to_i
        return args[0]
        return args[1]
' LANGUAGE 'plruby';

PL/PGSQL is nice and all, but it’s not as fun as playing with Ruby. PL/Perl… well is perl, and PL/Python… is python. Both PL/Perl and PL/Python have untrusted variants. You see, they don’t want your PostgreSQL server to do anything harmful to the machine by being able to do stuff like system(‘cat /dev/null > /etc/passwd). But for some people, (like me) they want the flexibility of their language anyways. :-)

Note: Never do this if your system user that runs PostgreSQL has privileges to do anything harmful on your system.

The PL/Ruby documentation is minimal at the moment, but covers enough to get you started. I don’t know if many people are using it out there… but hopefully that is about to change! I’ve played with it a bit, but always wanted to be able to do stuff like require ‘rubygems’, but this is a feature of an untrusted language. I even found myself digging around in C code to see if I could figure out how to hack the plruby language to skip over those checks… but I am not a C programmer and I got lost in some header files.

Then it hit me. “Why haven’t you emailed the author?”

So I emailed the author of PL/Ruby, Guy Decoux, who responded pretty quickly with the answer to my dreams! Okay, I do have bigger dreams than this… but you get the idea.

First of all, some of you might be thinking, ”Why on Earth would you want to do this?”

Well, here is a simple example of how it could be used with RedCloth Let’s say that I want to be able to perform the following query from within SQL.

SELECT redcloth(‘strong text and emphasized text‘);

Why not do this in the application? Well, I do actually have a case where I have an older PHP application that I will be porting to Ruby in the future, but would like to give the application some access to some of the features of Ruby that I will be using, such as RedCloth.

Okay, so show me an example of one of these scary PostgreSQL functions.

CREATE FUNCTION redcloth(text) RETURNS text AS '

  require ''rubygems''
  require ''redcloth''

  content = args[0]

  rc =

  return rc.to_html

' LANGUAGE 'plruby';

”Wait! You said this would be scary!?”

Well, PL/Ruby allows you to write… plain ole Ruby within your functions. (do you see where I am getting here?)

PL/Ruby meets RedCloth

 rb=# SELECT redcloth('*strong text* and _emphasized text_');
 <p><strong>strong text</strong> and <em>emphasized text</em></p>
(1 row)

PL/Ruby meets ShortURL

CREATE FUNCTION rubyurlize(text) RETURNS text AS '

  require ''rubygems''
  require ''shorturl''

  return ShortURL.shorten(args[0])

' LANGUAGE 'plruby';

...which allows for

 rb=# SELECT
rb-#   rubyurlize('') as link1,
rb-#   rubyurlize('') as link2;
          link1           |         link2
--------------------------+------------------------ |
(1 row)

PostgreSQL meets DRb

Okay, this is one of the reasons why I wanted to play with PL/Ruby a bit more. Distributed Ruby Objects… from PostreSQL?

What is DRb?

If you don’t know already… per the description in RDOC, “dRuby is a distributed object system for Ruby. It allows an object in one Ruby process to invoke methods on an object in another Ruby process on the same or a different machine.”

It basically allows you to share an object to other machines… at the same time!

mmm…distributed objects…

DRb Object

Here is a simple ruby script that you would run from the shell. It creates a DRb object which accepts connections at localhost:9000.


require 'drb'

class MyRemoteObject
  def say(str)
    return "You say #{str}. I say #{str.reverse.upcase}!" 

server =

DRb.start_service('druby://localhost:9000', server)

Start me up!

$ ruby mydrb.rb

Now that we have DRb running and listening for connections…we need a client to connect to it.

DRb function in PL/Ruby

Here is a very simple DRb client script and I just drop that into a PostgreSQL function.

CREATE FUNCTION drb_test(text) RETURNS text AS '

  require ''drb''


  ro =, ''druby://localhost:9000'')

  return ro.say(args[0])

' LANGUAGE 'plruby';

The result?

rb=# SELECT drb_test('Potato');
 You say Potato. I say OTATOP!
(1 row)

Are we having fun yet?

Okay, so how do I manage to get this to work? Well… for that, you will have to read my blog post, Installing untrusted PL/Ruby for PostgreSQL

Let’s all go get some coffee (or tea) and start playing with PL/Ruby today!

Older posts: 1 2 3 4