baseball series probabilities
Mood: curious and mathy
Posted on 2006-06-30 09:36:00
Tags: baseball math
Words: 790

So when Rice was in the NCAA baseball tournament and College World Series, I thought about how one baseball game or even a three-game series weren't really enough to determine which team was better, which is why MLB playoff series are 5 or 7 games, which certainly seems enough to tell for sure which team is better. Trying to figure out how true that was, I modeled it mathematically:


So, let's be formal here: the Astros are playing the Blue Jays, and the Astros have an x chance of beating the Blue Jays in any given game. (for 0 <= x <= 1) Assume that we have no prior knowledge of x - i.e. the probability of x is evenly distributed from 0 to 1. Given that the Astros beat the Blue Jays, what is the probability that x >= .5? (that is, the Astros are "better" than the Blue Jays)

Since the probability that the Astros beat the Blue Jays in one game is simply x, we're looking at the area under the curve y = x, which is of course the integral of x. So the probability that x >= .5 is just (the integral of x from .5 to 1)/(the integral of x from 0 to 1) = (1/2 - 1/8)/(1/2) = 3/4.

(hmm, this would look a lot nicer in LaTeX)

The nice thing about this method is that it easily generalizes - let's say that the Astros beat the Blue Jays two times. Since the probability that the Astros win both games is x^2, the probability that x >= .5 is (the integral of x^2 from .5 to 1)/(the integral of x^2 from 0 to 1) = (1/3 - 1/24)/(1/3) = 7/8.

And let's say the Astros beat the Blue Jays in a best out of 3 series. The probability that the Astros win the series is x^2 + 2*(1-x)*x^2 = 3*x^2 - 2*x^3, so the probability x >= .5 is (1/2 - 3/32)/(1/2) = 13/16, which is .8125. (which is less than 7/8, which smells wrong to me, but sort of makes sense because a best of 3 series always chooses a winner, while "winning 2 games" doesn't. Feel free to start checking my math at this point, though :-) )

If the Astros beat the Blue Jays in a best out of 5 series, the probability that the Astros win the series is x^3 + 3*(1-x)*x^3 + 6*(1-x)^2*x^3 = 10*x^3 - 15*x^4 + 6*x^5. So the probability that x >= .5 is (1/2 - 5/64)/(1/2) = 27/32, which is about .844.

Finally, for a best out of 7 series, the probability that the Astros win the series is x^4 + 4*(1-x)*x^4 + 10*(1-x)^2*x^4 + 20*(1-x)^3*x^4 = 35*x^4 - 84*x^5 + 70*x^6 - 20*x^7. So the probability that x >= .5 is (1/2 - 35/512)/(1/2) = 221/256, which is about .863.








Probabilities with 0 <= x <= 1
# games in seriesProbability winner is "better" team
1.75
3.8125
5.844
7.863


So, this is all well and good, but the results seems a little unrealistic - I find it hard to believe that the best team wins 3 out of 4 times in just a single game. Let's try to remove some of the simplifying assumptions.

In the real world, the Astros beating the Blue Jays 100% of the time is just not going to happen. If we look at the final MLB standings from 2005, no team had a winning percentage below .3 or above .7, so let's try using .3 <= x <= .7 instead of 0 <= x <= 1. So we just have to recalculate all the integrals. This leads to the following results, assuming my math is correct (thanks to this numerical integrator):








Probabilities with .3 <= x <= .7
# games in seriesProbability winner is "better" team
1.6
3.646
5.678
7.702


These probabilities seems a bit more realistic.

Finally, we've been assuming that x is distributed uniformly, but I'd say more teams are close in relative ability to each other. So let's try distributing x as a probability function over .3 to .7. We can use a "tent" function that peaks at .5 - something like 1 - 5 * abs(x-.5). (this hits the points (.3, 0), (.5, 1), and (.7, 1)). Again, this is relatively easy to calculate - we just multiply the expression we were integrating by (1 - 5 * abs(x - .5)). Doing this leads to our final results:








Probabilities with .3 <= x <= .7 and x weighted
# games in seriesProbability winner is "better" team
1.567
3.598
5.621
7.639


So there you have it - under this model, even a 7 game series will only pick the better team 64% of the time. The probability function may have been a little too harsh here, so the 70% in table 2 might be a better guideline.

To make this more accurate, we should recognize that even if the Astros have an x chance of beating the Blue Jays, on any particular night the starting pitcher for both teams adds a bit of variance to that factor. This might be interesting to look at at some point.

Thanks for reading this far! Comments (especially pointing at mistakes) are most welcome.

1 comment

bad news, good news
Mood: calm
Posted on 2006-06-29 14:35:00
Tags: politics links
Words: 325

Random news items that have left me thinking recently:

Bad news - High court upholds most of Texas redistricting map. The Supreme Court ruled that it is essentially OK for state legislatures to redraw Congressional districts whenever they want, and not just every 10 years (after the Census) as required by law. This to me is really horrible news. A Daily Kos article opines that the Democrats should take advantage and do this in states where the state legislature is more Democratic than the congressional delegation. I consider this whole thing to be a non-trivial threat to democracy. Guh.

Good news - High court blocks Gitmo military tribunals (CNN really likes to refer to the supreme court as "high court", apparently :-) ) This is a big rebuke to Bush's claim that, since we're at war, he has broad overarching powers to hold people as enemy combatants. Andrew Sullivan points out the court seems to have reinstated the Geneva Conventions in the "war on terror", which is also good.

