OpenSSL::SSL::SSLError (hostname was not match with the server certificate)

I got this error in one of my Rails apps that I migrated to 2.2. It occurs when you try and send mail with ActionMailer, which makes it especially annoying because the exception notifications I normally receive when there is a problem weren’t being sent!

I wasn’t able to track down the root cause of the problem – apparently something about an SSL certificate not being there or not being right, but here’s the change that causes ActionMailer to fool around with SSL mail:

http://github.com/rails/rails/commit/732c724df61bc8b780dc42817625b25a321908e4

I was able to “correct” the problem (or at least get things working again) by commenting out this line of code:

smtp.enable_starttls_auto if smtp.respond_to?(:enable_starttls_auto)

Perhaps it should be a configuration option, or there should be better error detection with regards to the certificate. If anyone comes up with a nicer answer, leave a comment, but in the meantime, I thought I’d post my quick and dirty fix.

Update

I fixed the problem by running this as root:

make-ssl-cert generate-default-snakeoil --force-overwrite

Which regenerates the SSL certificates.

Python “Surpasses” Perl?

There has been some buzz going around about Python “surpassing” Perl in terms of “popularity”:

http://mail.python.org/pipermail/python-list/2008-November/517191.html

However, they’re basing their results on the TIOBE survey, which is, in my opinion, even dodgier than my own, at http://www.langpop.com . It’s really difficult to pin this sort of thing down, but I think that by utilizing more data sources, my own numbers bear some relationship to what my “ear to the ground” tells me about what’s going on, and certainly more than TIOBE’s, which place D, Logo and Lua above things like Tcl/Tk. I know Tcl is not the hottest thing out there these days, but…Logo? D is gaining in popularity, but how many companies are hiring D programmers, how much code is out there written in D? I’m not saying that D is “bad” or “not worthy” because of that – quite the contrary, I think it’s on its way up, but there are a lot of things you have to look at in order to take a stab at creating some meaningful numbers, and even then it’s important to remember that popularity isn’t everything! In any case, picking a precise moment in time when one language “passes” another is also a bit more theater than science, in my opinion.

Getting back to Perl and Python, I thought I’d look at some numbers of my own. Unfortunately they only go back a year, but they already give us an idea of what’s going on. In order to concentrate on something fairly concrete, let’s look at Freshmeat projects:

Perl is still clearly more widely used. However, I think there’s an important distinction to be made in terms of popularity. Since many systems that function ok stay around for years, there’s a big difference between what’s being used for new systems, and what’s out there already. Perl has a lot of code out there already, but how fast is it growing in comparison to Python?

Python’s definitely got the edge – it’s growing, whereas Perl was very nearly static. To me that does indicate that Python has got momentum right now, where Perl is sort of coasting.

Business Book Breakdown

Joe Wikert swears off business books:

http://jwikert.typepad.com/the_average_joe/2008/11/business-book-breakdown.html

and in the process, he highlights one of the reasons for Squeezed Books to exist: most business books are pretty high on the fluff/content ratio. Even a lot of the good ones which present a noteworthy idea need to pad out those ideas to make a book out of them, as the basic idea can usually be described in a few pages.

The part of Squeezed Books that I really hope to get going is the discussion of books, because I think that can add a lot of value for people. Reading a book is part of learning, but you often internalize and consider things more deeply when you actually discuss the ideas in the book, subjecting them to critical examination, and applying them to situations you have experienced.

Incidentally, I also rejigged the site’s look and feel, using the blueprint CSS ‘framework’. I’m not much of a designer, so I have to aim for simple and not unpleasant, rather than beautiful and flashy.

The Economics of Programming Languages – in the 1950’s

I was having a look at this paper on the development of Fortran:

http://www.softwarepreservation.org/projects/FORTRAN/paper/p165-backus.pdf (which I found here )

And I noticed the following quote:

1.2. The Economics of Programming

