watch this  

the official mrchucho blog

Impressed Again

Posted 2006 Dec 12

I’ve been working on a big Rails project and I’m still finding things that impress me. Recently, I wanted the equivalent of SQL’s “IN” statement, e.g.


select *
from people
where first_name in ('MrChucho','MsChucho')
I wasn’t immediately sure how to do this with Active Record, so I tried what seemed most intuitive: passing an Array to find…

Person.find_by_first_name(['MrChucho','MsChucho'])
It worked perfectly!

comments (1)

Chucho MUD: Now dependency-free!

Posted 2006 Nov 11

I’ve updated Chucho MUD to remove the dependency on Teensy MUD. I doubt my network code is as robust, but I’m glad to be rid of the dependency. Still, I owe Teensy MUD a lot for inspiration!

Also, I’ve started adding preliminary ERB support for descriptions (and, eventually, all output). Using ERB has even allowed some “markup”, e.g.


You see a < % red do %>red< % end %> flag.
All ERB parsing occurs in the Reporter—right before it’s sent to the client. Another example:

desc = %{\
You are in the < %=room.name%>. You see < %= room.items.join(', ') %>. 
}
I’ll be adding more (consistent) support soon.

comments (1)

SOA is...

Posted 2006 Nov 07

As someone who is constantly subjected to the SOA gospel, SOA Facts made my year.

J2EE can sometimes make a diamond from a lump of coal. SOA can make diamonds from air.

I’m trying to decide between posting a copy on the wall outside my cube or “accidentally” leaving it on the printer trays on my floor…

comments (0)

Chucho MUD Hosted

Posted 2006 Nov 03

I’ve setup a Google Code project for Chucho MUD, complete with a Subversion Repository and Issue Tracker.

You can grab the latest version:

svn checkout http://chuchomud.googlecode.com/svn/trunk/ chuchomud

There’s still a dependency on Teensy MUD for the networking core, but that project seems to have disappeared… But you can grab the latest version (2.10.0) via MUD Magic and stick it under vendor.

I’ve reworked a lot of the code and added some unit tests. There is still a lot unfinished, but it’ll run. There’s a “test” game database under test/game.

comments (0)

Unit Testing Ruby Singletons

Posted 2006 Oct 31

I found an interesting post via reddit about how the Singleton pattern is incompatible with Unit Testing. I’ve certainly encountered difficulties unit testing a Singleton that maintains any sort of state. I posted the following as a comment, but my code didn’t format properly, so here it is:

I’ve encountered this problem recently using Ruby. Thankfully, with Ruby I can create a singleton of my Singleton class for use in my unit tests. In this test-specific singleton I can add “reset” or “clear” method to reset the state. Assuming I have a singleton called “OnlyOne”:
def test_singleton
  class &lt;&lt; OnlyOne.instance
    def reset
      # reset state
    end
  end

  OnlyOne.instance.modify_state
  OnlyOne.instance.reset  
end
comments (0)

Clever Ruby Idiom

Posted 2006 Sep 23
Whilst whipping-up another Rbot plugin yesterday, I wanted to concisely say “sometimes do something”. I found this at Ruby Garden
def sometimes
    yield if rand > 0.5
end
Now I can do this:
sometimes do
    some_action
end

I love that!

comments (0)

Contact

Posted 2006 Jun 27

<!-contact form->

comments (0)

Encouraging Signs from Yahoo! Dev Network

Posted 2006 Jun 22

Looks like Jeremy Zawodny is back at the Yahoo! Developer Network. I posted my request regarding adding support for Yahoo! Shortcuts. Hopefully we’ll see some action!

comments (0)

Forecast Plugin for Rbot

Posted 2006 Feb 16

Another day, another weather/Ruby/IRC plugin :)

This time it’s an rbot IRC plugin for weather forecasts. It also uses the Yahoo Maps API, so any free-form location works, e.g.

rbot forecast Tulsa, OK

or

rbot forecast 74104

Download it here: [forecast.rb]

comments (0)

When did Yahoo get so cool?

Posted 2006 Feb 15

I have to say: I’m really impressed with Yahoo! lately. I have used a personalized My Yahoo! for the longest time, but have never really thought of Yahoo as “cool”. First, my encounter with the Yahoo Maps API, then their new ajaxalicious UI library and now a tweaked-out My Yahoo!

The new My Yahoo! has site-specific mini-icons in each of the content bars—which I great because I collate feeds from Reuters, AP, del.ico.us, and others. Besides being drag-and-drop capable, the context boxes also show a mini preview in a tooltip.

I also want to thank Yahoo for adding “Submits over SSL” to the mail login… That saves me like 10,000 clicks over the course of a year ;)

My Yahoo! is the “dashboard” that Dashboard can only hope to be: it’s open, powerful, portable and - now - sexy!

comments (0)
atom rss