Bad news - Israel hits Gaza as Hamas lawmakers held. This has been a rapidly-escalating series of attacks between Israel and Palestine and it looks like things are getting much worse. This latest conflagration started when Palestinian militants kidnapped an Israeli soldier, and they have killed an Israeli settler since then. To put pressure on the Syrian president to stop aiding Hamas, Israeli fighters buzzed his home yesterday (anti-aircraft guns fired on them). Scary stuff.

Good news - Buffett to give away billions. Warren Buffett is giving away $30+ billion dollars, most of it to the Bill & Melinda Gates foundation. The Gates foundation does great stuff in global health and education, and $30 billion dollars goes a looong way. Good for him!

I read this great speech by Barack Obama - it's a little long, but very powerful. The last 10 paragraphs or so I liked a lot for personal reasons. I hope he runs for president in 2008 or 2012 or sometime...

6 comments

Maryland pictures up
Mood: meh
Posted on 2006-06-29 10:07:00
Tags: pictures palmtogooglecalendar
Words: 48

Here are the Maryland pictures - didn't get too many that turned out decently.

Yesterday Google released their authentication for Web-based clients (although it seems to have disappeared at the moment - weird!), so I hope to get a working version of the palm to google calendar thing up soon.

4 comments

oh well
Mood: disappointed
Posted on 2006-06-22 11:32:00
Words: 98

So the US's run is over with a 2-1 loss to Ghana. They played decently and had some good chances in the second half, so it wasn't horrible. The sad part is that Italy beat the Czech's, so if the US had won they would have advanced. Now Ghana gets the opportunity to play Brazil :-)

Also, since I have sound working on my computer again, I've been playing a lot more Civilization IV. Goood stuff. I love this game! The English empire will rule the world soon enough...

djedi and I are gone this weekend apartment hunting. Exciting!

5 comments

driving quiz! and character encodings
Mood: aggravated
Posted on 2006-06-17 18:58:00
Tags: java
Words: 544

So, first things first. I was driving on Anderson east of Mopac and was waiting to turn left into the shopping center that houses the Alamo Drafthouse. The left turn light was solid green (i.e. a yield thing) and there were cars coming. Then there was a letup and a bunch of cars in front of me turned left. Except for the car in front of me - there was plenty of space to turn but he didn't. I was in no particular hurry, and there were cars waiting to turn left behind me.




So I did honk, but I waited for a while. The reason was fairly simple - the guy should have gone, and there were cars behind me. I was more honking on their behalf than honking for myself.

As it turns out, I waited too long to decide and by the time I had honked it would have been a little close, so the guy didn't go and then the light turned red. The next time it turned green, there was no fair opportunity for the guy to go. Finally, the next time we both got to go (although he hesitated a bit).

Thanks for playing!


On another note, I'm working on the Java iTunes to m3u project I mentioned before. It basically works, except for the fact that iTunes stores the file paths in UTF-8 format, while I need them to be in Latin-1 format for them to be read from the filesystem. I've run into this before in Python and solved it, but it always always takes me at least an hour and makes me very frustrated. I've read Joel on Software's The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) which was terribly helpful in knowing what I need to do, but man, it gets frustrating. Hopefully I'll solve it in a bit here and I'll never have to write this code in Java again...
Postlude: I did finally get it to work. The key moment was when I realized I had to set the environment variable LC_ALL to en_US - then it works. If you leave it the default (blank for me), there is literally no way to access files and directory with characters above 127. This makes me cry, seriously. Don't ask me to sing UNIX's praises right about now...

djedi and destroyerj and I went to watch the US-Italy game at the Drafthouse today. It was fun! Unfortunately we were late enough that we couldn't sit together, but the upside was that it was crowded and a good crowd to watch the game with (although there were a few Italy fans here and there...luckily no problems there). I even explained to the guys next to me what offsides was :-) Wish the US had won, but a 1-1 tie is nothing to be ashamed of and they looked sooo much better than their first game, I have high hopes for their Ghana game. They have to beat Ghana to advance, and if Italy beats the Czechs, then they'll advance for sure - otherwise it comes down to tiebreakers (the first one is goals scored - goals scored against) which the US is doing poorly in right now. So we'll see Thursday morning!

8 comments

quick macgyver link
Mood: busy
Posted on 2006-06-16 15:01:00
Words: 13

Busy day, but here's a list of problems solved by MacGyver. Wikipedia FTW!

0 comments

Colbert nails him!
Mood: giggly
Posted on 2006-06-16 09:42:00
Words: 21

If you missed the Colbert Report Tuesday night, you should check out this interview he did of congressman Lynn Westmoreland. Hilarious!

2 comments

Java!
Mood: mellow
Music: The Killers - "Mr. Brightside"
Posted on 2006-06-15 10:25:00
Tags: java programming
Words: 689

