Ruby

Sharing my cool toys

I was berated the other day by Keith. He told me about PLEAC and I said yeah, I know!! He said no fair you didn't share your cool toys! So for all you remaining coders out there, I'm sharing! Here's a few handy code snippet sites and I'll review for you today.

PLEAC
This site uses the Perl Cookbook as the basis (which has the Perl source freely available) and volunteers rewrite the snippets in other languages where possible. Very handy, if you know one language and wonder how you would do it in another language.

Learning Design Patterns - Decorator Pattern

This week I'll be hanging the Decorator Pattern in my series on design patterns plucked from this book and from examples on the Internet.

What is it?
An important design rule is to design your code to be open for extension, but closed for modification, and the Decorator Pattern is one way to go about extending existing code. The decorator wraps up an existing object and then adds functionality to it; and since the decorator is of the same type as the object it wraps, the effect should be seamless for client code (unless client code is relying on the concrete type of the original object).

Design Patterns - Observer in Ruby

Last week, I wrote about the Singleton pattern in Ruby much like Rusty Divine did about Java/C#/.NET. Since his second entry was about the Observer pattern, I thought I'd write about its Ruby implementation.

Learning Design Patterns - Factory Pattern

This week I'll be manufacturing the Factory Pattern in my series on design patterns plucked from this book and from examples on the Internet.

Design Patterns - A Singleton in Ruby

Rusty Divine recently posted a look at the Singleton design pattern, with some Java and C# based examples.

I wanted to show that same pattern using Ruby:

The end of the year is always so strange...

There's always this mantra of wanting to spend up certain pools of dollars so as to not pay taxes on it. At the same time, some purchases need to wait until Jan 1 in order for the money to be there. Always fun times.

Things are quiet for me at the moment. I'm in maintenance mode until next week when most of the facility is gone and I can go through and perform some much needed up upgrades. As such, I don't have much to share.

The only nugget I can give you is this: O'Reilly just started a Ruby focused blog, and I'm a contributor. Point your browser over to http://www.oreillynet.com/ruby and check it OUT.

Open Source Can Still be a bit Closed

It's no secret - I'm a huge fan of Ruby.

I had a user recently on the ruby-talk mailing list make it known that QtRuby was acting up for him with Debian. There was some discussion, but no resolution.

A few days ago, I had another Gentoo Developer tell me the same thing. So I investigated. And I found that QtRuby worked fine with Ruby <= 1.8.3, but broke with Ruby 1.8.4.

I dove in.

HTML Helpers - Ruby Wannabes in PHP

I've gone back and forth on the idea of using ALL html generation functions to hammering it all out in a template like Smarty. Templates are nice, It sure is nice to use functions. I was looking at RoR and saw these HTML helper functions. I thought, hey I can write them in php. (Yeah to all you php hating ruby folks, this may be an effort in futility, but thinking how to implement some of these things in PHP helps me understand the concept, like my MVC articles)

Implementing just a few… Here's what I came up with:

Master Plan v0.2

CodeSnipers has been growing pleasantly over the past few months and I believe it's reaching a critical tipping point. After the holidays, there are going to be a series of announcements about new functionality, areas, and ideas that will be coming about in this little community. If all goes well, some of them may happen when they're announced.

Anyway, towards this goal, I'm looking for a few brave people to share their thoughts, bare their souls, and generally start a discussion with the community. I'm not looking for just any people, but people with particular skills:

First, I need a .htaccess/mod_rewrite wizard. I'm not looking for any work to be done, but just to get some questions answered and bounce some opinions around.

Business and Database Logic, Part 2

In a previous post on the subject, I touched on some thoughts I had based my application needs to keep data in a database over a period of time, without using updates and deletes.

After doing some pencil and paper design, and a lot of thought, I think I figured out the easiest way to implement this.

From a database standpoint, what we really have is a simple one-to-many relationship. For example:

Let’s say we define an employees table. I want to put as little information in here as possible, and yet I want the most amount of static information available in this table as well. For the purpose of this example, let’s just assume that the only thing static about an employee is their name.