You are currently looking at an older section of the wincent.com website.
Please check the new version of the site at https://wincent.com/ for updated content.

spacer spacer spacer
spacer spacer spacer spacer

Mini-log

"I shall call it, Mini-log..." (about)

6 Feb 2008

  • SuperDuper! 2.5! Released!

    A most welcome update that brings Leopard compatibility at last. I make simple tar-based backups of my home directory every two hours via a cron job, but I've been without whole-disk backups for a while now because SuperDuper! has been out of action. It's good to have it back!

4 Feb 2008

  • backtrace(3)

    Cool new API for Leopard that I just found out about.

12 Jan 2008

  • Ragel 6.0

    A new release of the totally awesome state machine compiler. When you need to parse regular languages fast, remember Ragel.

11 Jan 2008

  • New Mac Pros out

    Only just found out about this... have been very busy with work of late and so haven't really been keeping up to date with the news. While I would certainly love one of these machines, I'll probably be sticking with the trusty old first-gen Intel iMac for a while yet.

3 Jan 2008

  • RR

    A new and very interesting "test double" (mock, stub, proxy) framework called RR. I really like the terse syntax in the examples.

  • WordPress 2.3.2

    "WordPress 2.3.2 is an urgent security release"... Familiar-sounding words for anybody who's been tracking the releases of everybody's favorite PHP weblogging engine.

23 Dec 2007

  • Subversion 1.4.6

    Is out (full changelog). I doubt I'll bother upgrading though from the default 1.4.4 installation that comes with Leopard, seeing as I use Git for everything now.

20 Dec 2007

  • Crazy advice

    Just crazy.

18 Dec 2007

  • ssh-agent in Leopard

    Good coverage of the changes.

14 Dec 2007

  • Ruby 1.9/2.0 manifold faster...

    ...than it's closest competitor (JRuby), which isn't surprising, seeing as JRuby is built on Java (not exactly known for its blistering speed).

7 Dec 2007

  • Rails 2.0.1

    Already, but no release notes and no mention on the official weblog.

  • Rails 2.0

    Apparently out, although there's been no announcement on the official weblog yet.

30 Nov 2007

  • Nested examples in RSpec

    Very surprised to see this (there always seemed to be a bit of resistance to the idea from the core devs), but very happy too as it will make for some much more readable specs.

29 Nov 2007

  • Rails 2.0RC2

    Almost there...

28 Nov 2007

  • Game of life

    He's on a roll (see also Wikipedia on the Game of life).

Mini-log archives...


Git log

what's this?...

14 Mar 2008

  • Speed up full-text indexing by doing a multi-row insert (wincent.com, 0d3e312)

    This gets indexing up to an acceptable speed (a 10,000 word, 90,000 byte test article took less than a second to save in development mode, so production mode should be fast enough) so we can turn it back on again.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Fix the n+1 select problem in the tags implementation (wincent.com, 513d102)

    When showing all items marked with a single tag (ie. the "show" action of the tags controller) or all items matching multiple tags (ie. the "search" action) we unfortunately had an n+1 SELECT problem because we had to inspect each Taggable instance to see if the user had access permissions to it.

    Now we reduce the number of queries by grabbing all Taggables for a given taggable type in one hit. In other words, given 3 matching Articles and 10 matching Posts, we now do 2 queries during access checking rather than 13; and when we display the Taggables in the view there are no additional queries because the Taggables have already been fetched.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