I was feeling a little blah yesterday, so I did what usually clears that up for me - start a new project! (this probably isn't a great long-term solution, but it works for now) I decided to write a program that would turn my iTunes playlists (which are stored in the iTunes XML file) into plain ol' .m3us so I could listen to them served up from my computer. Not too tricky, since I already have an analysis of my songs in iTunes that parses the iTunes XML file.

To make it more exciting, I started writing it in Java, which I used extensively at Rice, but hardly at all since then. I was going to parse the XML file and then use XPath to get the stuff I needed, but the file is so big (200000+ lines!) that Java runs out of memory getting the nodes. Sigh. So I went back to plain ol' parsing it line by line and just picking out the parts I need, which turned out to be pretty easy.

It's not done yet, but I've already extracted the playlists and which songs they refer to (by referencing the database that is created when I do the analysis of my songs), so I just need to write the code to output them as .m3us which is pretty straightforward. But the point of this post is to point out some new stuff in JDK 5 (which is really 1.5) that are very nice compared with what we had back at Rice :-) The link describes them, but I'll point out the highlights:


So, anyway those made programming in Java a bit less painful, but it's still awkward going from a dynamically-typed language (Ruby, Python) to a statically-typed one (Java). Just takes some getting used to, is all.

On a random note, I rearranged my home page a bit, hopefully for better clarity and for putting the most important/interesting stuff towards the top.

5 comments

more world cupiness
Mood: excited
Posted on 2006-06-12 15:05:00
Words: 132

So destroyerj and I watched the Iran v. Mexico match at the Alamo Drafthouse on Sunday - admission is free (presumably for legal reasons), and it was a lot of fun! The picture quality was pretty good (HD content looks fine on a movie screen), and it was just a neat environment. I could have done with more people (around 15 at the start, around 30 by the end), but it was cool. Apparently Austin soccer fans are more partial to Mexico than Iran, btw :-) (Mexico won 3-1)

US lost today 3-0 to the Czech Republic - the Czech's are a good team, but the US did not play well at all. They play Italy at 1:30 Austin time on Saturday...

Also, Rice is two innings away from going to the College World Series!

2 comments

How 'bout that local sports team?
Mood: excited
Posted on 2006-06-10 21:35:00
Words: 548

So, wow. My sports day has been quite exciting.

I got up early to watch the England-Paraguay World Cup match (which started at 8 am). Luckily I TiVoed it, since I didn't start watching until 8:15 or so. I just get settled in, and bam! England scores (well, technically it was an own-goal on Paraguay, but it came off of such a beautiful free kick by David Beckham (yes, he bent it like himself) that it might have gone in anyway. After that exciting start, the rest of the game was fairly lackluster. England won 1-0, but didn't look like a great team.

After that, I watched the Sweden-Trinidad & Tobago match. This is Trinidad & Tobago's first World Cup ever, and nobody gives them a chance (Sweden's odds of winning are 44ish:1 - T&T's is something like 2000:1). Also, their starting goalie got hurt in warmups, so their backup keeper played the hole game. And what a game he played! He was tested quite a few times and came up admirably. Oh, and a T&T player got his second yellow card at the start of the second half, so they played basically the whole second half down a man. And they still pulled out a 0-0 tie, which they rightfully celebrated. For some reason I like a sport where a team can legitimately cheer a 0-0 game :-)

After the pride festival, we went rock climbing. It was fun but tiring and hard on the muscles! I climbed my first section pretty well and then waited up there for a while before I could convince my body that pushing myself backwards to fall was really the right thing to do. Climbed another wall and a half before my arms gave out on me...

Then I had root beer at NxNW. Yeah, not sports related, but that was seriously good root beer!

