Archive for October, 2006

More on Why I Love Ruby

Tuesday, October 31st, 2006

Reading this reminds me of how much I love being in the Ruby world now.

For one, most Ruby devs these days aren’t expected to be “senior” or know how Ruby internals work. Outside of the core contributors in Japan (and a few in the states), it seems like there are really only a handful of people who really understand what’s going on in the Ruby internals.

I guess this sounds bad… but you really don’t need to know much about the internals of the language for 95% of the possible use-cases for building a real-world Ruby on Rails app.

For almost all apps out there, you’re just shuffling data & markup (html/ajax/etc) back and forth between the websever. Pretty simple stuff, which is why Ruby shines in this area. (Do you really need an EJB Container for the backend of that weblog or simple CRUD application of yours? I didn’t think so.)

With Java, especially now that they are up to version 5 and have added an incredible array of features and libraries to core, it can take you years to learn the Java API and you’ll still be a novice in other parts of the framework.

Day-to-day Ruby coding is much easier. When you’re first getting started (and working with other people’s code), you may come across Ruby constructs that you’re not familiar with, making you feel slightly back in Perl-land.

Want to collect an array of ids from an array of ActiveRecord objects? I’ve seen it done this way:

  users = User.find(:all)
  ids = []
  for user in users do
    ids < < user.id
  end

That code is perfectly fine. Anyone just getting into Ruby will be able to understand what’s going on.

But you can also do this (which you’ll see from veteran Rubyists):

  users = User.find(:all)
  ids = users.collect { |user| user.id }        # Returns something like [1,2,3,4,...]

It looks a bit cryptic at first, but eventually I decided to actually figure out what was going on in the above kind of statement! :)

You might also see this written:

  ids = users.map { |user| user.id }

That’s the same thing - “map” and “collect” are aliases for one another. (not sure which is the alias of which exactly!)

It’s simply calling a “block” (in the Ruby / functional programming parlance) on each object in the users array. Each block call can return something (in this case, an id), which then gets stuffed into the array that’s returned by the collect method. (in this case, an array of ids)

When you discover little shortcuts like these, it makes you love the Ruby language even more!

Ludo Signs with Island Records

Thursday, October 26th, 2006

Ludo - the Rock Band

Just got word that my high-school buddy Andrew Volpe and his band (Ludo) have signed with Island Records:

On Tuesday, October 3rd we signed our final papers making Ludo an Island Records recording artist. Island Records is home to artists like Bon Jovi, Fall-Out Boy, Mariah Carey, Lionel Richie, Thursday, Sum 41 and The Killers. Our search for a label has been a long one, but we were lucky enough to have several options and we’re thrilled with how things have turned out. What does all this mean? All it really means is that the next Ludo album will come out on Island Records. Which means we’ll have their help in getting our music to more people. Other than that, it’s the same Ludo.

If you haven’t heard these guys, check ‘em out on their MySpace. (esp. Hum Along - which, if on their next Island Records album, could very easily end up on pop/rock radio stations across the country, imho)

Setting up Gruff Dependencies on OS X (RMagick, ImageMagick, etc)

Thursday, October 19th, 2006

Update: Yes! These instructions did the trick.

Gruff is some hot stuff. If you’re working on a Rails app and want to pimp out your backend, or have data that would be much more useful if visually illustrated, it’s the goto tool in the RoR world.

Gruff Example
Example Gruff graph

The only problem I’ve had is getting the whole stack of dependencies installed & working on my PPC mac on OS X 10.4.8.

It seems like plenty of people have been able to get it working, so I’m not sure exactly what’s up.

I spent a few hours one night compiling/recompiling the stack to no avail. (Though, Rubyforge being down that evening didn’t help, either. :))

Just tried this option which says to install RMagick via Darwin ports:

sudo port install rb-rmagick

That didn’t work.