5 Mar 2008

  • Add product creation with icon uploading (wincent.com, b970662)

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Add extension and description to products model (migration) (wincent.com, 4eb5a36)

    We don't need to store the full path to the icon file but we do need to store the icon file extension; with this we can reconstruct the full path on demand.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Update products link in navbar (wincent.com, 76cf73f)

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Add products listing to index, links are permalinks (wincent.com, 63db015)

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Fix products routing (wincent.com, b906a09)

    I'd mistakenly used "map.resource" instead of "map.resources" which meant that things like "product_path" didn't work.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Assign found products for view (wincent.com, 98ab4ca)

    This is a spec, the corresponding change was already made to the controller itself.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Teach products controller to find all products (wincent.com, b794161)

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Add "index" action to products controller (wincent.com, 96c7e77)

    And accompanying specs.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Add basic products controller specs (wincent.com, 4b2b9cb)

    These are the shared application controller specs which all controllers should pass.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Validate uniqueness of product permalinks (wincent.com, a33cdbc)

    This is the validation and the corresponding spec.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Require permalink on products model (wincent.com, 6c0c3b7)

    Add the validation, corresponding spec, and example data for FixtureReplacement.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Add permalink column to products table (wincent.com, a4263df)

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

4 Mar 2008

  • Add products controller and make it the default (root) route (wincent.com, e1580bd)

    Requests for the application root (/) now get routed to this new products controller, and concretely the "index" action.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Add database-level constraint for product name uniqueness (wincent.com, 7805a54)

    The Rails "uniqueness" validation is advisory only and is vulnerable to races, so add a database-level constraint to ensure integrity. (The Rails validation is about UI polish, not integrity.)

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Require product names to be unique (wincent.com, b023972)

    Add validation and corresponding spec.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Require name in products model (wincent.com, e323bf2)

    Add validation and corresponding spec.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Add example data for products model (wincent.com, 4109d10)

    This is the FixtureReplacement data that will be required in order to pass validations.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

  • Make sure product name is not nil (wincent.com, 8ef596d)

    Add a database-level constraint.

    Signed-off-by: Wincent Colaiuta <win@wincent.com>

Git log archives...

Welcome to the personal weblog of Wincent Colaiuta

This is my personal weblog where I write things that aren't always related to my business. If you're looking for information about my products please go to wincent.com, and for official news see here. Shortcut to this weblog: colaiuta.net.


March 25, 2008

Final server migration this week

I've been working on moving to the new server for nearly a month now, a process which has been quite slow because all the data has to be exported from a number of "legacy" applications and imported into a brand new custom Rails application written especially for this site. It's slow going because it's the first time I've ever deployed a Rails application and I've had a lot to learn... but now I know a fair bit about nginx, capistrano, mongrel, monit, and of course Rails itself. The server too is totally different, with a different operating system, so it's all been quite time-consuming.

Well, the crunch time is now coming and the real server move is about to happen this week (at the end of the March the old server will go offline forever, so the move has to happen this week, ready or not). So this will most likely be my last post ever to this weblog.

The forums are already in read-only mode, and I'm about to shut down the bug tracker too shortly so that I can do the final export of all the records and move them into the database on the new server. If you had an account on the old server you'll automatically have one on the new server too, although you will need to reset your password (I couldn't transfer across any passwords because none of them were stored in plain text, and rightly so of course).

At some point during this week email might temporarily go down, hopefully only for about an hour (delivery failures should be temporary), and the wincent.com domain itself will go down at roughly the same time too. When it comes back up we'll be running on the new server. If you make a purchase during that time you might have to wait an hour or two for your license information, but we'll soon be back to immediate automated delivery.

Keep your eye on my Twitter account if you'd like to be kept posted with updates; it will be my only avenue of communication during my brief stint in limbo:

  • twitter.com/wincent

More Miscellaneous articles

Posted by wincent at 1:18 AM

February 26, 2008

Server migration under way

The server migration from Rackspace to INetU is currently underway. My aim is do this very carefully, service by service, and keep downtime to a minimum; hopefully minutes rather than hours.

Just in case there is any interruption during the move, I've just opened a twitter account where I'll be posting updates along the way:

  • twitter.com/wincent

Not really a twitter fan myself — I've always felt that the best place to post that kind of info is on my own weblog — but in a case like this it makes sense to have an offsite feed.

More Miscellaneous articles

Posted by wincent at 11:53 AM

February 19, 2008

Microphone prices

I'm currently looking at getting a better microphone to do screencasts. The one I'm most interested in goes for between $84 and $100 in the US (57€ to 68€). Purchased locally here in Spain the mic goes for upwards of 130€.

Unfortunately, most of the retailers in the US don't want to ship outside of the US. I found one who would: they quoted me over $160 shipping, plus $50 wire transfer fee (they don't accept foreign credit cards) and the cost of the mic on top of that for a grand total of $294. Ridiculous. That's 200€. Needless to say I'll be holding off until I find a better option.