Then I came back here and was planning on watching the Rice-Oklahoma baseball game. Unfortunately, ESPN2 was carrying a different game, so I turned it off for a while. When I turned it back on, Alabama was ahead of North Carolina 4-2 in the middle of the 7th inning (I decided to root for North Carolina because they weren't ranked while Alabama was - make it more fun for me to cheer for someone :-) ). In the bottom of the 8th, North Carolina got a 3 run homer and later a double to take the lead 6-4. Then, in the top of the 9th, Alabama got a runner on base because of a throwing error. After a walk and a strikeout, they got a 3 run homer to go up 7-6! So now it's the bottom of the 9th. North Carolina gets an out, a walk, a stolen base and a strikeout. And with two outs, the same guy who hit a homer in the bottom of the 8th hits a walk off homer and North Carolina wins 8-7. What a game! (also Rice won 10-4 - yay!)

And if you think I'm going to miss the Mexico-Iran game tomorrow morning, you're sadly mistaken. It's irritating that I can't watch any of the games during the week since they're during the day, so I better make the most of the weekends. And they're both good teams so it should be a good game!

0 comments

wheeee
Mood: buzzed
Posted on 2006-06-09 13:48:00
Tags: baseball baseballstats
Words: 244

I'm having one of those days (really, one of those "last few days") where things are going very well (codewise). I left work yesterday with a mysterious problem, and solved it quickly this morning (my idea of what the problem was was right on, just needed a little more tweaking), which is always a good feeling. Also, I had a large mocha this morning, so I've reached a state of higher consciousness.

Nachos for lunch (not just nachos, mind you, but suuuuper nachos!) is awesome. Nachos for dinner (as I did at the astros game last week) is also good.

Inspired by the baseball books I've been reading, I present the expected runs per inning finder. There isn't a whole lot of data, but it's rather interesting. For example, if you have a runner on first with no outs, you never want to sacrifice him to second - the probability of having a zero-run inning goes from 57.6% to 59.3%. Sacrifices in general usually aren't worth it on a runs scored per inning basis, although they can be if you really just need a run.

From a technical standpoint, I used XPath for the first time, and got it to work with IE and Firefox without too much trouble. I also added more Retrosheet data to both the expected runs per inning finder and the Win Expectancy Finder.

The Texas Pride Festival is tomorrow in Austin. I'll be there!

Thank you, namaste, and good luck.

8 comments

recent happenings-on
Mood: peaceful
Music: U2 - "Sometimes You Can't Make It On Your Own"
Posted on 2006-06-07 09:10:00
Tags: politics
Words: 453

The Senate votes on the Federal Marriage Amendment today, which will not pass. On NPR on Wednesday, I heard a good series of stories about it, including a fiery speech by Harry Reid (D-NV, Minority Leader in the Senate) decrying the amount of time being spent on it since it has no chance of passing. Update - it failed 49-48, (so only 49 senators voted for it). Only one more person voted for it than in 2004, despite the fact there are 5 more Republicans in the Senate, and the AP calls it an "embarrassing defeat to President Bush". Woohoo!! (and I'll stop updating this post now)

Something I've been forgetting to mention - I got a summons for jury duty! I'm very excited. Unfortunately they have this new online system to sign up, which worked great, but I feel like I missed out on part of the experience. No matter - it's apparently a new system that isn't used many places. Anyway, I'm scheduled to serve sometime in mid-July (I'll find out more details before then)- w00t!

Went to the Round Rock Express game last night with Doug and Lucas - Teresa was supposed to come, but little Timmy had had a long day and was very tired and cranky, so she stayed home with him. We only ended up staying a few innings since Lucas was tired, too, but it was a lot of fun. It was a beautiful night, and it's very relaxing sitting in the grass behind the outfield wall. Also, Lucas was in a very inquisitive mood, but in a cute way, not an annoying one. We had quite the conversation when I was driving him to pick up Doug from Dell :-)

After reading "Baseball Between the Numbers" (a birthday present - thanks, Mom and Dad!), I fired up the old Win Expectancy Finder data to figure out what the expected number of runs in an inning is, given the current situation. Got the data collected, now I just need to write a frontend to it.

So after my bold statement of my goal, getting sound working on my computer was quite easy. For posterity, I have an MSI RD480 Neo2 motherboard, which has an onboard Realtek ALC880. All I had to do was download the Linux drivers, untar and run the install script. Dunno why that didn't work last time, but whatever.

Also, Google announced Google Spreadsheets yesterday. I signed up and got in - if anyone wants to try it out I can let you share my spreadsheet. It looks neat, but I couldn't think of anything to put in a spreadsheet. Also, I finally got my invitation to Google Analytics so I've been playing around with that. Looots of stats available :-)

10 comments

adrift
Mood: 4 8 15 16 23 42
Posted on 2006-06-05 14:48:00
Tags: baseball baseballstats
Words: 242

So djedi and I were home this last weekend to celebrate birthdays and other things. I had a good time - it was good to get to see my family again. The downside is that Carrie got me hooked on Lost, and I spent too much time this morning looking at lostpedia.com to find out more stuff I missed. Maybe I'll watch it next year...

I also got some new shoes, which are designed to help me not pronate (walk on the insides of my feet). My feet are mostly used to them now, and they do seem to feel better, so yay!

We also went to the Astros game Saturday night.
Since the game on Saturday was exciting, and the Astros almost came back in the 9th inning, I graphed the win expectancy throughout the game using my win expectancy grapher. The resulting image is below:

You can see the Astros got back up to a 20% chance of winning in the bottom of the ninth, which is pretty good.

I watched and listened to the end of the game on Sunday, which was exciting and went into extra innings - the win expectancy graph is below:

Whenever a game goes into extra innings, the win expectancy fluctuates wildly (since one run makes a huge differencE), and this game is no exception.


Tonight before and after game night, my goal is to get sound working on my computer. We'll see how that goes.

3 comments

my current obsession
Mood: furtive
Music: one seven five zero five two six three
Posted on 2006-06-02 14:06:00
Tags: numbers stations
Words: 320

So I saw an article on Slashdot last night that rekindled my interest in some neato things I had looked at before (and possibly led to my bad dreams last night :-) )

The slashdot article makes reference to Numbers Stations, which are mysterious shortwave radio frequencies of spoken numbers, words, or letters. It is widely suspected that these are used to communicate with spies in the field, perhaps as a one-time pad. There's more information (and a listing of known stations) at spynumbers.com, and the Conet Project is a 4 CD set of recordings of many of these stations.

The article also talks about two recent postings on craigslist, which include a telephone number. Calling the number (at the time) gave a prerecorded message of digits, similar to a numbers station. A comment on the article also talks about similar postings in the comments of Slashdot, although I find it hard to believe people would use Slashdot for that sort of thing.

The blog 27B Stroke 6 at Wired thinks that the craigslist postings are love messages between cryptographers or something similarly innocuous, which is certainly possible. Interestingly, one of the authors of that blog, Ryan Singel, is the guy who interviewed Jonathan and I for Wired last year.

One thing I thought about: if these are one-time pads, isn't making them publicly available a big security risk? I mean, people have been able to track down where some of the stations are coming from, so it wouldn't be too hard to use the data received and try it against all known coded messages detected coming from that station's country of origin. Maybe I'm underestimating the amount of data involved, though.

