December 29, 2008

Rails Studio Early Registration ends soon

I love doing the Pragmatic Studios. Nicole, Mike, and Chad are all good friends, and that creates a really relaxed and fun atmosphere for what could otherwise be a pretty intense three days.

The next studio is in Denver at the end of January, and I'm really looking forward to it—living in Texas, I relish being able to see mountains and snow. I just wish I was a skier so I could have an excuse to take an extra day or two to head on up to a resort.

If you are planning on going, though, don't put it off—early registration (a $300 savings) ends in a week.

There's one bad side to the studios, though. Mike put together a video showing what studios are like. Notice anything? Food. Lots of it. Scarily good food. Must resist. Must…



December 26, 2008

Little bit of musical fluff

56 I decided a while back to publish the music I'm writing, if nothing else as a way of keeping myself honest. So, here's a little piece of fluff I wrote just to play with time signatures—alternating 5/8 and 6/8 has a nice drive to it.

But, I have a problem: I can't actually perform any of the pieces I write, so I'm somewhat at the mercy of the good will of others (notably my teacher) to record them for me. And Christmas is a busy season for my teacher, so I don't yet have a recording of this piece.

Because this piece is so simple, Sibelius' built-in playback sounds OK, so that's what I'm posting. But if anyone fancies recording this, or taking it and turning it into something cool (as Chris Morris did with my previous piece) please send me a link and I'll add it here.

In the meantime, here's

  • the score,
  • the Sibelius mp3, and
  • a midi version (don't listen to this—it sounds horrible. It's just here for folks who want to import to a sequencer)

December 21, 2008

Clearly I've missed an opportunity with our book covers

Agile_web_dev_w_rails
Like the rest of our publishing business, I like to keep our covers simply and easy. But now I realize that these covers fail to capture the true epic nature of our books. Joey deVilla posted some reworkings of book covers last year, but I only came across them today. I'm inspired...

The strange thing is: I'm not sure where he got hold of the image. After we posed for the picture, DHH and I thought better of it. We thought we had destroyed all the copies...

December 17, 2008

Ruby 1.9 can check your indentation

All Ruby programmers regularly encounter the mystical error “syntax error, unexpected $end, expecting keyword_end.” We know what it means: we left off an end somewhere in the code. As Ruby compiled our source, it keeps track of nesting, and when it reached the end of file ($end), it was expecting to see one more end keyword, and none was there.

So, we trundle back through the source, and after a while discover we'd deleted just one too many lines during that last edit.

Ruby 1.9 makes that easier. For example, here's a source file:

class Example
  def meth1
    if Time.now.hours > 12
      puts "Afternoon"
  end
  def meth2
    # ...
  end
end

Run it through Ruby 1.9, and you'll get the same old error message:

dave[RUBY3/Book 8:26:48*] ruby t.rb  
t.rb:10: syntax error, unexpected $end, expecting keyword_end

But add the -w flag, and things get more interesting.

dave[RUBY3/Book 8:26:51*] ruby -w t.rb
t.rb:5: warning: mismatched indentations at 'end' with 'if' at 3
t.rb:9: warning: mismatched indentations at 'end' with 'def' at 2
t.rb:10: syntax error, unexpected $end, expecting keyword_end

It's the small things in life...

December 10, 2008

Names of encodings built in to Ruby 1.9

Encoding

I've heard of about 10% of these...

What an amazing piece of work.

December 08, 2008

What's on my mind...

December 02, 2008

Forking Ruby—my RubyConf Keynote is now up

There's a sound that no presenter wants to hear, and that's dead silence. And that's what greeted me when I made the suggestion in my RubyConf keynote that the community should fork the Ruby language. I think by the end of the talk, though, most people were convinced.

Am I anti Ruby? no.

Am I suggesting Matz is doing a bad job? Not in the least.