My past experiences ordering computer components from the US have always been excellent, but it seems that things are different in the audio realm.

Update

Found a reasonably priced European supplier.

More Miscellaneous articles

Posted by wincent at 9:51 PM

February 16, 2008

The joy of deleting code

Things have been quiet here of late because I've been feverishly trying to get things ready in order for the server move coming up at the end of this month. It's a big move because it's not just moving the box from one place to another; I'm changing data centers, hosting companies, operating systems, and application software all at once, and there is a lot of work to be done.

One of the things I'll be doing is replacing the teetering stack of disparate applications that I'm currently running (a mix of applications — Movable Type, UBB.threads, Mailman, Bugzilla, MediaWiki and a number of custom scripts — written in a mix of languages — Perl, PHP, Python and Ruby) with a single unified application, a custom job written in Ruby and built on Rails.

I'm taking the opportunity to greatly simplify things in the "Web 2.0" spirit (ugh, how I hate that term; but I've started to use it because it's lost some of its ridiculous hype feel and has now come to mean a set of widely understood characteristics). And it's actually quite a liberating experience. Each chunk of code that I delete makes me feel lighter, freer.

Read full article

More Miscellaneous articles

Posted by wincent at 5:53 PM

February 2, 2008

Ragel wins! Fatality!

One of my projects is a fast wikitext-to-HTML translator. It's a Ruby extension written in C with speed being one of its top design goals (robustness, predictability and security being the others). I'm working on this because the Rails rewrite of this site will use wikitext markup for basically everything. Rails has a bad reputation for being slow and resource hungry, and that's why one of my primary objectives is speed; I don't want my wikitext parser being a bottleneck.

The translator itself consists of a hand-coded parser written in C paired with a scanner/tokenizer/lexer generated from a grammar specification.

Up until now the scanner used a ANTLR-generated lexer using the "C target" (although ANTLR itself is written in Java, it can target multiple languages, including C). The C target is the current speed king among ANTLR targets and is likely to remain so for the foreseeable future. It too is engineered with speed in mind and is quite frugal with resources (for example, when emitting tokens it maintains pointers into the input stream rather than making a copy of the substring for each token).

And the results were quite snappy. But for some time I've had the sneaking suspicion that a Ragel-generated scanner would be faster. I suspected this even though ANTLR uses all sorts of clever tricks like trying to predict which path to take and only backtracking if prediction fails.

You see, Ragel generates simple state machines: the building blocks of regular expressions. Whereas ANTLR is like a complex and unpredictable magic clock, Ragel state machines are totally transparent and predictable. I've spent many months trying to use ANTLR on a number of different projects and in every case except for this wikitext translator I've ended up putting it aside because I couldn't divine the incantations required to make it do its black magic. Ragel, on the other hand, is absurdly simple. You can build complex things out of it, but the base components are easily comprehensible. Compared to ANTLR, Ragel is incredibly easy to learn.

Read full article

More Development articles

Posted by wincent at 6:07 PM

January 31, 2008

Farewell Rackspace

I wrote the other day that I was going to be moving to RHEL 5 in the near future. What I wasn't sure at the time was exactly how I'd be making the move. At the time it seemed that the most likely pathway was going to be installing a new drive for RHEL 5 and migrating the data over afterwards; the exact mechanics of this were never really defined (would the drive have RHEL 5 pre-installed on it prior to being slotted in? would they need to take the machine down and do the install "in place"?).