I can't say exactly why, but I find the whole thing fascinating and creepy at the same time. I'm seriously considering ordering the CDs, although they are a bit expensive.

Anyway, that's what's on my mind. Have a good weekend!

4 comments

na nanana nana na na...
Mood: pensive
Posted on 2006-05-31 09:35:00
Tags: movies pictures ruby palmtogooglecalendar
Words: 451

...Katamari Damacy! djedi bought WeKatamari yesterday before he left (thanks!) so I played last night. Goood stuff. I love doing the flower level (collecting as many flowers as you can) - very relaxing. Quitting without saving and losing my data was somewhat less relaxing, but if you think I'm not going to redo those levels tonight, you'd be sadly mistaken.

I have the top Google result for "pic6"! Unfortunately it goes to this picture, but you can't win them all.

Speaking of pictures, I put pictures from Jessica's graduation up last night.

Speaking of things I did last night, the palm to google calendar thing is basically done. I have a few tweaks to do, but I'm going to link to it soon. fairydust1, want to test it?

So last time I talked about getting the ruby script to return that it was done while forking a new process. I was almost correct, but instead of doing this in the new thread:


# Create session and return session id to browser
pid = fork do
$stdout.close
$stdin.close
$stderr.close
# Do long-running stuff
end
Process.detach(pid)

you instead just need to do this:

# Create session and return session id to browser
pid = fork do
$stdout.close
# Do long-running stuff
end
Process.detach(pid)

Closing $stdin and $stderr just leads to problems (which was why passing parameters weren't working before).


Speaking of...umm...lj-cuts, I saw X-Men 3 this past weekend.
I liked it, all in all. The parallel between mutants and gays was extremely striking in some parts. I also liked the shift of power that the vaccine gave the humans - now they had a weapon against the mutants so it wasn't just a case of "watch the mutants kill the humans, who have no hope of ever retaliating". I like Storm the character (especially with the white hair!), but I didn't think Halle Berry did a good job acting this time around, especially during the scene where they're debating whether to keep the school open. It felt very fake to me.

Also, I loooove Ian McKellen. Maybe it's the white hair talking, but I like the obvious mutual respect he and Professor X have for each other. When Magneto lost his power, even though he was clearly a bad guy, I felt very bad for him since his identity was so wrapped up in his power.
If you go and see it, be sure to stay until after the credits end! There's a final scene that's actually very significant.

I'm looking forward to a number of summer movies - at some point I'll post the ones I want to see and y'all can make fun of me. Oh, there was a trailer for Snakes on a Plane, and it was good.

22 comments

warning: good weekend ahead
Mood: happy! not sick!
Music: Lordi - "Hard Rock Hallelujah"
Posted on 2006-05-26 09:37:00
Tags: pictures music ruby palmtogooglecalendar links
Words: 500

Already this weekend (starts on Thursday!) has been good - we finished Maraudon last night in WoW, which was fun (despite an infuriating part where Dextra and I (the two people who can rez) died and had to spirit rez and fight our way back. Scary!), and I got a shiny new dagger and orb.

Another good thing - I'm not sure yet, but I think I've solved my work problem...but not in a great way. It's like finally arriving at Disney World in Georgia (the country, not the state), and you're tired but happy you finally got there, and then getting out and realizing that Tennessee (where you started) is really right across the street from Georgia (the country, not the state). And you think everyone is mocking you for taking such a roundabout journey when you were right there, except they presumably aren't. Whee. I think I'll put this analogy to rest :-)

I have a problem...I cannot stop listening to "Hard Rock Hallelujah"! Seriously. Sometimes songs stick in my head so long, it actually makes my stomach hurt (and can keep me up at night). This song isn't there yet, but it's headed that way...

I put up pictures of Stephen's graduation. Next up - pictures from wonderjess's graduation! And then the pictures I will have acquired in the intervening time. Yikes.

Had a breakthrough in the palm to google calendar thing last night.