Confreaks_ RubyConf 2008 But I do think the complexity of the current language inhibits experimentation with language features. Want to implement parallel Ruby? If you do it with the current syntax and semantics, you'll be struggling with the integration of global variables, the non-threadsafe nature of require, continuations, and so on, and so on. So before starting these kinds of experimental projects, I'm saying we should fork the language. Produce variants that let us focus in on the aspects under test. Make the new language a rich-enough subset that you can do useful work with it. Then let people play with it. Maybe the ideas are stellar, in which case we can all talk about integrating the changes back into the mainline language. And maybe the idea didn't pan out, in which case we can quietly forget it, and we've done no damage to the language itself.

A mutation is an altered fork of the original. And mutations are essential to the diversity and strength of a genetic line over time. Let's not be afraid to create Ruby mutants and let them compete.

The keynote is available from Confreaks.

November 30, 2008

See Rails request paths in 'top'

During our sale, we had one particular request that came in and wedged the application: every time it hit, the mongrel process size zoomed steadily up to 500Mb, so we had to kill it. But finding out which request was doing this was tricky. The log files didn't help—with the amount of traffic we were getting, it was a small needle and a large haystack.

Eventually, we found the culprit. But it would have been a lot easier if I'd thought of this hack on Friday, and not after the sale ended.

If you put this into your application controller:

before_filter :set_process_name_from_request
def set_process_name_from_request
  $0 = request.path[0,16] 
end   

after_filter :unset_process_name_from_request
def unset_process_name_from_request
  $0 = request.path[0,15] + "*"
end  

then Ruby will set the cmd field in your process control block to the first 16 characters of the request path. You can then use top to see what request is being handled by each mongrel.

Pragmatic@ey00-s00220_~ — ssh — 155×40


Once the request has been handled, an asterisk sign is appended, so you can see the last URL when a mongrel becomes idle. 

Pragmatic@ey00-s00220_~ — ssh — 155×40-1

If your version of top doesn't show the short command by default, use the c keyboard command to see it.

This is probably common knowledge, but I thought it was cool.

November 26, 2008

Just in case you missed it...

Turkey We're having a sale on Friday...

October 28, 2008

Ruby 1.9.1 Preview 1 is out

The path to a stable Ruby 1.9 has been long. Almost a year ago, 1.9.0 was released. This turned out to have been less than stable. The core library has grown by many hundreds of methods since then. And, probably more significantly, people have started using 1.9 for real, and they've discovered rough edges that needed to be fixed. In particular, the multinationalization support, which is incredibly ambitious, turned out to be hard to use for library writers. James Edward Gray II was probably the first to bump into this as he updated his FasterCSV library (now part of core Ruby) to handle any encoding supported by Ruby. His problems lead to a lot of discussion, and eventually to an entirely new concept inside the interpreter. And as a result, the core team have decided to slip the release of 1.9.1 by at least a month while they investigate other encoding-related issues lurking in the libraries.


In the meantime, a 1.9.1 preview has been released. Details are here.

If you are the maintainer for any publicly available Ruby code (be it a Gem, an application, or whatever) I strongly urge you to download this preview. You'll be doing the community a great service in two ways. First, the various incompatibilities between 1.9 and 1.8 mean that there's a chance that your code may not work without some tweaks. Making those changes now will help others using your code. As importantly, by using 1.9.1 for real, with real code, you'll potentially discover other rough edges. Reporting these back through ruby-core or RedMine will help the Ruby developers further hone the interpreter.

Now, all this delay leaves me with a problem. The new 1.9-specific PickAxe is now content complete. Some people have been waiting for it for 10 months. And I have to decide: should I hold on for the official 1.9.1 release (which will be, at the earliest, at the end of January 2009) or should I send it to the printers? Let me know what you think.

Now in Beta

  • Programming Ruby, 3rd Edition
    Third Edition, Covering Ruby 1.9, now in beta
My Photo

Pragmatic Stuff

Photos

  • www.flickr.com
    This is a Flickr badge showing public photos from pragdave tagged with pragdave_badge. Make your own badge here.

Site Search

  • Google Search

    The web
    PragDave