Ideally my host (Rackspace) would have slotted in a drive with a pre-installed OS on it, brought the server online so I could migrate my data over to the new drive and then rebooted from the new drive. I thought they use identical, standard hardware configurations to allow precisely this kind of thing.

So you'd be looking at two reboots, one of them accompanied by a few minutes of downtime to physically install the drive, and then a period in which some services didn't work properly because they'd need to be tweaked, set-up and configured only after booting into RHEL 5 for the first time. But overall impact to your website visitors would be fairly minimal. Once all that was done you'd be looking at another quick powercycle while they shut down the server to remove the old drive (you don't get anything for free from Rackspace).

I wonder how often Rackspace does this type of upgrade. As it was, they were suprisingly slow to offer the details of the procedure and offer options, and that's what makes me wonder.

After quite a bit of deep thought I decided that instead of staying with Rackspace I'd move on to another company. I've chosen INetU.

Read full article

More Miscellaneous articles

Posted by wincent at 11:53 AM

January 28, 2008

Involuntary Reboot Log #25

Like I said the other day, looks like this iMac is dying. This time the machine simply turned itself off when I bumped the desk with my knee; it could barely even be called a bump.

The average time between failures is dropping. Not long ago it was about one month, but now it's approaching three weeks, and if you look at the average over the last month the failures have been almost weekly.

Apart from the risk of damage to my data, I am starting to get sick of these Disk First Aid runs (during which the machine is unusable), which go especially slowly because Spotlight decides to reindex all of my volumes every time I have one of these failures.

On a tangential note: I received an email in response to my last post in which I complained about the lack of RAM in the low-end iMacs. It was pointed out to me that real-world RAM really is cheap nowadays (even if RAM from Apple is not). You can max out an iMac to 4 GB for a mere $100 at my retailer of choice (OWC), and for someone like me living in Europe and buying the RAM from the US you're still looking at only 85€ including international shipping.

Involuntary reboot stats to date

  • Operating system version: 10.5.1
  • Kernel panics: 7
  • Hard resets: 18
  • Total failures: 25
  • Start of recording keeping: 21 May 2006
  • Total days to date: 617 days
  • Average time between failures: 24.68 days
  • Uptime at moment of failure(s): a day or so

More Involuntary Reboot Log articles

Posted by wincent at 9:39 PM

January 25, 2008

Rails and validates_uniqueness_of

I'm a Rails dabbler who has never actually deployed an application yet but has been working in spare moments on a new version of this site that will be powered by Rails.

I was puzzled today to see excess SELECT queries whenever I saved a record. The queries were for attributes that were entirely unrelated to what I was manipulating.

I'll spare you the long story and cut to the chase. It turns out that these extra queries are generated by validates_uniqueness_of. I guess I should have known. The entire model gets validated whenever you save, even attributes that you haven't touched. I guess this makes sense.

Now, I am not really sure about the point of validates_uniqueness_of because it is vulnerable to a classic race condition; basically Rails checks "is this unique?" and if it is goes ahead and saves the record. Of course, in a multi-user application it's possible that what was unique a millisecond again is no longer so.

Basically validates_uniqueness_of can't provide you with any guarantees, and if that's the case then why bother using it? I had it in my app mostly for experimentation purposes.

The only robust way to approach this is to do what we always do when we have race conditions to worry about: go ahead and save the record and only if it doesn't work worry about what you'll do. In order for this to work you need to impose a database-level constraint which will cause an exception to be thrown if someone tries to create a duplicate (and of course, the database won't permit the creation of the duplicate to succeed).

Something like this in a migration should do it:

add_index :things, :attribute, :unique => true

Try to insert a "thing" with a duplicate "attribute" and MySQL will complain about a "Duplicate entry" and Rails will duly raise an ActiveRecord::ActiveRecordError which you can rescue and deal with appropriately.

If you're doing that then is there any point in keeping those validates_uniqueness_of calls? Perhaps. I guess if the probability of races is low then you can keep your application logic simpler by relying on validates_uniqueness_of for informing the user nicely that "that name is already taken", and rely on database-level constraints to handle the really nasty race conditions (and throw an irrecoverable error). I suppose it depends on how much traffic and contention you're expecting. If traffic is high and performance is a real issue then you might just want to get rid of the validation; it doesn't provide any guarantees and those extra queries will only slow you down.

More Development articles

Posted by wincent at 8:51 PM

iMac finally dying?

I'm starting to get really worried about this machine.

Today we have the painters here painting all the rooms, which means that I've had to take the iMac out into the kitchen. As I've mentioned before, it has a wonky power socket, and this time it didn't want to boot up.

Several minutes of jiggling later I finally got the machine to turn on. Now I'm wondering which boot-up is going to be the last. One of these days the machine isn't going to power up.

Financially, I'm not in a position to buy a replacement yet. The cheapest model costs 1,169€ here but is handicapped with only a gig of RAM which would probably make it slower than this machine (which has 2 gig) despite having a faster processor (a 2 GHz Core 2 Duo as opposed to the 1.83 GHz Core Duo I currently have). RAM is very important for performance when compiling code in Xcode, mostly due to the amount of memory occupied by precompiled headers.

The top-end model would be a big improvement over my current machine — a 2.7 GHz Core 2 Extreme with 2 gig of RAM and a bigger screen (24" up from 17") and hard drive (500 GB up from 160 GB) — but it's out of my price range at 2,159€.

So really my only two options at this stage are to cross my fingers and hope that this machine holds up, or send it in for repair; and with the deadlines I have looming I just can't afford to be without this machine, even for a few days.

More Miscellaneous articles

Posted by wincent at 10:28 AM

January 21, 2008

Git 1.5.4-rc4

Git 1.5.4-rc4 is out, and the final 1.5.4 release is likely to come soon, probably before the end of the month. My favorite change in this build is the fix for the performance regression when commiting a single file specified on the command line (eg. git commit foo) as this is something that I do often.

The regression was only in the development version and has never made it into a released version of Git, but I've been tracking the master branch for some time now (see "Tracking the Git maint or master branches") so I had definitely noticed the problem.

More Development articles

Posted by wincent at 12:51 PM

January 19, 2008

Moving to RHEL 5

In October last year I wrote about changing UNIXes. Well, it's a new year now and it looks like it is going to happen.

I'll be migrating to RHEL 5 (from RHEL 3). I don't have a firm date for the migration yet, and I need to do quite a bit of research before then about the best way to get all my data across. This will basically be a clean install on a new hard drive, the server should only be down for a relatively short interval, and then we'll come back on line and over the following hours I'll be transferring user accounts, mail, databases, software and everything else from the old hard drive to the new. So it will be quite intense, and most services will be interrupted for at least some of the migration. I expect to be transferring and configuring for several hours, possibly even the entire day.

One way to minimize the interruption would be to install the drive with the new system on it and migrate some of the data before rebooting, but I'm not sure how much time that will actually buy me, nor whether my host, Rackspace, would be prepared to do that (it would require them to install RHEL 5 on the drive in another machine, then uninstall it from that machine and reinstall it into mine).

I'm very happy about this because it means I will be able to gradually retire bits of legacy software and replace all of this with a single, lean, unified Rails application which handles everything for me (bug tracking, customer support tracking, forums, the wiki, and so forth).

Deploying Rails is a bitch by all accounts, but it's easier on RHEL 5 than it is on RHEL 3, (specifically, there are fewer pieces of additional software that you have to install, and you deviate less from the supported, auto-updated configuration). And once you've deployed it you've got one application stack to worry about instead of half a dozen.

More Miscellaneous articles

Posted by wincent at 2:56 PM

January 17, 2008

Involuntary Reboot Log #24

Only a few days since the last kernel panic and I've just had another hard reset. This time the machine just froze completely with no explanation (mouse pointer frozen, clock frozen, no visible movement on screen or sound from the hard drive). This machine may well be on its last legs.

As always I did a Disk First Aid r

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.