Hung Truong: The Blog!

  • July 22, 2008

    Neat iPhone App: Shazam!

    Let me tell you a little story.

    While on my drive back from the grocery store today, windshield down and blasting some “Of Montreal,” I overheard some sweet tunes coming from a truck during a red light. Instead of yelling at the driver for the name of the tune (he might not have known anyway), I turned off my radio, fired up this app, Shazam, and held it out the window for a few seconds. The app came back at me with the song title, artist, and other junk:

    Pretty cool.

  • July 19, 2008

    Bat Attack!

    Less than 4 hours after writing about The Dark Knight, revenge struck in the form of a bat flying around in my apartment. I'm not sure if this bat was sent as punishment for me not going to see Dark Knight again or what, but it freaked me out! It flew around the living room for a while, terrorizing me, then went to other parts of the apartment. Then it kinda crawled around on the ground for a while. I think it was trying to hide or look for high ground to start flying again.

    Then I hatched an ingenious plan to open a window and have the bat fly out of it! It worked!

    I really have no idea how the bat got in, since the only windows open were the ones with screens. Maybe the bat squeezed through one? Or maybe it was a lame assassination attempt? We may never know the truth!

  • July 18, 2008

    The Dark Knight: In IMAX!

    I went to see The Dark Knight in IMAX last night. It was pretty good. I mean, as far as movies go it was probably one of the best I've seen in years. But there was so much hype leading up to it that the movie was kind of wasted. My co-workers were really psyched about the movie. So listening to them continuously talk up the movie had its effect on me, I guess. If I had come in with no expectations, the movie would've been incredible. It still was, and it met the hype, but sometimes I feel the best way to go into a movie is with no expectations at all.

    When I went to see Wall-e a few weeks ago (or maybe it was just last week), I had no idea what the movie was about. Okay, so I knew it had a robot in it. And that was about it. I ended up enjoying it a lot! I think we, as viewers, should just let the damn story tell itself. No spoilers, no trailers, maybe just a title.

    Knowing as little as possible about a movie going into it probably gives the best chance for me to enjoy it.

  • July 15, 2008

    Hardcore Rails/Server Troubleshooting Session!

    So early last night, I noticed that one of my sites, Anime Nano, was flipping out and throwing 502 proxy errors. I tried to do some simple troubleshooting but it seems as though the problem came very suddenly, and I figured it might go away very suddenly as well. The thing about this particular problem was that I had made no changes to the server. So the problem should fix itself! Unfortunately, life is not so simple.

    When I woke up in the morning, not only was the site still throwing errors, it was also affecting my other websites as well. MapsKrieg, Notecentric, Basugasubakuhatsu, etc. So I figured I should find out what is going on. I sent a support request to MediaTemple, my host, in case it might've been something on their end. It took a while for them to reply, but they eventually just told me it was something taking up all the memory and that I should try to optimize the site. Not too helpful. But I don't really expect MediaTemple to provide this kind of support anyway. And it turned out it wasn't their fault.

    Upon closer inspection, the site was really behaving weird. I could tell by the logs that the site was actually rendering things, but it always took about 189 seconds. This was odd. I've had experiences before where the rendering took less than a second but the page still took more than 3 seconds to load. But 189 seconds! That was a bit too much.

    I had suspected it was something to do with the mongrel cluster that I had set the site up to run on. Basically, I followed the script that MediaTemple provided and I still don't have a great understanding of how mongrel cluster works. That's definitely bad.

    I tried stripping the view of everything but the content for layout. I got rid of before_filters and tried running the site on the mongrel clusters as well as the webrick server on port 3000. The same thing happened. It took way too long for the site to load. Thinking it might be easier to test on my local machine, I got the site and database from svn and mysql and, strangely, it worked fine on my PC.

    Now things were slowly fitting together. I was reminded of a post that someone made on Anime Nano about how their feed wasn't being aggregated into the site. Apparently their feed was unreachable from my server. I had previously chalked this up to weirdness on their server, but I wondered if it wasn't a problem on my server. The thing about each pageload taking almost exactly 189 seconds pointed to a timeout issue. Then I realized there was a piece of code in Anime Nano that I hadn't written. It was a plugin for Text Link Ads that I used for some ads on the bottom of the site. That plugin was grabbing a feed of ads and parsing it to show links automatically on the site.

    If their site was unreachable, it's possible that Anime Nano was just waiting on grabbing that snippet of code and timing out. And that's exactly what happened. I commented out the text for the ads and the site immediately started working again. I'll have to look into how I can prevent this from happening again before reinstating the ads.

    So what did I learn from this whole experience? You should probably understand how code works before randomly integrating it into your site (I added that code a long, long time ago and forgot about it). Also, relying on a third party to provide some information before loading your site is just plain stupid. I can't believe how badly thought out I had made the organization of the site.

  • July 14, 2008

    Wii Fit: Fun With Linear Regression!

    So I've been playing Wii Fit for a while. One of the really neat things about the program (it's not really a game, right?) is that it automagically graphs your progress as you lose weight. It's pretty nice getting positive feedback when you put hard work into something. I think this is one of the very well thought-out features of Wii Fit.

    Anyway, I was looking at my weight going down and figured I'd do some rudimentary linear regression on it. I'm pretty much just eyeballing it because I don't want to throw stuff into R or Matlab. It seems as though I'll reach a threshold (away from Obesity) around the end of August. Though I'm basing this on a linear fit. It's possible that the actual plot will end up looking more like a power law since it's easier to lose weight when you're way overweight. The point is, I'm losing weight and it's nice to try and see when I might reach my goals.

    I also think it's worth noting that Wii Fit seems to overestimate my weight. Because when I use my bathroom scale my weight is always lower than what Wii Fit says. I guess I could adjust the “weight of clothing” but since I always pick the same thing I don't want to mess with the consistency.

    Now, if Nintendo had programmed some regression in automatically, I'd have to give it a 10/10 for science! But for now I'm pretty happy with just the graph functionality. It's fun seeing large local fluctuations with a general downward trend. Now, if I can only keep this graph from turning into a parabola like with my DDR Diet…