Now trying these instructions… (which, incidentally, weren’t available that night b/c of Rubyforge being down. Maybe it’s the golden ticket!

Wonka's golden ticket

For future Googlers… this was the error I was receiving when trying to build a Gruff graph. I must just not have Postscript/ghostcript or Freetype installed from the looks of it…

sh: line 1: gs: command not found
sh: line 1: gs: command not found
RMagick: no decode delegate for this image format `/var/tmp/magick-HGhhQTrg’.
RMagick: Postscript delegate failed `/var/tmp/magick-HGhhQTrg’.
RuntimeError: Can’t measure text. Are the fonts installed? Is the FreeType library installed?
from /usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.3/lib/gruff/base.rb:875:in `get_type_metrics’
from /usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.3/lib/gruff/base.rb:875:in `calculate_caps_height’
from /usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.3/lib/gruff/base.rb:434:in `setup_graph_measurements’
from /usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.3/lib/gruff/base.rb:397:in `setup_drawing’
from /usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.3/lib/gruff/base.rb:376:in `draw’
from /usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.3/lib/gruff/bar.rb:8:in `draw’
from /usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.3/lib/gruff/base.rb:357:in `write’

Quick n Dirty Console-like Highlighting in WordPress

Wednesday, October 11th, 2006

Just add this to your stylesheet:

#page pre {
	color: #63FF00;
	background: #000;
	overflow: auto;
	font: normal 12px "bitstream vera sans mono", monaco "lucida console", "courier new", courier, serif;
	margin: 0.9em 0; padding: 6px;
}

Then wrap your code in <pre></pre> tags.

CSS blatantly ripped from I.NFECTIO.US, though I’ve seen it around on plenty of blogs before so I think we’re OK. :)

Autoload Models in Subdirectories in Edge Rails

Wednesday, October 11th, 2006

If you have models in subdirectories in your Rails app (i.e. app/models/billing/, app/models/observers/, etc), you need to add this line to your environment.rb if you upgrade to Edge Rails:

  config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/']

Via: I.NFECTIO.US

Making $500k - Pffff. Raising $1M in VC: Priceless.

Thursday, October 5th, 2006

Update: Ted Rheingold from Dogster dropped by and wrote in the comments that they are going to break $1 million in revenue this year!

I had forgot about this, but while at the Future of Web Apps conference, Ted Rheingold of Dogster gave one of the best (if not the best) presentations.

Dogster

During his presentation Ted announced that they were now doing around $500k per year (can’t remember if it was revenue or profit, but they seem to have fairly low overhead regardless).

Anyway, he announced that and the audience was silent.

Next he announced that they raised $1 million in Venture Capital funding and everyone clapped.

Maybe it was just the awkward circumstance of the situation, but it reminded me how people in the Web 2.0 world really value VC and being the “in” startup, more so than actually generating revenue / profit.

Marcus Frind of Plentyoffish.com: Google AdSense’s $300k per month man

One example of a guy who probably doesn’t get as much respect as he deserves, despite having bootstrapped a thriving business, is Marcus Frind of Plentyoffish.com. The entire operation is apparently him and 4 servers. (he did, and still does, all the coding, marketing, etc. himself)

Here’s a photo of a check from Google to Marcus for $900k (Canadian Dollars):

Marcus Frind of plentyoffish.com's check for $900k Canadian dollars
(click for the full shot)

Marcus did get some props though from several presenters at the FoWA Summit, which I was glad to see.

How to Shoot Yourself in the Foot in Any Programming Language

Wednesday, October 4th, 2006

This is destined to be a classic.

My favorites:

C++
You accidentally create a dozen clones of yourself and shoot them all in the foot. Providing emergency medical assistance is impossible since you can’t tell which are bitwise copies and which are just pointing at others and saying, “That’s me, over there.”

JAVA
After importing java.awt.right.foot.* and java.awt.gun.right.hand.*, and writing the classes and methods of those classes needed, you’ve forgotten what the hell you’re doing.

Ruby
Your foot is ready to be shot in roughly five minutes, but you just can’t find anywhere to shoot it.

PHP
You shoot yourself in the foot with a gun made with pieces from 300 other guns.

ASP.NET
Find a gun, it falls apart. Put it back together, it falls apart again. You try using the .GUN Framework, it falls apart. You stab yourself in the foot instead.

SQL
SELECT @ammo:=bullet FROM gun WHERE trigger = ‘PULLED’;
INSERT INTO leg (foot) VALUES (@ammo);

Perl
You shoot yourself in the foot, but nobody can understand how you did it. Six months later, neither can you. (via Andy)

CSS
You shoot your right foot with one hand, then switch hands to shoot your left foot but you realize that the gun has turned into a banana.


You are currently browsing the Shanti’s Dispatches weblog archives for October, 2006.

Shanti A. Braford blogs here.

If you really want to know, just read this.



  

Powered by FeedBlitz