Thursday, September 2, 2010

New Adventure

Got a job, which I will be creating a resource based website using PHP and MySQL. This is going to be very challenging, not because of the languages itself, but the fact that I'm taking 4 senior courses at the same time.

Time to put my time management skill to test!

Saturday, July 24, 2010

Caution When Using Property in Objective-C

Objective-C 2.0 provides us @property/@synthesize to easily implement getters and setters. Today I encounter a problem. Here is the scenario:

@property (nonatomic, retain) NSMutableSet *tags;

This lets me conveniently call

self.tags = set;

which is equivalent to call all three below:

[set retain];
[tags release];
tags = set;


So here's what might bite you if you are not careful. Within the -(id)init method, never do (I can't think of a reason) something like the following:

self.tags = [[NSMutableSet alloc] init];

This line is basically 1)initialize an object for you, 2) pass the object through the setter that retain the object for you.

When you call init to create an object, retain count is 1. By passing it through the above property will increment the retain count to 2. When this object's dealloc method is called by the application-loop (you never call dealloc directly), the retain count become 1 but there's no pointers reference it. MEMORY LEAK!

So in this case, the correct statement will be simply

tags = [[NSMutableSet alloc] init];

because you don't want to use setter method here. I'm not saying to avoid using self. syntax at all. Actually you will be using it a lot. Make sure you read all the recommended guideline by Apple before diving in like me, who had wasted a lot of time debugging nasty-but-not-obviously bugs like this.

Monday, July 12, 2010

Bed Bugs Infestation (Update)

So the diatomaceous earth has come. I sprinkled it all over the place, especially around my sleeping area. My roommates did the same.

The result was great. I didn't feel much difference before and after (because my room isn't seriously infested) but my roommates claimed he could finally sleep at night. He told me he would turn on the light 3am only to found bed bugs on his mattress crawling away. After using the DE, he's now only seeing maybe one or two bed bugs everyday which is heck of a lot less!

Considering the fact that we only apply DE for merely a day, DE really works pretty well as in eradicating the bed bugs. People said DE is also for killing roaches as well so I also sprinkled DE everywhere in the kitchen. I really hope it works for roaches too.

I think I should wait few more weeks before buying myself a new mattress (I threw mine away). After all, DE does work. I used roughly 3 pounds for my 3-room apartment (I bought 50 pounds hahaha).

Saturday, July 3, 2010

Bed Bugs Infestation

Recently my bedroom is infested by bed bugs. It's not heavily infested, but i found and killed at least 5 adult bed bugs last couple days.

Almost 3 to 4 months ago, my roommates whose bedroom is far away from mine, first got infested by bed bugs and complained to me. I didn't think it is a serious problem, i thought they were dirty so they got bugs. At that time I didn't know what bed bugs are. I only know they suck my roommates' blood every night.

Until last week, I found spot on my arms, thinking I got bitten by mosquitos. But dang it, how come those spots formed a line. They looked like they are some kind of sign left by extraterrestrials.

To make it short, I got bitten by bed bugs. It's really a pain in the butt because they are difficult to be eradicated once you got it. I haven't had a good night for 4 days since I threw away my mattress. Now I sleep on chairs which all the legs are wrapped by super sticky double-sided tape.

I just bought a bag of DE (diatomaceous earth) at Amazon. All natural, non-toxic, food grade. I hope it works. I will write more about DE once I get it and try it out.

Sunday, June 27, 2010

New Blogger Template Designer, HTML5, Summer Class

The new template designer is pretty neat, although there're not many option to customize it, but the html editor is still there!

I noticed that the doctype is now "html", which means Blogger now uses html5! (Not exactly sure, I remember that it was xhtml)

Anyway, one more reason to love Blogger.

These few week I've been learning C# and wrote a small but useful tool for my uncle, while taking Statistics summer class everyday. One more week to go... but another class is coming right after. I really want to take a look at and learn HTML5. Hope after all these summer classes I could get started learning it.

Tuesday, June 8, 2010

iPhone 4 and the Gyroscope

This is remarkable. It might not immediately draw any serious attention from normal users, we developers know what it means to us.

If you not already know what a gyro (short for gyroscope) is for, check the Keynote video out on Apple.com now.

Have you heard of Augmented Reality? That's what I'm talking about. Without gyro, we can only depend on the not-so-accurate accelerometer to (try to) capture velocity. (Accelerometer is only capable of capturing acceleration, but not velocity, which means it doesn't capture constant speed). The big deal is here, if we hold the iPhone and rotate our body with constant speed, the Accelerometer has no clue on which direction we are currently facing, or it doesn't even notice we've changed the direction. Gyro completely changes the game of mobile gaming. Together with the compass, accelerometer, A4 chip and the amazing 326ppi Retina display, iPhone 4 has become a killer phone/gaming device.

This is huge. And I think it's one of the most important feature on the iPhone 4. Expect to see more AR (augmented reality) apps coming this year.

I might as well write one AR app, if I got spare time.

Monday, June 7, 2010

Apple Keynote 2010

One of the biggest event of the year, Steve Jobs will be standing on the stage giving us surprises. It's a no-brainer that a "new" iPhone will be introduce tomorrow. So what surprise(s) should we expect?

Last couple of weeks, there have been a lot of rumors about the new iPhone. Something immediately drew my attention: Jobs' email reply. Someone emailed Jobs asking about the event, as the "new iPhone" was leaked to the public, would the keynote event become less appealing this year... and the reply goes something like "you won't be disappointed".

Some said the iPhone was purposely leaked to the public, and Apple has prepared another iPhone model as a surprise.

It's gonna be interesting how this year's keynote will again make a remarkable point in the mobile history.

I'm not taking out the possibility that the event might be disappointing, though. So go to the Apple's website and check out the video tomorrow morning at 10am PDT.