So the problem I had been having was that, when you connected to start the syncing process, it wouldn't return until it was done, which means that you couldn't poll for status updates. (actually, I guess you could, but then you'd have two connections open at once unnecessarily) So, I tried something like this:


# Create session and return session id to browser
pid = fork do
# Do long-running stuff
end
Process.detach(pid)

Interestingly, this works when you run the script from the command line, but not when you're doing a POST to it! I'm not sure if this is an Apacheism or something. After digging around for a while, I found the solution is to do something like this instead:

# Create session and return session id to browser
pid = fork do
$stdout.close
$stdin.close
$stderr.close
# Do long-running stuff
end
Process.detach(pid)

(Note: this is incorrect. See update here) and this makes everything work well. Except that I'm having some difficulty access variables declared in the pre-fork section inside the forked process. I bet they're getting destroyed or something when the parent finishes. But, on the whole, I'm closer to getting it to work. Yay!


"How to cheat good" (by a college professor). Tip number 8 is hilarious!

Top 50 Places to Have a Beer in America - I was a little disappointed/surprised there were no Texas places in there. (although this is just the places with highest scores on BeerFly - maybe there's some geographic bias there?)

DeLay campaign cites Colbert bit as evidence of innocence...um, wow. After the White House Correspondents Dinner thing, I thought everyone had figured it out!

7 comments

a few random things
Posted on 2006-05-25 12:42:00
Tags: music palmtogooglecalendar links
Words: 140

If you haven't seen the winning Eurovision song, and you like seeing people from Finland dressed as Klingons (or something), you owe it to yourself to check it out!

So I saw in my referrer logs that some MySpace page was using my spade image (), so I decided to look at the site. Aaand...wow. I think my eyes exploded just looking at that.

I made some good progress on the palm to google calendar thing - it's mostly working and the server is updating status as it goes. Now I need to figure out why the client doesn't poll for status until the server is done, and make the client display status in some nice and friendly way. Oh, and make it a bit more secure, too, just in case. Hopefully in another week or two it will be doneish!

14 comments

back from graduation!
Mood: sick?
Posted on 2006-05-23 11:10:00
Tags: travel
Words: 814

So wonderjess graduated this weekend, so I made the trip up to the ol' ROC to be there. It was a lot of fun! I took toons of pictures that maybe I'll get around to putting up tonight.

One downside is that I think I picked up a slight cold or something from my family (three out of four of the others felt sickish yesterday)...although I feel much better today than last night! (my flight got in around midnight and I was exhausted from travelling)

The way UofR does it is there is a ceremony for everyone in the morning, but they don't call names and nobody walks. You receive your diploma in smaller ceremonies on a per-department basis. So, the four of us got up early Saturday morning to get good seats - we got there around 8:15 for a ceremony that started around 9. The trouble was that when we got there, it was cold, windy and rainy. Luckily, it stopped raining before the ceremony started and the wind died down some, but it was still darn cold. To pass the time, Carrie and I and Mom played a word game - we each picked a word before it started that we thought would be said the most, and counted how many times it was said. Carrie beat us both by a lot. For your enjoyment, take a guess which word won!


Carrie had "academic", which was said 7 times. I had "success" which was said 2 times (although "succeed" was said 2 times as well). Mom had "meliora" which, oddly enough, was only said twice. Thanks for playing!

That first ceremony was fairly short, only an hour long. Then we met up and went inside to warm up, then headed out to the next ceremony (where we met the grandparents). The Modern Language and Cultures ceremony (wonderjess majored in Russian) was not well run at all, so it took almost an hour to graduate maybe 40 people. And it was boring. And slooow.

But after that we headed over to brunch, which was awesome! I had a tasty omelette and some yogurt with granola, some hot tea, and strawberry shortcake from the strawberry shortcake bar. (yes, a strawberry shortcake bar!) I didn't even try the lunch stuff, which looked delicious, or the waffle maker or the hot chocolate with marshmallows in it. Mmmm.

After lunch was the political science ceremony, which was much more organized and better run. I didn't realize just how big the department is - they graduated almost 100 people this year! wonderjess won an award for the outstanding undergraduate in poli sci - congrats!

We were pretty "graduated out" by that point, so we helped wonderjess pack and store some more stuff, then relaxed for a bit and then went to a poli sci party hosted by a professor. That was sorta awkward, as Carrie and I clung together to avoid social awkwardness, at which we mostly succeeded. Then it was time for dinner (oof, so full by that point...maybe that's why I gained a bunch of weight this week :-( ) and bed after that.

wonderjess finished moving out, and she found an apartment for next year, so all in all it was a successful weekend. It was nice to see my family and grandparents, too.

Travel notes: I flew JetBlue for the first time, and boy is it awesome! The seats were pretty comfortable and the inflight DirecTV and XM satellite radio are awesome. I watched an X-Files, Daily Show, Colbert Report, Yankees-Mets game, and some other stuff I'm probably forgetting. Also listened to the end of Game 7 of Mavs-Spurs. On the way there, I watched Game 6 of the Cavs-Pistons game - unfortunately, the signal cut out (which happened reasonably often) when there was 1.6 seconds left and came back on after the game was over. The second flight, I watched Game 6 of Mavs-Spurs....until there was 16 seconds left and we had landed and they turned the system off. Doh!

On the way there, I was flying into JFK and we had started late (and I only had 50 minutes for my connection anyway)...then the flight was slower than expected. But I was still going to be OK until the pilot announced the flight in front of us had declared an emergency and so no one else could land until they did. So we had to circle around a bit. Then when we finally did land, we had to sit on the ground for maybe 10 minutes because there were no gates available. Luckily they held the flight for me, because otherwise I surely would not have made it...

On the way back, I got to spend a lot of time at JFK airport in New York. It's a neat place! Lots of interesting restaurants, and a few bookstores, and just generally a very busy place, which I liked.

7 comments

la-de-dah
Mood: happy
Music: Pink Floyd - "Time" (imh)
Posted on 2006-05-19 09:49:00
Tags: links
Words: 111

Whee! Friday! And I'm visiting wonderjess and watching her graduate, so I'm looking forward to that. And I'm flying JetBlue, which I've never done before! Man, I like travelling. They show DirectTV on the plane and everything, which intrigues me.

These "seamless pictures" are very very cool. They're the work of Rob Gonsalves.

The Competitive Enterprise Institute is a group funded by lots of big companies that, among other things, argues that global warming isn't really happening. They have decided to start a PR campaign to defend...wait for it...CO2. The ads are hilarious, especially the one on the left ("Energy")! (from Andrew Sullivan)

Random Jon Stewart quotes

Have a nice weekend!

1 comment

"burn baby burn" - poll
Mood: curious
Posted on 2006-05-17 09:07:00
Tags: poll
Words: 117

Iraq's Grand Ayatollah Ali al-Sistani appeared to renounce a fatwa calling for the killing of homosexuals "in the most severe way"...um, yay!

So Austin Police Chief Stan Knee is resigning to work with police in Afghanistan. He's had a good tenure here, although there were a few incidents that reflected poorly on the department. One such incident that happened a year or two ago was that a group of police officers, watching the Midtown Club burn down, text messaged another police officer "burn baby burn". People protested because of the other messages which seemed to celebrate the burning, and this one in particular, because of the racial undertones. That leads us to this week's poll:

*swoosh*

13 comments

trippy game
Mood: focused
Posted on 2006-05-16 08:54:00
Tags: weight
Words: 74

So last night gerdemb brought the game WeKatamari (the sequel to Katamari Damacy)...whoa. I had heard that it was weird, but wow. Just watching it is pretty awesome :-) Watching that Katamari roll over small things, then fences, then children, then cars...good stuff!

So phase one of my weight plan is going well - lost weight this week, and I only need to lose .4 pounds to get down to a new low. Here's hoping!

8 comments

brain dump
Mood: hopeful
Posted on 2006-05-15 09:56:00
Tags: ruby palmtogooglecalendar politics
Words: 957

Man, I have a lot of things on my mind!

So Prop 6 passed here in Austin (allowing the city to give health benefits to same-sex couples). I gotta say, it feels really good to finally win on a gay issue here in Texas. Yay!

djedi and I went to his brother's graduation in College Station Saturday morning. It was nice, although the ceremony itself was fairly boring (naturally) and it was fairly chilly inside. We went out to lunch afterwards and we got to meet his girlfriend, who was nice. I also took a toooon of pictures that I need to sort through at some point. A&M wasn't too scary - they say "Howdy" a lot (I could get used to that!), and there was some whooping, but it's all good. wonderjess graduates next weekend, so I'll be flying up to sunny (and hopefully not too cold!) Rochester on Friday.


So, going into the weekend the backend was written mostly (I could update my google calendar by running a ruby script from the command line), so I needed to put a web interface on top of it. This was tricky for a number of reasons.

First of all, the way I have to do authentication with Google right now, I have to ask for the user's Google username and password. They're working on a different way to do this, but for now this is what's required, so I wanted to make sure the page was using HTTPS to collect that information. I set up a certificate (that I signed myself - not worth paying $50 or whatever it costs to have someone else sign it) and after a few hiccups, got things working.

Then I started thinking about how this was actually going to work. The problem is that deleting and adding the entries will take at least 30 seconds, and sometimes much more, so I wanted an asynchronous way to do it. I had read some stuff about Comet, which is a bleeding edge application model. Basically, the idea is that the client opens a long lived connection to the server, and because of this the server can push back data whenever it wants (which isn't possible under normal HTTP). This sounded perfect, because I could connect to the server when the user pressed "Upload", and the server could send back progress updates while it was working, and have the client close the connection when it was done.

So, great. There are some problems. One is that web servers that aren't aware of a Comet-like approach don't scale this approach very well - having lots of connections open for a long time. That's OK for me, I'm not worried about too many people using this thing all at once :-) The other problem is that apparently it's hard to get working correctly. It was hard to find easy to understand examples that actually use this approach, and the one that I did find and understand relied on having the server basically return a text stream that gets progressively updated. I could not for the life of me make this happen correctly - it would wait until the whole thing was done, then display the whole stream, which obviously wouldn't work. I looked around for some other way to do this, and found a Mozilla/Firefox-only solution which was no good. So finally I threw up my hands and gave up on Comet for now. Maybe I'll take another look at it in the future.

So, I decided that the request to upload would finish quickly and return a session ID, and the client could call a script to get the status of that session every few seconds, which would simulate the same effect. This required some way to share session data across ruby processes, and CGI::Session turned out to be perfect for me - it by default stores session data in a file, so I can just read that file when I receive a request to get status.

Another problem was uploading the Datebook file itself - it's easy to do this using a normal HTML form, but because of security restrictions, Javascript can't read files off of the local drive (which makes sense...). So I couldn't use my normal trick of having the "submit" button have an onClick handler that sends the request, because that handler couldn't get the file data. Instead, I found out more information about the hidden IFRAME technique (which was used to do XMLHttpRequest-like things before XMLHttpRequest existed), so I'm having the form do a POST with its target set to the hidden IFRAME. This works well and I can receive the file on the other end - now I need a way of getting the session ID returned to the IFRAME to the parent document (the link I found this morning and looks like it will work well).

I was also baffled for a while that I was receiving the file correctly, and processing it with pilot-datebook, but the resulting file in longtxt format wasn't showing up. After butting heads with the problem for a while, I realized that I was using Tempfile to generate a temporary filename, but it was deleting the file as well, so that was an easy fix.

So most of the hard problems have been solved - I still need to do the processing and integrate that with status reports (and abstract that part out so I can still use the command-line version), and I need to handle errors better (at all :-) ), but I'm very happy with where things are right now.
...in short, things are going well.

Apparently having the NSA intercept domestic phone calls was Dick Cheney's idea, and NSA lawyers were against it.

51% of people disapprove of the domestic spying.

4 comments

friiiiiiday!
Mood: okay
Music: "Super Mario Galaxy" music
Posted on 2006-05-12 14:12:00
Tags: movies politics
Words: 406

Thank goodness. This week...not so good.

Why I love Fry's: the storm last Thursday night knocked out our wireless access point. So Wednesday after I work I popped over to Fry's to get a new one. After looking around for a while, the cheapest one I found was $70, and for that price I could get a wireless router, so I went ahead and got that (the last time our router died, we had an access point, so we got a router without wireless for about the same price, which was dumb). Aaaand I get to the register, and it's only $50! Unexpected price cuts - that's the way to go.

Video of Super Mario Galaxy - ooooooo I want this game!

We saw Harry Potter and the Goblet of Fire in Republic Square Park last night (hosted by the Alamo Drafthouse's Rolling Roadshow). It was nice, and the sound was turned up compared to last year so we could hear better. Lowlights were it starting an hour after they said it would (because it wasn't dark enough), lots of people smoking around us, and some jerks next to us who came in maybe half an hour in and started talking to each other (normal volume, mind you) about random crap. After 10 minutes or so, I said "shhh" and wildrice13 told them they were bothering us, so they left (and maybe apologized - I played the role of the person who doesn't interact with them). Oh, and Ben & Jerry's had a cart there so I got ice cream :-)

Tomorrow's David's brother's graduation, so we have to get up early early to make it to College Station by the time it starts. Oh, and Austin folk - don't forget to vote tomorrow! (vote for Prop 6, which would allow the city to give same-sex benefits to city employees)

(ooo, Firefox just crashed, but restored my almost-finished post. Woohoo!!)

Anyway, here's more information about election day, including polling locations and text of proposed amendments. I recommend yes on Prop 5 ($100 is way too low a personal limit to contribute to campaigns) and 6. I'm honestly not sure about Props 1 and 2 - need to read a bit more about them...

Also, I've been really really in the mood to program lately (at least for at-home projects). I'm not sure whether to give in and program a whole lot, or try to do other things until the urge passes. We'll see...

2 comments

aww yeah
Music: Pink Floyd- "Hey you"
Posted on 2006-05-10 09:51:00
Tags: pictures weight links
Words: 128

So after the weekend where I ate lots of bad stuff, I was sure I was going to gain at least a pound. Flash forward to Tuesday morning....I step on the scale...plus .2 pounds! Awesome. So my goal this week is to lose weight, and next week to get below my low since I started in December (I'm only .8 pounds away, so this is very doable). Woohoo!

Some fun Daily Show videos: Hayden/Goss and "Oh, Really? bin Laden? Who?". Well done! Also a fun trailer for a "Pac-Man" movie made by Uwe Boll.

I put up the pictures from last weekend. Cute pictures of the nephews :-)

Fun information about US interstates. (thanks medryn)

Oh yeah - here's the Onion's preview of summer movies. (hint: they're not terribly excited)

0 comments

weekendish activities!
Mood: blah
Posted on 2006-05-08 09:59:00
Tags: dallas ruby palmtogooglecalendar
Words: 475

So djedi and I went up to Dallas this weekend to visit his sister and two nephews. I had a good time, despite the long drive and somewhat awkwardness (since I don't know them too terribly well). The kids are really cute, though, and they were pretty well behaved. I played with the older one (Donovan) a fair bit and he called me "Uncle Greg" once near the end, which really made me feel good. Man, I don't know how they keep up with them - they're ages 5 and 3 and bursting with energy!

I did take some pictures, but didn't have time to put them up last night. Maybe tonight...

Saturday night we went out to see "Ice Age: The Meltdown" which I wasn't terribly impressed with. It was clearly aimed at kids, but unlike "Shrek" and, oh, every Pixar movie made so far, there wasn't much there for adults. I chuckled a few times, but that was about it. The kids really seemed to enjoy it, too - they're old enough to mostly sit through a movie at the theatre, which is neat.

I hate Dallas. This is not news to many of you, but there it is. While driving up there, I discovered another reason I hate it. So the interstate system has some pretty neat features, one of which is that interstates ending in 5 are roughly parallel across the country (i.e. I-5 goes through California, I-35 and I-45 go through Texas, and I-95 goes along the East Coast, etc.), and interstates ending in 0 are the same thing, but east-west (i.e. I-10 goes through Texas, I-90 goes through, erm, North Dakota or something). However, Dallas totally screws this up - not only do I-35 and I-45 meet in Dallas, so do I-20 and I-30! It's making a mockery of this beautifully designed system. Screw you, Dallas! (the floor is open for more reasons to hate Dallas)

Ooo, might Futurama be coming back?

So I stayed up late last night and made some more improvements to my Palm to Google Calendar importer. I fixed some irritating timezone issues (thanks to the TZInfo module) and, instead of deleting all existing events and adding all new events, now it compares the new ones with existing ones and only deletes and adds ones it needs to. Sort of like a diff/patch type thing. I also went ahead and split up repeating events into individual events so the calendar could handle it - hopefully they'll fix that someday and I can go back. Anyway, once I improve the Palm parsing of events, it'll be pretty much feature-complete and I'll put a web interface on it so anyone can use it. (at least maybe fairydust1 will find it useful) But even if nobody else does, it's very useful for me, and I'm learning more about Ruby and such. Whee!

14 comments

Go earlier/later

This backup was done by LJBackup.