Wednesday, March 22, 2006

Are we a youth hostel now?

About two weeks ago, Q's Ukrainian friends stayed here for a few days. Then this past weekend, N had 3 college buddies and his brother over for the weekend--for his "bachelor party." (I do not think I saw his brother sober ever.) Then last night when I come home, there's some guy sleeping on the couch--one of Q's friends.

Anyone else need a place to stay?

Monday, March 20, 2006

Why PHP is not a real language...

PHP doesn't have named parameters. You know what that means? That's right, you have to specify every parameter to a function, in order and unnamed, even if there are default values. You can leave off parameters at the end, but only at the end.

Earlier today I thought, "Hey, it'd be neat to list the number of posts in each category." It's not exactly rocket science. The categories are listed by some function called list_cats, and it takes a parameter for just such an occassion. It's called optioncount because it controls the option of whether or not to list the post counts for each category. It defaults to FALSE, or in other words "don't show the counts." Hey, I told you it's not rocket science.

So I have just to send the function TRUE in that parameter instead of the default FALSE. Now here comes the whacky part. I now have to specify all the parameters of list_cats up to and including this one--even though I don't want to change any of the others. So the code must read:

list_cats(FALSE,'All','name','asc','index.php',TRUE,FALSE,TRUE)

There's only one other parameter in there that's not taking the default value. That's the one 'name' which says to sort by category name (it defaults to category ID--why!). So with named parameters, it could look as simple as:

list_cats($sort_column => 'name', $optioncount => TRUE)

Now I must ask you the reader a few questions. Which one is more readable? It's certainly not clear what all the parameters in the first one do. Furthermore, which ones are important? For example, which ones differ from the defaults? Which ones are there because the author intended them to be set, and which are just there because the language is braindead?

While we are at it, which line is more maintainable? If you write this and come back to it five years later, or even two days later, you'll have to scour the documentation to figure out what all the parameters of the first line do. You can make an educated guess (and probably be right!) for the second version. (Maybe PHP developers are envious of Perl developers for being able to create morasses of unmaintainable, illegible code! Just a theory.)

This shortcoming is nothing new. I used to use PHP all over the place. So when I encountered this flaw again, I thought, "Hey, maybe they fixed that in the latest version!" So I googled. Unsurprisingly, I found this guy Adam who thought named parameters would make his life easier. I'm sure there are many such people out there though. He had a nice link though... Apparently the PHP people did think about adding named parameters pretty recently. Laughably, they did not. The link gives three reasons:

  1. There is no real need.

  2. It's not simple enough.

  3. It makes code messier.



Now, certainly in my example, and in Adam's, it makes code simpler and easier to follow. What's more, it leads to maintainable code. You could actually read some lines without having to continually return to the manual or documentation. You can imagine how difficult it must be to actually figure out what's going on in a reasonably-sized PHP script. So really, that only leaves their first one: there is no real need.

I suppose. Other languages respect developer time. They try to help one make simple, legible, maintainable code. Ruby and Python stand out. Even Perl has named parameters. So in the sense that one can just use a decent language, I agree.

