Hung Truong: The Blog!

  • 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 13, 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…

  • July 11, 2008

    iPhone 3G GET!!!!

    So after a few false starts, I have an iPhone 3G that works.

    The journey was a long one; at the end I grew weary and lost faith. But finally, I have a neat iPhone 3G that does cool stuff.

    It started this morning at around 5:30. I woke up (though I only got like, 3 hours of sleep since I had taken a nap earlier and messed up my sleep cycle) and took a quick shower. No breakfast. Just took a vitamin water (these things are kinda good!) and a coffee granola bar for energy.

    Gaurav (from Troubadour Mobile) picked Adam (also from Troubadour Mobile) and I up. We drove to the mall and saw a bunch of peeps. We also saw some officemates from CampusRoost (yes, that’s a slick mention!). They told us that the AT&T store on Liberty had like, zero people and we should go there.

    When we actually got to the AT&T store, it was around 6:30ish. There were actually about 30 people in line. Apparently everyone showed up around 6:15 or so. There was a really cool line wrangler named Steve that kept everyone reasonably informed. We found out there were like, 40 phones. So we should be able to get one. Adam and Brent didn’t want to settle for white ones. Or 8GB ones. But I think eventually Adam got a black 8GB and I dunno what Brent did.

    At 8am, the line started moving, and it was moving well. But then disaster struck! It seems either Apple or AT&T didn’t have the resources to take a billion people in the US all wanting iPhones at the same time (and having to activate them in the store). The activations were apparently taking around 45-50 minutes each when they should’ve taken 15 or so.

    Eventually, the AT&T people let us just do most of the steps in store and then activate at home. By the time we were done, it was about 11am. I went home and tried to activate the thing for about 15 minutes. iTunes was just being bad. So I went to sleep. I woke up at around 2pm and tried to activate again. This time it worked after about 30 minutes of trying.

    I’ve been loading up apps and trying them out. It’s pretty cool. My favorite so far is the PhoneSaber.

  • July 10, 2008

    Mega Man 9 on WiiWare. AWESOME

    So I read that Mega Man 9 is coming out on WiiWare. Cool. But then I realized it was Mega Man 9 and not, say, Mega Man X or Mega Man Battle Network. It’s MEGA MAN! The old school one!

    I remember getting Mega Man 1 (still have it) for the NES after getting 3. I think the second one is probably still the best, what with Wood Man, Heat Man and Bubble Man. Geez, Bubble Man was so awesome!

    It’s amazing that Capcom is actually making a new Mega Man game with NES style graphics. I think the only reason this is possible is that digital distribution (Wii Shop channel, PS3 Store, Xbox Live) makes it extremely cheap to distribute. I imagine an 8-bit game costs less to develop than, say, Grand Theft Auto 4. So Capcom should be able to make its money back through nostalgic fans.

    I, for one, will probably be getting it. Depending on my level of nostalgia vs. the price of the thing. I remember the NES Mega Man series kind of jumping the shark anyway, when they started running out of “Men” to use. Seriously, Pharaoh Man? CLOWN MAN!?

    I hope the bosses are a bit more original and kickass this time around.

  • July 05, 2008

    The Google Shirt of Hostility

    So a while back I scored a free Google shirt (my first of many). This was while I was at the University of New Mexico, where the school colors are “Cherry” and “Silver.” The shirt itself was red with white text. Kind of like this cup (I couldn’t find a pic of the actual shirt, and I didn’t want to take a pic of it; it’s kind of faded now):

    Just imagine that cup in shirt form. Anyway, the shirt colors fit the UNM colors. Pretty sweet!

    Now fast forward to… now. I’m at the University of Michigan, and our colors are “Blue” and “Maize.” Our sworn enemy, Ohio State, has the colors of “Scarlet” and “Gray.” Which is basically the same as my old school’s colors. Kind of hard to disassociate with. Anyway, I’ve noticed that while walking around with my red Google shirt on, people seem to give me more dirty looks (than usual). Like I was at Meijer last week and I could’ve sworn I noticed some hostility.

    I figured the Google shirt (remember, imagine the cup above as a shirt) reminds them of the Ohio State shirt:

    That might just be my crazy theory, but I think it works. I’m sure from a far enough distance, the red Google shirt could look like the Ohio State shirt. And I’ve given my fair share of dirty looks to people wearing Ohio State stuff in Ann Arbor. How dare they, right?

    I think it’s time I get a blue and maize Google shirt. What say you, Google?