Another factor which influenced the development of FORTRAN was the economics of programming in 1954. The cost of programmers associated with a computer center was usually at least as great as the cost of the computer itself. (This fact follows from the aver- age salary-plus-overhead and number of programmers at each center and from the computer rental figures.) In addition, from one-quarter to one-half of the computer’s time was spent in debugging. Thus programming and debugging accounted for as much as three-quarters of the cost of operating a computer; and obviously, as computers got cheaper, this situation would get worse.

This economic factor was one of the prime motivations which led me to propose the FORTRAN project in a letter to my boss, Cuthbert Hurd, in late 1953 (the exact date is not known but other facts suggest December 1953 as a likely date). I believe that the economic need for a system like FORTRAN was one reason why IBM and my successive bosses, Hurd, Charles DeCarlo, and John McPherson, provided for our constantly expanding needs over the next five years without ever asking us to project or justify those needs in a formal budget.

As Hal Varian says, “Ignore basic economic principles at your own risk. Technology changes. Economic laws do not.”

I would continue to bet on programming languages that save programmers time, or otherwise make them more productive.

Won’t fix… why?

I discovered a minor Rails annoyance today, and, looking around for an answer to the problem, I found this, which is a perfect description of the issue, and includes a fix:

http://dev.rubyonrails.org/ticket/5123

Unfortunately it has marked as “wont fix” with no reason specified.

Perhaps there is a reasonable answer that was perhaps discussed elsewhere, and just didn’t make it into the bug report, making it invisible to people like me who find it via Google, which is pretty annoying. The other explanation is more along the lines of “don’t wanna” (or fuck you, as the case may be), but at least come out and say so. “We’re not going to do it, as it’s not part of our English-centric vision” or what have you. Being a native English speaker, even when doing stuff for Italian or Austrian or whatever clients, I tend to code in English, because it’s 1) fast, 2) easy and 3) it’s pretty much universally understood by programmers. However, I can see the case for specific things to be in a particular language, and on the surface, this one line patch makes that a little bit easier, and doesn’t appear to be costly, so why not?

Just closing the bugs of people who have taken the time to try and help (this is clearly not just a “dude, it’s, uh, broke” bug) is the twin of the equally annoying people who don’t bother to take 30 seconds to send an email or bug report about software they’re using, and both are things I greatly dislike.

Slicehost vs Linode

Update: since I did these statistics, Linode has upgraded their memory offering even more, which means that their offer is even better than what I show here.  As of summer 2010, Slicehost's offering really isn't very competitive, unfortunately.  I continue to hear that they do provide great service, but so does Linode.

Since hosting is *the* major expense for http://www.dedasys.com, and obviously a critical part of much of what I do, getting the right one is very important. Naturally, "the right one" for me may not be the right one for everyone. I am a fair sysadmin for small numbers of machines, so I don't mind doing that myself – I don't need, nor want to pay for hand holding.

Since this post has become fairly popular, I am going to link to my Linode affiliate URL if you'd like to sign up with Linode – thanks! Other than running my sites there, I have no other affiliation with Linode. And, if you're more a fan of Slicehost, here is my referral page on Slicehost.

