Rambo is the collective memory of all those people like us, who were born in 60′s and 70′s.

In the old days, when we were teenagers, the world was simple, black and white. There was a sarcastic truth, the American side was always the right side in imported movies, while wrong side in state-owned TV news channel. But it didn’t bother us at all. We were trained to switch our roles without second thoughts.

I can’t imagine why Stallone can still have the courage to produce such non-mainstreamed movies. Didn’t he know the time had changed? Now there are always hostages and kidnappers. You want to be the good guy, you can’t avoid hurting those hostages. It’ll be much more simple to switch to the opposite side with the bad guys. To make it worse, kidnappers can become hostages, and vice versa. Some hostages are kidnappers at the same time, depending on which view you wanna take.

In 1990, an English teacher, Susan, who was from America, was standing in our classroom, asking which movie is our favourite. Rambo! There was no other option. When Susan finally understood which movie we were talking about, she responded with one word: STUPID. We were all appalled, and langhed. We didn’t know, or care, why she thought so.

Truth is not always the only thing we seek while watching a movie. It could be entertainment, old memory, porn or just a political assignment. In The Expendables, I got the old memory of 80′s back. And we need some indulgent moments to make such assumption: Hell with the reality. Let’s assume all good guys are pure good, and bad guys are pure bad. Just shoot.

After the long and frustrating bug tracing of my android program, I think I’ve some idea about how sqlite and android control the version of its database schema.

At first, I guessed the version number is table-basis, i.e. you specify a version number for each table, and the android program will check the version number to decide whether this table needs to be altered. I was wrong. The android program use the Pragma, user_version, to do the version tracking. Since the db is exclusive to each android app, so this parameter is used to reflect the db schema version of each app.

Let’s see the whole process. When the SqliteOpenHelper class creates the table, it receives a version value and set it to the pragma “user_version”. Next time it receives another version number, it checks it with the existing version, which is retreived from that pragma. If the existing version is lower, it will call the appropriate method to alter the table, then update the existing version. So when any table wants to change its schema, it needs to specify a version number higher than the current one.

That’s pretty straightford, huh? It is until we need to modify multiple tables. Of course it depends on the approach we use to upgrade our db schemas. In my case, I create a helper class for each table. So if I wants to upgrade two tables and provide the same version number for both of them, the first one got upgraded will set the version number after the finish of upgrade. That’ll prohibit the 2nd table from upgrading, since the two version number are equivalent now.

When the Chinese government blocked foursquare.com, I downloaded a tiny zip file, in which there were only a handful of php and apache config files. It made my 4sq app on android cellphone work again. I skimmed through the source code. It’s pretty simple, just a comple lines to implement the request redirect function.

I found my Twip proxy for Twitter didn’t work anymore. It’s already the latest version. I looked like there was little I could do. And suddennly the 4sq proxy came to my mind. Hey, maybe I could modify it and use it for twitter.

And it did work. All I needed to do is just change the value of the api url to twitter’s url, and config a subdomain for it. It worked breezily!

Here is the source code of the two main important files:

1. .htaccess (the apache config file which lets 4sq.php process all the request):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . 4sq.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>

2. 4sq.php (grabs the request, and redirects them to the real receiver):