(If this seems like a bit of a rant, I suppose it is. I just see no reason to purposely thwart developers--even if they do use PHP. Given the option, the PHP language gods could add named parameters. It'd lead to better code, and save time for everyone. But they choose not to... WHY?)

The mice are back...

And I can't get to sleep. I'm going to do laundry and hope I don't wake up Q.

Saturday, March 18, 2006

Sing on

I got a little tired writing about all the results, so I'll give up on that. What's a little surprising is that I'm still second in our little pool. And in most cases, my losses weren't huge ones. Today I chose A&M to win, mainly because of the Texas connection. And as with every team I chose, they were winning with about 2 seconds left. And they lost! Oh well.

Rob and I are actually in two pools together. There's the small one he started with U of C math people. Then there's the one at the place we play pool. Supposedly this one's pretty big, with people from many bars and such playing in it. Unfortunately, we can't tell how that's going...

In the midst of all this fun, Niles has had friends and his brother over for his "bachelor party." A bunch of annoying drunk people... There is a bright side: Mitya is out of town and everyone else will sleep soundly. Thus, I can leave my tunes playing while I drift off to sleep:


Operator won’t you put me on through
I gotta send my love down to baton rouge
Hurry up won’t you put her on the line
I gotta talk to the girl just one more time.


OK, so it's not "Freedom is just another word for nothing left to lose," but who are you to judge? I'm from Texas, damnit.

Thursday, March 16, 2006

Unlucky me

So the rest of the games didn't help me so much. UCLA won, but everyone and their mothers called that. Fortunately, GW won in overtime by 3 points. I had them over NC Wilmington. LSU won over Iona. They were down at the half, but they continually expanded their lead in the second half. Likewise, Gonzaga was down at the half, but came back to win it. Unsurprisingly, Illinois easily beat Air Force and Duke killed Southern. I got all these.

Now we get into the fun part. Texas A&M beat Syracuse. I'm not sure if I wanted them to win because they are from Texas or because they play decent basketball. Probably the former... It wasn't too close a game though, and it worked out. I said there would be two other upsets though. I said San Diego St. and Utah State would win. They both lost. This wasn't too surprising. Utah had no chance of winning either. They were always down by around 10 points in a relatively low scoring game. However, San Diego was playing well. They were leading by a point with only seconds left. Again, a late score did me in.

Only 10 of 16 games did I get correct. I'm ranked at about 2 millionth of those on ESPN. That is, I'm at about the 27th percentile. What's funny is that EC called 14 out of 16, and she's at about the 99th percentile! Guess how she filled out her bracket...

Go ahead, guess!

That's right. She flipped a coin!

March Madness

I'm in two small pools regarding the tournament. It makes the whole thing so exciting.

The matchups so far have been not bad. Wichita St. beat Seton Hall in a blowout. Florida beat Southern Alabama in an unsurprising game. I got these right. Oklahoma lost in an upset to Wisc. Milwaukee. I got this wrong, but apparently so did the experts. :)

BC won over Pacific in double overtime. This was such an exciting game. I called this, but I must say it was much too close for my comfort. It was tied 65-65 at the end of regulation. With two three pointers in overtime, Pacific brought it to 71-65. Then BC brought it to 71-69, and Pacific made another three for 74-69. BC made a three to get it to 74-72. Then, with seconds left BC's Smith made the tying free throws. (He apparently is not so good with the free throws.) The second overtime was relatively anticlimactic, but BC managed to pull it out.

What was perhaps the most interesting was the Tennessee and Winthrop matchup. Believe it or not, I said Winthrop would win this. I might be the only person too. And it was a close game, the whole way. It was tied 61-61 in the final minutes. Then with 3 seconds left, Tennessee had possession, put it up, and damn it was good. Winthrop had 0.4 seconds left on the clock to get all the way down court and score. Obviously, this did not happen, but they tried valiantly. Final score was 63-61. I didn't call this game right, but I was close. :)

In another uninteresting upset, Montana beat Nevada. More interesting though was the Alabama win over Marquette. It was a 1 point game with 20 seconds to go, but Alabama pulled out a 5 point game. I got these both wrong. :(

So far, I've got 3 out of 7. I'm not doing so hot. I guess that's what happens when you don't regularly follow basketball... Fortunately I had none of these losing teams winning more than one game.

Everyone else having fun with the basketball? :)

Wednesday, March 15, 2006

Hard links!

I found the Unix Hater's Handbook for the umpteenth time. When I was in high school, I got it out from the public library. It's a long rant, but it's cute. It has many stories of ancient relics, such as LispM, and early Unix frustration... (One can also peruse some archives of the Unix Haters' mailing list.)

