Chuck Norris in Ruby

🔍
2026 retrospective
Context for younger readers: in the mid-2000s, “Chuck Norris facts” were an absurdly popular internet meme — an endless list of hyperbolic jokes about the actor’s supposed invincibility (“Chuck Norris can divide by zero”). Naturally, someone had to implement them in Ruby. intinig’s blog is gone, but the GitHub repo is still up — a ChuckNorris class that refuses to be instantiated (“No one initializes Chuck Norris”) or subclassed. The best part: if you try, it walks ObjectSpace and nils every instance of your class. Roundhouse kick to the entire Ruby runtime.

intinig ported Chuck’s roundhouse kick power to Ruby! Have a look…

https://github.com/intinig/chuck_norris/tree/master/chuck_norris.rb

It’s a proof-of-concept, of course :).

🔍
2026 retrospective
The joke: Apple had just announced Snow Leopard (Mac OS X 10.6) at WWDC 2008, over a year before its actual release in August 2009. On a Mac, the “About This Mac” version string is stored in a plain text plist file (/System/Library/CoreServices/SystemVersion.plist). Edit it, reopen “About This Mac,” and congratulations — you’re running an OS that doesn’t exist yet. Apple has since made this file read-only on modern macOS via System Integrity Protection.

And this is the proof:

Snow Leopard

(Of course, if you know about SystemVersion.plist, skip this entry ;)

What does your .bash_history say?

A friend of mine told me that on techie blogs there is a new meme going on: show off the most used commands, starting from shell history:

history | \
awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | \
sort -rn | head -15

I’ve got 20 times the default bash history size (10k lines), so it’ll yield interesting results. I also use the history timestamp feature, so I’ve added a little sed to the code in order to strip timestamps out.

Let’s see:

vjt@voyager:~/code*$* history | 
 sed 's#^[ 0-9\[\/\:]*\]\([^ ]*\).*#\1#' |  
 awk '{a[$1]++}END{for(i in a){print a[i] " " i}}' | 
 sort -rn | head -15
928 l
577 ssh
389 ping
381 cd
300 dig
259 telnet
153 sudo
126 ifconfig
125 whois
113 ps
96 svn
91 cat
73 fg
68 vi
61 ..

Yeah, I do a LOT of ls, l is actually ls -alFGs (I’m on Darwin). This list exposes my recent habits, because I’m coding less and managing more (no gcc, no irb, lots of dig & whois). svn is still there, of course ;). ssh means that these results should be aggregated with other histories coming from the other boxes I log on to.. but that’s a topic for another post ;).

Which are your results?

Post them here! :D

UPDATE 2008-06-03

As my recent habits are more coding than writing docs, I re-ran the history analysis.. and these are the new results:

1796 l
981 svn
705 ssh
693 cd
666 ping
402 vi
356 ifconfig
352 telnet
321 dig
315 sudo
283 fg
240 grep
188 ..
183 cat
157 ps

UPDATE 2009-02-20

5427 l
4379 git
3128 svn
2812 vi
2105 cd
1408 ping
1392 fg
1328 ssh
935 ifconfig
893 grep
890 sudo
733 rake
653 cat
554 ..
535 ruby

UPDATE 2009-05-24

7374 l
5041 git
3265 vi
3131 svn
2753 cd
1881 ssh
1763 ping
1618 fg
1101 sudo
1100 ifconfig
977 grep
867 cat
767 rake
721 telnet
671 ..

UPDATE 2010-06-01

20517 git
7794 l
1906 cd
1631 rg
1518 vi
1108 rake
1041 cat
1010 ruby
790 sudo
754 fg
676 make
670 script/console
626 rm
496 ping
474 ..

UPDATE 2012-07-23

3367 l
2685 ssh
1289 cd
1013 curl
976 git
857 sudo
815 ping
526 telnet
521 ps
497 cat
472 port
422 fg
400 vi
274 rm
259 dig
📜

This post was written in 2008. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
LightWindow is long dead – it was a Prototype.js-era modal library that vanished around 2010. If you need modals today, the <dialog> HTML element does the job natively.

Well, this is the result of 2 days of head-banging with lightwindow:

Index: public/javascripts/lightwindow.js, line 444

  _removeLink : function(removed) {
    // remove it from the links array
    //
    this.links = this.links.reject(function(link) {
      if (link == removed.href)
        return true;
    });
    // remove it from the gallery links array
    //
    if (gallery = this._getGalleryInfo(removed.rel)) {
      klass = gallery[0];
      name = gallery[1];
      if (this.galleries[klass] && this.galleries[klass][name]) {
        this.galleries[klass][name] = 
          this.galleries[klass][name].reject(function(link) {
            if (link == removed.href)
              return true;
          });
      }
    }
  },

Call this function from your .rjs template, something like this:

page << "myLightWindow._removeLink($('element').down('a.lightwindow'));"

More details to follow, when this work will be complete ;).

We still can do it

Well, it seems that I’ve got no reason to be paranoid about my age: I still can do inline like I did (everyday) when I was a bit younger :).

On international workers day, 1st of May, Sam literally carried me out from home, far from the computer, and we went skating. It’s been an awesome day, we skated a lot, and shot some nice photos.

But the real good ones have been shot when ndstr caught us. He is by far the best photographer you could meet, and of course my favorite one (take a look at his site!).

He’s been also a skater, so he knows very very well how and when to shoot in order to take out the most from your tricks :). Here are two of them, portraying me and Sam while doing our best!

Skating Photo

It was fun. Really fun. Thank you Sam for taking me out of home :D.

Oh, and don’t forget to visit my deviantArt, and look at this one :D

📜

This post was written in 2008. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
The single-user mode recovery (Cmd-S, fsck, mount writable) described here no longer works on modern Macs. Apple removed single-user mode in macOS Catalina (2019), the system volume became read-only with Signed System Volume in Big Sur (2020), and Apple Silicon Macs use a completely different recovery architecture.

Well, I’m really happy with OSX 10.5.2. Even though I’m not the one that blamed Apple for the translucent menu bar that everyone dislikes.. well, I like it. I don’t care about the TM menu bar tool, because I haven’t bought (yet) the nifty Time Capsule, I like the spinner in the Airport menu and, most of all, I really like the updates to the BluetoothSCOAudioDriver.kext that drives my bluetooth headset.

Spotlight also feels faster and faster on every upgrade, and I’m a heavy spotlight user, so this makes me really happy. Thanks Apple engineers!

Back to the topic: why odyssey? Because as per my battery hints, I managed to make my MacBook2,1 SHUT DOWN while at 74% of the “Writing files” phase of the combo update… resulting in a completely broken system, as every geek could imagine :). Apple updated some libraries, and upon reboot simply nothing worked, and the darwin console was filled with lots of error messages.

The standard apple fanb^Wuser would have simply archived and installed his system, but hey, I’m a proud geek! I know from experience that disaster recovery situations are the best ones to learn something about an operating system, because you have to help the system boot up, bringing services up by hand, and find some way to re-apply the combo update without using the easy Aqua interface.

📜

This post was written in 2008. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
This advice is now the opposite of what Apple recommends. Modern lithium-ion batteries degrade faster from deep discharge cycles. Since macOS Catalina (2019), “Optimized Battery Charging” stops at 80% automatically. Apple recommends keeping your MacBook plugged in when possible and removed the “calibrate by full discharge” guidance around 2012.

3 simple rules:

  • DO NOT leave your charger connected when the battery is charged, even when you go to sleep.

  • DO let it discharge completely, when using it wait till it reaches 0%, when sleeping it leave it alone, when you’ll wake up and you’ll open it, a resume from suspend to disk will greet you. OSX FTW.

  • Monitor it and show off OSX performance counters to your friends (images courtesy of CoconutBattery.app and System Profiler.app)

Battery health Battery cycles

📜

This post was written in 2008. It's preserved here for historical purposes — the technical details may no longer be accurate.

🔍
2026 retrospective
Sun was acquired by Oracle in 2010 and Solaris is effectively abandoned since Oracle gutted the team in 2017. Python 2.4 and urllib2 are long gone — urllib2 was merged into urllib.request in Python 3.

While happily installing prerequisites to build an app on Solaris 11, i enjoyed having Mercurial already installed in the base system.. except for a BIG issue: digest authentication was broken. I tcpdump’ed the traffic exchanged between the mercurial client and the CGI server and I saw that no Authorization header was sent, and obviously the server refused to serve the hg repository.

Before reinstalling python, maybe from source and replacing the default installation or having side by side two different versions, with consequent nuisances and dirt around the system, I tried a very very small patch to urllib2.py that… amusingly enough, fixed my problem:

--- urllib2.py~ Fri Jan 25 02:35:59 2008
+++ urllib2.py  Fri Jan 25 03:27:52 2008
@@ -815,7 +815,7 @@
             auth_val = 'Digest %s' % auth
             if req.headers.get(self.auth_header, None) == auth_val:
                 return None
-            req.add_unredirected_header(self.auth_header, auth_val)
+            req.add_header(self.auth_header, auth_val)
             resp = self.parent.open(req)
             return resp

I’m no fscking python expert (but the language is interesting), so don’t ask me WHY it works, i simply followed the add_header comment that said “this method is useful for adding authentication headers” and replaced the unredirected_header method with the former. I really don’t know why with Python2.5’s urllib2 “everything works” even with that method, something must be broken somewhere else. A diff between the two urllibs gave me nothing, I really should learn Python one day or another.


On this page