April 29, 2005

Spring Concerts

I already sent out an e-mail to all my friends who I thought would be interested in the upcoming UMCB and UMRO concerts, but why not mention it on my blog? Never know who might be reading and decide they'd like to come check things out.

Yes, it's that time again, when all the University-related musical ensembles I play in cluster their concerts together. Only at the moment it's just two ensembles. All events are at the Clarice Smith (http://claricesmithcenter.umd.edu/).

  1. Monday, May 2, 8 p.m., Dekelboum Concert Hall: UM Repertoire Orchestra
    • Sibelius Symphony #3, mvt. 1
    • Mozart Flute Concerto (don't know the number; trombones don't do Mozart concertos)
    • Tchaikovsky Romeo & Juliet Fantasy Overture
  2. Maryland Day, Saturday, Apr. 30: Two for the price of one!
    • 10 A.M., UM Community Band in the Kay Theater
      • Original Suite - Gordon Jacob
      • Xylophonia - Green
      • Georgia on My Mind - Hoagy Carmichael
      • Courtly Airs and Dances - Ron Nelson
      • First Suite in Eb for Band - Gustav Holst
      • Fugue on Yankee Doodle - J.P. Sousa
    • 11 A.M. (Immediately following!), UM Repertoire Orchestra Open Rehearsal
      • Rehearsal for above program. May be missing English Horn and some other parts... I don't know. Just head across the hall into the Dekelboum after the band concert.
FYI...
Posted by Bob at 02:03 AM

April 28, 2005

Defective Yeti Meme Game

New game from Defective Yeti. Everybody play! Click on the "URL ABCs" link to find out what this is about.

These are my URL ABCs:

Posted by Bob at 03:21 AM

April 25, 2005

Evil C Macro of the Day

The following line is in the source code of the product I maintain:

#define MAX_INT MAXINT/2 /* (2**31 - 1) */

In case that's not clear, the fact that MAX_INT is half the size of MAXINT is indicated by the underscore, which cuts the macro name in half, see.

Posted by Bob at 04:12 PM | TrackBack

April 23, 2005

Sliding Tile Puzzle

Finished with my JavaScript "15" tile puzzle. Oh, except it's really an "8" puzzle, because the website I stole the broken up images from had only 3x3 puzzles. Enjoy.

After all that work looking up how to do AddEventListener in IE, I ended up, on PPK's advice, dropping the use of that method, and using the "traditional" method for event handling.

Posted by Bob at 03:11 AM

April 22, 2005

Implementing the "15" Puzzle in JavaScript

Everyone knows those "15" puzzles: a 4x4 board with fifteen tiles that fit in there just so that you can slide an adjacent tile into the single empty spot on the grid. I found one online, but didn't like it because it was implemented server-side. I thought a JavaScript/DHTML version would be much more responsive, and fun to code up.

I finally got something that worked exactly how I wanted it to, but... I had been testing only in Mozilla. Since it works in Mozilla, I expect it to work in Every Other Modern Browser, except, that's right, Microsoft Internet Explorer. So when I finally decided to get it working in the Non-Thinking-Man's browser, I was at a bit of a loss. Not too much of one, though; a search for "ie addeventlistener" turned up this article on creating cross-browser event handlers: just what I was looking for.

I just thought I'd give that a mention for now. I'm still not done with it, as there's also a difference with the definition of "this".

Posted by Bob at 07:26 PM

April 20, 2005

31337 Hack of the Day

I saw some code at work today that looked like:

while ((here = FindInList(here, object), here))

My first reaction was, WTF? This turned out to be a quite appropriate reaction, because I ended up getting a general idea of what this meant at a pretty cool, fun website called The Daily WTF. Evidently, expressions (can I call them "statements"?) separated by commas are evaluated serially, with the last expression being taken as the value of the whole list. Pure Evil™, in other words, but at least now I knew what my while line meant.

Or did I?

Turns out in addition to the use of long-lost bastard syntax forms, we have a precedence issue. The above statement, simplified, is of the form

while (a = b , c)

Normally, for aesthetic reasons, I wouldn't put a space before that comma, but here it points out that '=' and ',' are both operators in a larger expression, and must face off in a precedence war.

I'm a firm believer in not memorizing rules of precedence, except for the really easy ones like '*' is higher than '+', which we were all taught in elementary school. How, then, do I find out what this code really does, so I can drop in parentheses in the right place? Well, I could take The Daily WTF at their word -- they mention the same issue. Or I suppose I could concoct a simple program, but this syntax is so weird to me that I don't really feel comfortable trying that (or maybe I'm just lazy).

Here's what I did do. I copied the source file. Then I added the parentheses where I thought they made sense -- around the assignment, with the closing paren before the comma. Then I generated assembly code for that file, and for the original, and I diffed them. Here's what I got:

1c1
< .file "mist.c"
---
> .file "list.c"

w00t! w00t1 (Those are zeroes in "w00t", BTW -- should change this stupid font). This showed that, except for the file names, both files shared the same logic. Meanwhile putting the parentheses in the wrong place -- around the atomic expressions straddling the comma operator -- and regenerating the mist.s file gave me the following diff:

1c1
< .file "mist.c"
---
> .file "list.c"
1054,1055c1054,1055
< movl -12(%ebp), %eax
< testl %eax, %eax
---
> movl %eax, -12(%ebp)
> cmpl $0, -12(%ebp)

Now, I don't really know what that means; I don't do assembly, for the most part. But they are clearly different, which proves that the latter placement of parens changed the logic.

Now finally, I tried to analyze what that construction would really mean. Putting this newly acquired knowledge together with my existing knowledge of C, here's what I came up with:

"Assign the result of the function to here, but instead of the default value of this expression (which would be the result of the assignment: "here"), use our supplied value... here." Uh... OK, clearly I'm missing something very important. So back to the assembler method. Take out the ", here", run the assembler command on it, and do the diff. And....

1c1
< .file "mist.c"
---
> .file "list.c"

... that extra parameter is totally useless! What happen? Maybe originally this odd syntactical construct had different things on either side of the comma, and someone later on needed to change the lvalue of the assignment part, and didn't realize that this left a redundant expression when he was done? Nope. I checked the archives; that's exactly how the line looked when it was introduced.

What do you think, folks? Is this a candidate for The Daily WTF?

Posted by Bob at 09:10 PM

Papa's Got a Brand New...

Papa.

A new pontiff has been elected. Joseph Ratzinger, a quick day after grabbing the other cardinals by the throat and pronouncing moral absolutism as the most pressing item for the Church, emerged on the balcony of the Basilica of St. Peter, smiling, arms raised in victory. Pretty smooth. Looks kind of like Emperor Palpatine, don't he? Hmmm...

For more info, be sure to check out the relevant entry at Uncyclopedia.

Posted by Bob at 12:38 AM

April 17, 2005

Chinese Communist Humor

From the English People's Daily Online report on human rights in the U.S.:

"The US freedom of the press is filled with hypocrisy. Power and intimidation hang over the halo of press freedom. The New York Times published a commentary on March 30, 2004, saying that the US government's reliance on slandering had reached an unprecedented level in contemporary American political history, and the government prepared to abuse power at any moment to threat potential critics."

Translation: "As we've learned from the New York Times, there's no freedom of the press in the U.S."

Funny reading, with a handful of sobering truths in there. But it's funny to see the Chinese bash press freedom in the US.

Posted by Bob at 11:04 PM

April 13, 2005

One Idiot Does Greasemonkey

Some pretty amazing things are being done with Greasemonkey these days. If you're not using Firefox, you're missing out on a lot. It enables you to add various types of functionality to wither the browser as a whole, or to add functionality or apply changes to the Web page you are looking at.

Now One Idiot, like our friend Salieri from the movie Amadeus, lacks the true brilliance of those who are doing great things with Greasemonkey, and possesses only the degree of skill necessary to recognize such brilliance. He is, however, able to come up with some utterly frivolous hacks. His first such hack is the subject of this post.

Though I am not a Web designer (or perhaps because of this!) I am a bit of a fan of Dave Shea's CSS Zen Garden. Content-wise, this site has exactly one Web page. Its entire purpose is to show what can be done to a Web page simply by changing the CSS style sheet associated with it, and by having incredible artistic skills. I borrowed heavily from a design I saw more than a year ago on that site for the current design of this blog. This is mentioned in some other post, which I don't feel like digging up; search in this blog for "zen", and you should find it.

Dave Shea does a good job of marking things up heavily to allow greater flexibility and creativity for its contributors. He also does a good job marketing the site and the concept (at least he did initially; the site is now so popular it seems to sell itself, with every Web designer and his dog thinking they ain't shit unless they have their own template featured on Zen Garden for the little people to gawk at). But when it comes to content, he could use a little work on his writing. The preamble, in particular -- an attempt at putting the viewer in that Zen-like state of serenity and clarity -- simply falls flat, and nothing makes the clunkiness shine like his incorrect use of "lay" in the very first sentence, which starts out "Littering a dark and dreary road lay the past relics of browser-specific tags..."

Though I can't find my email to him, I'm fairly sure I did email him and point out that it should be "lie", unless he really meant to use the past tense. He responded rather vaguely, saying someone had told him it should be "lay", though he didn't remember why, and it had sounded like a good idea at the time, so he left it like that. An unresolved subthread on this page on his blog shows a similar lack of interest in fixing it. It reminds me of the Woody Allen character who said "I've always wanted to know how to spell Connecticut"1; you'd think he'd just go ahead and find out the answer once and for all.

Thus it seems clear this won't get fixed on the server side, though one clever CSS artist succeeded in sweeping that entire paragraph under the rug with CSS, possibly for that very reason! Most of the other artists have not done this, of course, so the only way to remove this eyesore permanently is on the client side. Check out the CSS Zen Garden first, and marvel and the inspired designs and poor grammar. Download and install Firefox and Greasemonkey first, if you haven't already. Then click on this link for the CSS Zen Garden Grammar Fixer, and install it. Finally, visit the Zen Garden again. Viola2! The grammar stickler in you is appeased!

Now, almost nobody is going to download Greasemonkey just to fix Dave Shea's grammar, but you might download it so you can have, say, an auto-save feature in Gmail or skip over ad pages in Yahoo[u.p.o.] Groups. The above two links point into a repository maintained by the Greasemonkey project of useful scripts that have been cooked up since Greasemonkey started. Go to the top of the page to see a list of websites that have scripts targeting them. Then, once you've done that, you just have no excuse not to go and install my tiny little script which will restore grammatical order to this tiny garden plot in the universe.

[1] Thanks to the Eats, Shoots and Leaves lady for this example.
[2] The alto member of the violin family of string instruments.

Posted by Bob at 08:16 PM
Hosted by www.Geocities.ws

1