In the last chapter, they bring up one of my favorite things: hard links. Most of you probably don't care, but that hasn't stopped me yet. Hard links are absolutely wonderful creations. Most Unix-like filesystems behave very similarly. Information on a file (such as its owner and permissions and where it is located on disk) are stored in a central place. This allows for a little legerdemain. The filename is not part of this information. Instead, the filesystem views directories as lists of names and associated files (i.e. pointers to these blocks of information).

This means the name, and location in the directory hierarchy are not inherent properties of a file. It is possible that a file on disk is "hooked into" the directory hierarchy at no places (this shouldn't happen) or at more than one place. This latter condition is known as a hard link. This means one has the exact same file at two (or more) different locations in the filesystem, possibly in two different directories, possibly with different names. This is not just an exact copy--it's the exact same file, and it's only taking up space for one.

Why is this useful you ask? That's a very good question. Hard links do seem arcane at first glance. One could use them to get a certain amount of safety. Say you have an important file. Hard link it to a safe place. It can still get screwed by malicious actors--it's the same file--but if your usual editor breaks hard links (i.e. when it edits a file, it takes a hard linked file, and replaces it with a copy) you will be safe from accidentally messing it up. You have a known good copy in the "safe place."

An even better use is to create branches cheaply. When I program something (I've been known to do this ;)), and I want to work on some feature or another, I can hardlink the entire directory structure over. This is quicker than copying, and it uses much less disk space. Then my editor can break the links for any files I edit. And I now have two directory structures: one with the unmodified source and one with the modified source. And they get to share the disk space for all the unedited files! Yes, disk is cheap, but my laptop hard disk isn't that big. (There are even certain revision control systems that can work within this setting. Even cooler!)

To create a hard link, just run ln filename linkname. They must be on the same filesystem. After this you'll now have a file called linkname which is identical in every respect to filename. If you want to do this on a whole directory structure, you can run cp -al directory/ newdirectory/. Now you'll have a new directory structure newdirectory/ with exactly the same files as directory/.

Then, you may want to teach your editor to break hard links. For vim you can do this by putting set backupcopy=auto,breakhardlink in your .vimrc file.

Monday, March 13, 2006

A Delicious Exercise

Last weekend, I wanted a cheesecake--a strawberry cheesecake. I had a craving. I've never made one before, but it seemed easy enough. Flora's Recipe Hideout has tons of cheesecake recipes so I looked through to find a good one. I picked what seemed to be the average cheesecake recipe and modified it a bit. Scrawled list in hand, I got my ingredients from the store. When I got home, Q was baking. I chose to rest on my laurels for a bit...

By the time Wednesday rolled around, I was jonesing. I wanted the cheesecake. That morning, I shared my plans with Nemili and she was gung-ho. So we immediately began our cheesecake odyssey.

I had bought a ready-made graham cracker crust from the store. We prepared the crust following the directions. Then we (that is, Nemili) mixed all the ingredients for the filling together. I wanted a strawberry flavor in the filling, so we put a few good dollops of jam in there. Then we put the filling in the crust and slid it into the oven.

A few notes on the result:

  • The recipe made a little bit too much filling for our pie crust.

  • The outer edges of the cheesecake rose in the oven. They settled while cooling, but there was an unsightly crack on the top of the cake.

  • The center cooked much more slowly than the rest. After 40 minutes, we turned up the heat to 350°F for 8 more minutes. Only then did the center appear somewhat set.

  • When we removed the cheesecake from the oven, the center still wasn't as firm as I would have expected. The cake firms a great deal while cooling.

  • The top of the cake gathered a rich golden color along the outer edges, but the strawberry filling gave the innards a pinkish hue. The two did not mix well.

  • The filling's consistency didn't seem quite right. I'm not sure what I mean by this...



All in all, it seems like the baking parameters could be usefully tweaked. (Maybe I should try baking it for longer at a slightly lower temperature?) With that in mind, here's the recipe:


  • 1 store-bought pie crust

  • 6 strawberries

  • 1 egg white

  • 4 eggs

  • 1t vanilla

  • 1c sugar

  • 1c heavy cream

  • 2T flour

  • 6T strawberry jam

  • 16oz cream cheese


Prepare pie crust with an egg white wash and a quick toast in the oven for a nice golden color. Mix the flour, sugar, and heavy cream. Soften the cream cheese and mix it in thoroughly. Beat the eggs separately and add them to the mixture. Also add the vanilla and about 4T of the jam to the mixture. Mix thoroughly. Pour the mixture into the shell. Bake at 325°F for 40 minutes or until center firms up. Cool at room temperature for an hour and then in the refrigerator for 6 hours. Decorate with remaining jam and halved strawberries.


Don't get me wrong. The complaints are mainly for self-improvement. It was a great cheesecake. A wonderful cheesecake. It was so good and rich... You have no idea. It was that good!

Bert and Elizabeth had me to dinner at their place on Wednesday. (We've done this before, as you know.) I took half the cheesecake over there. It was perfect timing. Bert didn't partake of course, but Elizabeth had some.

Everyone loved the cheesecake. Elizabeth enjoyed the cake. Q and Karolina seemed to enjoy it. Q said he'll have to buy the ingredients for me to make it again, and watch so he can do it. M thought it was store-bought it was so good...

Excellent.

Monday, March 6, 2006

Wise not to seek a secret and honest not to reveal one

I make an awesome pork chop. Paprika is the secret. I just season the pork with salt and paprika and then fry it in olive oil. It's quick, easy and cheap. From here to eternity, I imagine I'll always have tons of pork in the freezer. I just buy the really cheap cuts, less than $2 a pound. Then it's there when I need it. No thought. No effort.

My flatmates know my secret now. I've shared some pork chops with Q and N. They now each know exactly one use for paprika. Yesterday, Q tried to emulate my pork chops. He bought his own paprika from the store. (I don't know why he can't use mine. We keep all our spices together in a shared cabinet.) With that, he fried some boneless loin cuts and made a side of rice. (As it turns out, he overcooked the pork a bit. I think it's tempting to do that. It tasted alright though.) He really went gung ho!

Saturday, March 4, 2006

Numerology

Suppose one asks what fraction of matrices over a fixed finite field are invertible. For nxn matrices, one can calculate this easily. In order to make sense of this, one might be tempted to take the limit with n. As it happens, the limit converges. Not only that, it converges to a very nice function (of the size of the field). It's a theta function. It shows up all over the place in number theory. It's modular. Its Mellin transform is closely related to the Riemann zeta function.

Now why does this function show up here?

Thursday, March 2, 2006

Done

I suppose I never finished the story. CC and the workmen came over at around 10 a.m. on Monday. It wasn't quite as simple as I had hoped. CC wanted to put a shutoff valve in our apartment. So she called the plumber, and we waited a few hours for him to show. CC waited in her car for a bit, and then we watched some early Seinfeld episodes together. Finally, the plumber arrived, and they spent some time trying to figure out how to put a shutoff valve in our apartment. The plumber gave CC an estimate (which was larger than she thought), and she decided not to do it for a while. Then the workmen fixed the drywall, and moved the washer/dryer back to its place.

Overall, it only took about 5 hours. Relatively quick...

A Modest Proposal

A piece talking about high school algebra was recently published by the Washington Post. It's a decent satire I think. And it's gotten a rise out of people who take it seriously. The Scientific American blog responds with facts and studies for example. I think someone should write an equally humorous piece about the uselessness of English writing classes, but alas I'm not in the mood.

Come on! A writer who doesn't even know the meaning of the word "reasoning"? Even with access to computers and dictionaries? The example of algebra's uselessness being a simple problem of exactly the sort any manager might need. An argument that is sui generis and utterly devoid of reasoning skills? At the same time he suggests writing is the ultimate form of reasoning?

It has to be a satire!

Deduction

Induction just doesn't work.

Wednesday, March 1, 2006

Haha

Look at what I found! And look at who's making the offer!