Categories
Uncategorized

subatom 0.11

Yet another new version, subatom 0.11 again prompted by Hans F. Nordhaug. The only change this time is to add a feed_title option to the config file, so you can specify the title for the feed as a whole.

Now, I’m going to sit down and attempt to rework all this as a module+script, along with some tests. That I managed to break things in the 0.09 release was very irritating, and the tests should have caught that.

Update: Please grab subatom 0.12 instead when it shows up if you want a working version. Doh.

Categories
Uncategorized

subatom 0.10

I’ve made another release of subatom. This contains a number of fixes for bugs that I managed to put into the 0.09 release (as well as a couple of minor features). This has really left me with a very nagging need for some tests for this module.

  • Restore the ability to send output to stdout.
  • Make the command line mode work, as well as the config file.
  • Don’t cover up stderr when executing “svn log”.
  • Force subversion to give us back UTF-8, and cope with it.
  • Add support for using—limit if your svn has it.

That item about UTF-8 has annoyed me, because it’s brought me into contact with a hated topic: locales.

Subversion internally works with UTF-8 everywhere. This is a sensible design. But in order to interface with the outside world, it needs to convert that into whatever character encoding you are using. How does it know what character encoding to use? It guesses from the locale.

The locale is meant to be a specification for how to sort characters, how to format the date and so on and so forth. In recent years, it’s also been taken over to specify the character encoding that’s in use. So, to specify that I want to see the world in UTF-8, I need to say:

  export LC_ALL=en_GB.UTF-8

Except that breaks ls(1). Yes, ls(1). For some insane reason, setting a locale changes the way that things work such sorting now happens in a case-independent manner. So that “README” files no longer appear at the top of a directory listing. I haven’t investigated any further to see what else is broken. I quickly switched back to the “C” locale, which effectively means no locale.

So now, I’m left wondering how to tell the system that I’d like UTF-8, but none of the other inconveniences that locales bring me.

Categories
Uncategorized

Skype Is Watching You

I wandered into the preferences for Skype 2.0β today and noticed this little delight.

Skype Chat Preferences with a quote from “1984” as sample text

Presumably this is a warning about the security of communicating over the Internet?

I will however note that the video does work quite well in this version, even though it can’t be held responsible for what you might see at the other end.

Categories
Uncategorized

subatom 0.09

I’ve released a new version of my tool subatom. If you haven’t seen it, it produces atom feeds for subversion commit messages. It’s pretty handy for monitoring activity in a subversion repository and it doesn’t need access to the server.

There are only two new features in this release:

  • Add in a option to specify link[@rel="self"], which means that the generated feeds can now pass the feedvalidator with flying colours. Many thanks to Hans F. Nordhaug for the patch.
  • I’ve added in a config file. I broke down and did it because I’d ended up with scripts that just called subatom in a variety of ungainly ways. Using a config file makes things slightly more manageable.

However, as with all releases, there are already a couple of problems:

  • Hans found that it doesn’t really cope with character encodings properly. This is particularly shameful for me. So I’ll take a peek at it tonight to ensure that we tell subversion to give us UTF-8 and process that accordingly.
  • Another point brought up by Hans is that it should invoke svn log as svn log --limit. I’d been avoiding that because I’m still on an older version of svn at work, but there’s no reason to not run svn help log and check the output to see if --limit is available.
Categories
Uncategorized

gdb ruby $pid