<?php
$file_name = ’4sq.php’;
$api_root = ‘http://api.twitter.com/’;
$request_uri = $_SERVER['REQUEST_URI'];
$pos = strpos($_SERVER['SCRIPT_NAME'], $file_name);
$path_component = substr($_SERVER['REQUEST_URI'], $pos);
$curl = curl_init();
$headers[] = ‘Connection: Keep-Alive’;
$headers[] = ‘User-Agent: FxxkGFW’;
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
curl_setopt_array($curl, array(
CURLOPT_URL => $api_root . $path_component,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_USERPWD => “$username:$password”)
);
if ($_SERVER['REQUEST_METHOD'] == ‘POST’) {
curl_setopt_array($curl, array(
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => @file_get_contents(‘php://input’)
));
}
$result = curl_exec($curl);
curl_close($curl);
?>

Pretty old post, but still worth jotting down:

  1. Don’t reinvent the wheel.
  2. Use open source.
  3. Automate everything.
  4. Design for scale – plan to be lazy from the start.
  5. Design for hardware manageability.
  6. Use good cluster management software – don’t dig wells with teaspoons.
  7. Use open source monitoring solutions.
  8. Control your users with a queuing system.
  9. Verify you get what you pay for – benchmark it!
  10. Manage cluster communication.
  11. Look for ways to become lazier.

Source

I’ve released my new Greasemonkey Script, ClassicRetweetFor163Weibo, today. It took me two days to finish the first version, starting from last noon.

I barely remembered the tricks of GM, so I had to read the book again, partially. The developer of 163weibo uses very complicated javascript library, which injects event to DOM elements. It’s difficult to find those snippets deserve my attntion. But anyway I did it.

And on Sean’s demand, I improved it a little bit. Now it uses the standard opost input box to retweet. ^_^

[extract from book Version Control with Git]
Tracking the renaming of a file engenders a perennial debate among developers of
version control systems.
A simple rename is fodder enough for dissension. The argument becomes even more
heated when the file’s name changes and then its content changes. Then the scenarios
turn the parley from practical to philosophical: Is that “new” file really a rename, or is
it merely similar to the old one? How similar should the new file be before it’s considered
the same file? If you apply someone’s patch that deletes a file and recreates a similar
one elsewhere, how is that managed? What happens if a file is renamed in two different
ways on two different branches? Is it less error-prone to automatically detect renames
in such a situation, as Git does, or to require the user to explicitly identify renames, as
Subversion does?
In real-life use, it seems that Git’s system for handling file renames is superior, because
there are just too many ways for a file to be renamed, and humans are simply not smart
enough to make sure Subversion knows about them all. But there is no perfect system
for handling renames…yet.

First of all, Google Reader is not for everybody. It’s not as simple as iPhone. Users need to be intellectual enough to grasp it, though they don’t have to be smart.

Secondly, it has built-in support for Chinese user to work around the GFW. The only thing you need to do is always using it through https. What’s https? Please refer to Rule No. 1.

Everything you do will be stored in cloud-side. You don’t need to worry about system reinstallaion and hard disk failure any more.

And it’s social. You can share good stuffs, and know what your friends are sharing.

And it’s mobile ready. Actually reading on mobile phone is more fun.

My routine data backup happens every 3-6 months. I zipped the “My Documents” folder and put it on the hard disk of my home desktop. That was what I did before.

I replaced my desktop with a Sony notebook last year. I didn’t bring the notebook out of my home. So it worked just like a desktop, until lately I started to use it as my working notebook and installed a Debian on my old office desktop.

What about my data backup? I put them on a portable hard disk. The problem is: the portable hard disk is carried with my notebook in the same backpack everyday. So, I put all my eggs in one basket.

I found out this fact this morning. The first response is taking out the portable disk and leaving it at home.

Backing up data is boring, though important. I heard the prodoct Carbonite many times in Twig show. It’s an automatic online backup product. It sounds good. The only problem is its price, which is a little bit high.

Gonna try it and compare it with Dropbox.

Malcolm Gladwell’s book is as good as always.

I’ve been reading the book, What the Dog Saw, these days. It’s good, though the beginning chapter did confuse me with those hair style stuff.

The dog training part is informative. Since I have a dog, Gerald, who is quite willful. I know what those dog owners feel. I also know discipline is the missing part. Gerald is paying attention to us all the time, that’s so true. Not like Alpha, our cat, who only pays attention to us when he feels like it.

The second section is more illuminating. He talks about the difference between puzzle and mystery. I never gave any thought about their difference. But I did have experience of being inundated by too much information. I like the story of Enron.

I’ll definitely finish this book. Mayby consider buying a book mentioned by the author, Conspiracy of Fools: A True Story (Paperback) by Kurt Eichenwald Conspiracy of Fools: A True Story.

“Buy once, read everywhere”, I love this statement of Amazon Kindle.

I’ve used Sony Reader for a year. I chose it over Kindle because of its touch screen. Double-tap to look up words is a good feature.

Then I saw Kindler for PC, Kindle for MAC. I didn’t get Amazon’s idea until I installed Kindle for Android lately. Yes, that’s “buy once, read everywhere”. The most annoying thing of DRM is the binding to device. Digital is supposed to be read on multiple devices. What’s the point of binding to one?

Amazon knew this. It sees itself a platform, rather than a reader manufacturer. Sony is still a manufacturer. If it wants to get its slice in the ebook market share, do something. Ditch the stupid DRM.