I recently moved everything over to [Slicehost](http://www.slicehost.com) on the recommendations of friends, and am so far fairly happy with the experience. It's cheaper, simpler, and more flexible than Layered Tech was. To boot, I also like the fact that Slicehost is run out of St. Louis, Missouri, rather than some really expensive tech center like San Francisco or Boston. Hosting is basically a commodity, and much like you wouldn't want to put a factory in San Francisco, you don't want your hosting their either. However, I discovered something annoying about Slicehost: they use x86_64 servers, which, per se, doesn't really matter to me – I use open source code that can run on any number of architectures. The problem is that this particular architecture uses more memory than plain old x86. Significantly more. My Layered Tech server with 1 gig of memory was hitting the swap space a bit, but the same code on a slice was swapping quite heavily, despite the fact that I'd moved PostgreSQL off to its own slice. Since I pretty much exclusively run Rails, I decided to look into Phusion's "Ruby Enterprise Edition", which is basically just some nice hacking on Ruby's garbage collection mechanism. What they've done is nice, and I may end up using it, but ultimately it's buying me space that I would also gain from simply moving back to x86. With that in mind, I decided to take another look at what appears to be emerging as one of Slicehost's main competitors, [Linode](http://www.linode.net), who *do* use x86 servers. Here are my results, which are admittedly not all that scientific, but what the heck – you're getting them for free, and they were pretty quick to whip up. ### Service, Support, Setup But before we begin with the numbers, I want to add a few words of caution. One of the big things about hosting, to me at least, is how they deal with unexpected random negative events. Connections going down, disk breakage, DoS attacks, and so on. It's really hard to get an idea of just what sort of people you're dealing with until you've "ridden the river together". I don't really know what sort of response times, uptime, and all that either Slicehost or Linode have, so there are potentially some big intangibles there that are not quite as easy to draw pretty charts for. In terms of the console/setup/management tools, I liked Slicehost's simplicity more – Linode gives you more options, but they're a bit fiddly and cluttered feeling at times. For instance, Linode lets you pick how much swap space to give your disk image, but doesn't include a bit of javascript to balance out the swap and regular partitions, so that if you type in a larger swap number, you have to do the math and subtract that from the other number. Annoying, but not a big deal. Linode lets you pick various data centers in the US (no Europe, yet). Slicehost gives you the option to do backups of your disk images, which is nice, and something that Linode lacks. ### Comparing plans Since I'm interested in comparing hardware and machines I actually have access to, here are the plans I am currently signed up with, and the salient numbers:

  Slicehost 1024 Slicehost 512 Linode 720
Memory 1024 512 720
Bandwidth 400 200 400
Disk 40 20 24
Cost 70 38 39.95

Memory / Dollar: Bandwidth / Dollar: Disk / Dollar: Linode mostly comes out ahead, but not by that much, except for bandwidth. However, let's take a crude look at x86_64 vs x86 memory usage. First, `./script/console` (a Rails console) for the same code base on two different machines, showing the virtual memory size (VSZ) and resident set size (RSS): And just to look at something else that's a bit smaller, I ran the following script: puts File.open("/proc/self/status", "r").read And got the following data: Being charitable with those numbers, we get x86 taking up 77% the memory that x86_64 does. So let's add that to our comparison of how much memory you're getting per dollar on Slicehost and Linode: Wow! That's a fairly significant difference. ### Performance That's most of what we can glean from published numbers, and running a few simple experiments. However, there's another factor that's important: performance. "Virtual Private Server" systems, or simply VPS's, got a bad name in the past because they were "overbooked" – too many virtual servers competing for the same CPU resources on one machine. Slicehost and Linode both look like they want to avoid that kind of bad reputation, and so far all the systems I have used have felt snappy and responsive. Now here's where we get really unscientific… I decided to try and do *something*, even if it wasn't much, to get some kind of objective measurement of what kind of CPU I was getting on the machines. This is really unscientific, because the machines do have other duties (I don't have the cash, time or inclination to set up random servers just for testing), and of course, who knows what else is sharing the computer with my systems: if you get a relatively unused computer, you can apparently pick up extra cycles for yourself, over and above your guaranteed minimum. But c'est la vie, and so I decided to do some numbers anyway. I picked a C implementation of mandelbrot from the [language shootout](http://shootout.alioth.debian.org/u32q/benchmark.php?test=mandelbrot) more or less "for the hell of it" (I'm going to keep repeating "unscientific" and invite someone to do better tests than I have). I ran this code every 20 minutes for a couple days, and then averaged out the run times: As expected, the higher power Slicehost 1024 machine wins out in terms of raw speed (less time is better), but not by that much over the Linode system. Indeed, when we factor in the relative prices, Linode comes out ahead, again: So it looks like we're not paying a CPU penalty for having more memory, bandwidth, disk, etc… ### Notes * Nothing in these statistics is indicative of future directions that both Linode and Slicehost might take. Slicehost was recently acquired by Rackspace, and that could have effects on the service they provide. Maybe one or both will come under financial pressure and start "overbooking" their servers. * The spreadsheet I used is available via Google docs, for the curious. I did most of the work in OpenOffice, and then uploaded it though, because working with the web spreadsheet was kind of painful. Unfortunately, you can't select non-contiguous data ranges in the Google spreadsheet, so the labels are interspersed with the data. Yuck. Also, Google docs doesn't handle 'time' values nicely, which is what the performance data was originally. The spreadsheet is here: * The standard deviation on the processing times is higher for both slices than the linode system. Not quite sure what that means in terms of what's going on under the hood, but I thought it was interesting.

