infundibulum

Class variables are Mysterious

June 14th, 2005

I was just reading about Class variables, which, for some reason, don’t make an awful lot of intuitive sense to me… so, how important are they? Being a statistically-minded guy, when in doubt, I count.

UPDATED below, thanks sbp! (The script immediately following gives the right results, but only by chance. Find the bug? 8^) )

$ pwd
/usr/lib/ruby/1.8
$  grep -c  '@@' *.rb |rev|sort -n |rev|tac|head
weakref.rb 17
yaml.rb 16
profiler.rb 12
gserver.rb 11
tempfile.rb 5
tmpdir.rb 4
set.rb 3
resolv.rb 2
matrix.rb 0
complex.rb 0
$ ls -alh *.rb |wc -l
80

Well, only 8 out of 80 files in the Ruby directory have Class variables, so I’m not going to go insane about it. I mean, I’ll learn it but… that gives me a little perspective .

UPDATE
Sean B. Palmer pointed via a comment and instant messaging that there’s a problem with my little script: Uh, it doesn’t sort right. It’s sorting reversed numerals. Funnily enough, the data I had (the number of hits for '@@' in those Ruby files) sorted the same way reversed.

sbp’s solution doesn’t suffer from this thinko:

$ grep -c '@@' *.rb | awk -F: '{print "$2" "$1"}' | sort -rn | head

Which gives the same results as mine borked commandline. But it’s right.

Ah, blogging! The debugger of the future!

Intro to Wikipedia

June 14th, 2005

If you’ve ever been hesitant to actually edit Wikipedia, check this out: Wikipedia: Simplified Ruleset.

A couple extracts:

  • BE BOLD inupdating pages. Go ahead, it’s a wiki!
  • Assume good faith; in other words, try to consider the person on the other end of the discussion is a thinking, rational being who is trying to positively contribute to Wikipedia — unless, and only unless, you have firm, solid, and objective proof to the contrary. Merely disagreeing with you is no such proof.

The list as a whole constitutes a set of pretty good rules of thumb for getting involved in most online community, methinks.

Not that there are actually any other online communities like Wikipedia, mind you. Heh.