gdb is my “tool of last resort”. When all other online diagnostics have failed, I know enough gdb to pull out a C level stack trace.

  % gdb $SHELL $$
  GNU gdb 6.3.50-20050815 (Apple version gdb-477) (Sun Apr 30 20:06:22 GMT 2006)
  /Users/dom/320: No such file or directory.
  Attaching to program: `/bin/zsh', process 320.
  Reading symbols for shared libraries ........ done
  0x90006108 in syscall ()
  (gdb) where
  #0  0x90006108 in syscall ()
  #1  0x00054558 in signal_suspend ()
  #2  0x0002c9a8 in waitforpid ()
  #3  0x0002cb4c in waitjobs ()
  #4  0x00012584 in execlist ()
  #5  0x00011c24 in execlist ()
  #6  0x00011874 in execode ()
  #7  0x00026890 in loop ()
  #8  0x0002945c in zsh_main ()
  #9  0x00001d14 in start ()

It’s not terribly informative, but in the past, it’s given me just enough of a clue to start looking at the SSL libraries (for example).

Jamis Buck has gone one better—he’s pulled a ruby stacktrace from a running process. Which seems quite magical to me indeed. I also think that you can turn most of what he’s done into a gdb macro. I’ll have to have a look at some examples

In the past, I’ve resorted installing a signal handler “just in case” to pull out this sort of information. All of my Perl apps have this in their startup files.

  $SIG{ USR2 } = sub { Carp::cluck("Caught SIGUSR2 in $$") };

Which is all very well, if you know what you need in advance. Which is not usually the case.

Jamis++

Update: Ok, turning it into a gdb macro is dead easy. Save this lot into ~/ruby.gdb

  # A quick hack to show the environment for a Ruby process.

  define printenv
    set $index = 0
    while environ[$index]
      x/1s environ[$index]
      set $index = $index + 1
    end
  end

  document printenv
    Display the environment for the current process.
  end

  define rb_where
    set $ary = (int)backtrace(-1)
    set $count = *($ary+8)
    set $index = 0
    while $index < $count
      x/1s *((int)rb_ary_entry($ary, $index)+12)
      set $index = $index + 1
    end
  end

  document rb_where
    Show the ruby stacktrace.
  end

To use it do source ~/ruby.gdb from the gdb session, and then you get two new commands: printenv and rb_where.

Oh yes, I do know how super-trivial all this would be if only I had DTrace. Roll on Leopard.

Categories
Uncategorized

dTrace & JavaScript

dTrace is one of those really, really cool technologies I wish I’d had back when I was a wookie^Wsysadmin. It lets you monitor and profile your system in ways which just weren’t possible before. It’s Solaris only at present, but it’s being ported to FreeBSD and Mac OS X.

But the cool thing is watching people apply it to their favorite languages. Hence, DTrace meets JavaScript. Find out where the time is really being spent in your page…

Categories
Uncategorized

Unicode in Rails

I’m really happy to see that Thijs has just pointed out that the unicode_hacks plugin is undergoing further development:

We’re almost ready with a new version of Julik’s ‘Unicode Hacks’ that’s now called ‘ActiveSupport::Multibyte’. You can find more information and code on the ‘Multibyte for Rails’ project site.

I’m particularly pleased to see that: “We hope to get ActiveSupport::Multibyte accepted as a new core extension in the 1.2 release of Ruby on Rails”. That would be a real boon. Check out the FAQ too.

Categories
Uncategorized

RailsConf Day 2

Urgh, I’ve spent most of the weekend recovering from a cold and lack of sleep, so I’m finally at a point where I can write up the final day of the conference. In the meantime, I noticed that DHH has a great railsconf writeup, which covers many of the things I saw.

In the morning, Jim Weirich kicked off with a talk about how to write good libraries in Ruby. He pointed out that there a lot of really bad libraries out there that do hideous things and have weird side effects. Monkey-patching is OK, in an application, but in a library, you really have to keep control of yourself (“sufficiently encapsulated magic” as I once heard schwern call it). He presented some good advice, but most of it was really kind of obvious if you’ve worked in any dynamic languages before. I did get the impression that there were a lot of Java converts in the audience, for whom this might not have been so obvious.

As a side note, Tom showed me how to use Quartz Composer in the end of that talk. That’s a heck of a cool toy. I must play more.

Next up was why the lucky stiff. It was nearly James Duncan Davidson, as _why was a little conspicuous by his absence. But he showed up on time, and went on to talk about a number of things. Watching a talk by by _why is more like being at the theatre than a lecture. It’s hugely entertaining. If I said that he talked about how to use the * operator (splat), and his lovely sandbox library, it might sound dry. This would be to ignore the contributions of the Dragons, Foxes, Owls and huge cast of characters that assisted him on his journey.

After this, the main talks started. I went to see Rany Keddo talk about “How I turned my Bank job into a rails playground”. His answer: lie, steal, cheat. It seemed to have worked well for him though. The best bit had to be his picture of Gollum labelled as “DBA”. 🙂

After lunch, I went into Sean O’Halpin’s talk, “RoR against the Machine”. But I’ll admit that I wasn’t paying much attention; I was too busy working on my own talk. Which is a shame, as it sounded really interesting. The notion of having Virtual Machines as “MS Office Servers” sounded like a really cool hack.

I did manage to catch the very end of Hampton Catlin on “HAML: Naughty Boys Need Structure”. HAML is an alternative approach to writing pages which aims to sit between the extremes of XML::Builder, which is just code and erb which is interpolated markup. I’m not sure I agree with it, but it’s an interesting experiment.

After my talk, we all filtered into the main hall to hear James Duncan Davidson. His talk was entitled “The Web is a Pipe”. He was talking about how using HTTP as a substrate for integrating web applications is the way to go. Having used FastCGI, I really, really agree with him. Doubtless there are some times when you’ll hit performance issues, but it’s certainly a very sensible default.

The final talk was given by Dave Thomas. This was the most unexpected talk of the conference, and it completely blew me away. He started out talking about terrorism, apropos of the 5 year anniversary of 9/11. This seemed to shock most of the audience (although he didn’t say anything revolutionary—much of it was very reminiscent of Bruce Schneier). But he veered around to talking about risk. And from there to talking about Rails and FUD. And how to deal with it. He dissected several of the common tactics that are used to diss Rails. But, he emphasised, he’s not saying Rails mustn’t be criticised. Just that he wants valid criticism, not straw men. This was one of the best talks of the conference for me.

After the conference, we gradually filtered out towards a rather lovely curry in Soho…

Categories
Uncategorized

RailsConf Day 1

What I done saw…

Unsurprisngly, after a brief introduction by David Black, DHH kicked off the conference with a keynote speech. Except that having no copy of Keynote on his laptop, he used TextMate instead. Hardcore! He went on to show off the RESTful ideas in Rails 1.2 (due out Real Soon Now™). I’ve done quite a bit of REST stuff at work, and the rails stuff completely kicks the butt of everything I’ve done. It has simple written all over it. But it’s not just the server! They’ve implemented ActiveResource, which is an ORM for REST based web services. So you get client and server! He also discussed the next project, SimplyHelpful which is aiming to clean up the views a bit. Looks really neat, but not scheduled until Rails 2.0. But it’s a plugin if you want it. Lovely.

P.S. deprecation warnings will appear in 1.2 as well. Pay attention; those things are gone in 2.0.

Afterwards, Kathy Sierra talked about passionate users. I have to admit to finding this one a little bit hard to follow. That’s because I do so little design I guess…

I wanted to see Dann Webb talk about the Unobtrusive JavaScript Plugin. Unfortunately, it “sold out” and I couldn’t get in. Instead, I elected to see Dave Goodlad talking about Rails speaks C. This was actually a really nice talk. A single topic well covered. He talked about how to write C extensions in Ruby, and then covered the use of BackgrounDRb for long running processes. Really useful.

Lunch was served in the conference venue itself, which I found a little odd. On the other hand, it was a great way to mingle with all the other delegates. But you inevitably get drawn to people you know… I quickly found Tom and Simon. Given that between us we are PHP, Python, Perl and JavaScript coders more than Ruby, it gave an interesting slant on the talks!

Post lunch, I listened to Jamis Buck talk about all the shiny new toys in Capistrano 1.2 (the shell is the big one, but parallel execution looks real handy too). He finished his talk early and then asked the question “Who doesn’t know what capistrano is?” I ducked out at that point to go and buy a copy of Building Scalable Web Sites from Josette on the O’Reilly stand. Simon mentioned it had a great chapter on Unicode, so I cribbed a few bits I’d missed for my talk. 🙂

For the next slot, I watched Alex Payne talking about “Securing Rails—a whole stack approach”. He covered a huge amount of ground in a fairly short time. From the obvious things like SQL Injection, XSS, CSRF all the way down to databases and firewalls. He gave out loads of tips, which I still need to sit down and digest. #1: Use h() everywhere!

I was really curious to see Simon talking about Django and what Rails can learn from it. I have to say, Django looks hugely impressive. It’s clear that they’ve taken a very different approach to Rails in many ways yet still come out with something similar. Personally, I loved the way in which Django uses very richly specified domain models in the Python classes in order to build up an “instant” admin interface. Really cute stuff.

I’d talked to Till Vollmer beforehand about his talk on Localization. It turned out we had quite a few slides in common. However, the rest of slides gave a good overview of the seemingly myriad array of plugins available for i18n and L10n for Rails.

After the sessions, there were “Drinks and Canapés” served. The drinks were good, the canapés slightly miserly, so I headed off to a noodle bar with a few guys before the evening session. I’m not sure how great the idea of the evening session is. I was alright because of the food, but some people must have been getting really hungry. 🙂

Anyway, with 6 members of the Rails core team assembled, David Black fired off questions submitted by the audience. There were quite a few insightful ones in there, but I liked:

Q: When should you not use Rails?

DHH: Lots of projects come with an “Enterprise” label and are doomed to fail, regardless of technology. Please don’t let Rails be associated with them. 🙂

Post-Q&A, DHH got to give the last part of his talk from the morning, which he hadn’t given because of time constraints. This was basically an extended rant about Vendoritis. He used the recent security incident as an X-ray to analyze the rails community and found it suffering from Vendoritis (entitlement & indignation). He concluded that we have to help make the community a better place in order to try and solve things. Get involved. Make it personal. It’s everybody’s job to keep the rails community healthy.

However, the funniest bit was his translation of the MIT license: “I don’t owe you shit”. (in response to some of the whingers)

Thanks to my ineptitude at advance planning, I had no hotel room, so I had to head back to the train pretty sharpish after that…

Categories
Uncategorized

Unicode for Rails

I finally gave my talk this afternoon. I rushed through things in 40 minutes; I was planning on 45, but I started a little late due to microphone difficulties.

The talk seemed to go down well; a few people came up to ask questions afterwards. My official hecklers, Tom and Paul were noticeably silent. They didn’t try to pedant-me-to-death afterwards, which is good. Although it probably means I had too much detail in there for mere mortals!

I’d also like to give a huge bouqet of thanks to the hyper-lovely _why for his fabulously encouraging words along the way.

Anyway, please take a look at the slides for Unicode for Rails if you fancy. One thing I added at the last minute and didn’t get a chance to show on screen was the links slide. In particular, I recommend checking out Julik’s Unicode Slides.

I practised by giving the talk to a collection of fluffy toys that we have around the house. We now have the most well-unicode-educated giraffes in existence, I suspect. 🙂

On a slightly less fun note, I’ve just read Tony Finch’s summary of UTF-8 in email, which is far, far hairier than in HTTP (which has most of the complications built in at least). Worth checking out if you do much email.