Ticker Widgets on Your Mobile Phone?

I’m doing a bit of research for a microemulator feature request I filed. link

In short, the question is: on your cell phone’s Java ME implementation, does the ticker scroll across the top get reset and start again from the side, or does the text get updated without the ticker restarting from the side, as in this example:

http://www.heclbuilder.com/scripts/show/155

On my Nokia 6121, it starts the text over each time it gets updated, which isn’t how I wanted it to work. The debate regarding microemulator is how it ought to behave – update the text, or restart from the right, like the Sun emulator and my Nokia phone. To that end, we’re looking for you to let us know what your phone does. Thanks!

Ruby YAML Bug & Fix

Besides the nasty Ubuntu bug, which I was unable to do anything meaningful with, yesterday I also found a small bug in Ruby’s YAML package:

irb(main):004:0> YAML::load('1900-01-01T00:00:00+00:00')
ArgumentError: time out of range

The problem is that the YAML implementation that Ruby is using, called “syck” interprets that kind of date as something that it should make a Time for:

        else if ( strcmp( type_id, "timestamp#iso8601" ) == 0 )
        {
            obj = rb_syck_mktime( n->data.str->ptr, n->data.str->len );

So I did a little bit of hacking on the C code, and made it create a DateTime object instead. My fix works, although I’m not sure it’s the best possible way of tackling the problem. The patch is attached to the bug report here:

http://redmine.ruby-lang.org/issues/show/752

This matters because my Rails text fixtures had some dates in them that were quite old, and this was causing problems.

Ubuntu Intrepid Regression: Beware of Wireless and WPA

A lot of people, myself included as of the upgrade I did last night, seem to be having trouble using certain wireless chipsets with WPA:

https://bugs.edge.launchpad.net/ubuntu/intrepid/+source/wpasupplicant/+bug/272185

There are a lot of people following this one, and you have to think that for every person who looked it up, googled it, and dug around to find that page, registered with the site, and so on, there are several more who simply gave up and went back to Windows or something.

I thought a couple of weeks was probably a good amount of time for the bugs to be shaken out of Intrepid, but I thought wrong.

Here is a set of search terms that can be used to look through “regression-potential” bugs, which if I’m not mistaken, ought to mean those things that worked in previous versions of Ubuntu but now no longer work. In my case, there’s an extra little bit of annoyance because I am running on a Dell laptop that I bought with Ubuntu preinstalled, and you’d think the Ubuntu guys would have a few sitting around to do some testing with prior to release.

I spent some time digging around in the code for the network manager, wpasupplicant, and a brief look at the kernel code, but there was nothing that made much sense, so I guess I’ll just have to wait for the fix like everyone else… wish I could help, somehow, though.

Another “Mysql Doesn’t Do that?!” Moment

http://adam.blog.heroku.com/past/2008/9/3/ddl_transactions/

I think the real reason there was resistance to this change is that MySQL doesn’t support DDL transactions; and wrapping migrations in a transaction is mostly pointless without this feature. Since MySQL doesn’t support it, most Rubyists don’t know what DDL transactions are – so here’s a quick primer on this incredibly useful and certainly underrated feature.

DDL = data definition language, also known as the schema. DDL commands include CREATE TABLE, DROP TABLE, ALTER TABLE, and CREATE INDEX. DDL transaction support means that the following sequence of SQL commands will not modify your database

I never even thought of that. I was fairly confident in my vision of Postgres getting faster and faster, and Mysql become a “real” database… that the two systems were converging on something resembling a common speed/feature set. But things like this still occasionally rear their ugly heads and I’m happy to be a Postgres user.