Tag java (2)

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

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

This backup was done by LJBackup.