Peaceful Revolution

a computer scientist’s thoughts
RSS icon Email icon Home icon
  • On Google’s quitting China

    Posted on January 14th, 2010 Eric 6 comments

    Maybe I should say something on this issue since I have done a lot of thinking about Google’s strategy in China since the first time they entered China. I have to make a disclaimer that I am Chinese, and I don’t agree with Google’s self-censorship in the first place.

    To make long story short, let me briefly review how the censorship works in China. For every website that offers services in China, a so-called “ISP license” is required. However, the government will revoke your license if it thinks that you are not so “manageable”, and therefore you have to shutdown your website (or they will block you if your servers are abroad). When Google first entered China, Chinese gov didn’t give it a license, and banned the access to Google.com from China since its search result was uncensored. To make the service available to Internet users in China, four years ago, Google started to filter the search results and provided them via Google.cn. Google.cn is a domain name registered in China. Google is just one example among many Internet service providers that do self-censorship.

    Every website in China, if their servers are in China, do self-censorship. Otherwise, secret-police will unplug your server cable and put you to jail if necessary.  As you can see, by restricting the service provider’s license and setting up the Great Firewall to restrict the access of Internet users, Chinese government literally set up a panopticon so that the prisoners (users and service providers) can watch each other and have to do self-censorship to survive.

    However, Chinese government was still not satisfied with what Google had done. They want to have full control of Google. During these years, say, pretty much once every year, Chinese government and the state controlled media would criticize Google for something that “is not legal according to local laws” and would suggest a solution with no surprise: tighter self-censorship. For instance, last year, they tried to flood Google.cn with some obscene keywords so that those keywords would be high frequent enough to enter auto-completion system. Then, they made a TV program showing that when you type in “son”, Google search box would hint you with “son and milf”. On that program, they were criticizing Google for “helping distributing pornography”. In one word, Google has been under a very high pressure doing business in China. Chinese government
    always wants Google to be its homeboy, which we obviously know Google’s response: No, simple and straight.

    I do agree that Google’s market share in China is not good enough, so I don’t think Google will lose any revenue substantially by quitting China’s market. China now is different than 10 years ago. Even it looks very nice from the outside now, it is extremely corrupted inside. Maybe I am making an oversimplified statement, but the truth is that no private business, not a single one, with proper moral standard, can make money in China. The reason is fairly simple: it is a government controlled market instead of a free market.

    Essentially, the market is controlled by the government and you have to “pay” for “using” the market. It sounds crazy since according to Adam Smith, nobody can really control market, the hidden hand. But currently, seriously, Chinese government, with a huge visible hand, is able to. Being a country with very high tax rate and secret police everywhere, the government has a much higher controlling power than that we would
    normally think of over the domestic market. It can simply kick the player out, or arrest the player, if that player doesn’t obey those so-called rules. Google is one of the victims.

    As a totalitarian state, it naturally needs some common bonds to control people’s mind. In China, insofar, the best mind weapon is called nationalism. Chinese government, intentionally or unintentionally, make some netizens believe that Baidu is a local company and it is a good kid, while Google is controlled by “westerners” and also is a bad kid.

    I am not concerned about Google’s losing money in China. In modern society,  some business might be able to earn money in a country without free speech, free market and democracy; some business might be able to earn money under a big government. However, in a country when tyranny is combined with big government, which we usually call totalitarian state, no private-owned company can make any profit if
    its moral standard is not compromised. The history in the last half century has provided so many examples.

    Also, I am very optimistic about the future of Google’s business in China. Again, i
    I strongly believe that Google will return to China on the day that China becomes a democratic nation where all citizens enjoy proper human right protection. Then Google will dominate China’s market, since it is really a superior service and there will be fair competitions.

  • Fix Latex-beamer

    Posted on November 2nd, 2009 Eric No comments

    A recent upgrade of latex on my Debian/Ubuntu caused some problem on compiling my latex-beamer slides. Latex reported that

    l.17 \pgfdeclareimage[
    width=14pt,height=12pt]{beamericonbook}{beamericonbook}
    You’re in trouble here.  Try typing  <return>  to proceed.
    If that doesn’t work, type  X <return>  to quit.

    According to some posts on the forum, it is because the latest version of latex put pgf package to core. Thus, the original pgf package become obsoleted.

    To fix this, you can just go to your latex directory and remove the whole pgf directory. On my machine by default, it’s

    /usr/share/texmf-texlive/tex/latex/pgf

    remove this and the problem solved.

    I wrote this because I found no explicit solution on the Internet. I tried a couple of times removing different pgf packages (they are scattered in more than one places) and finally found this solution.

    Happy hacking.

  • [Rant] Springer sucks

    Posted on September 7th, 2009 Eric 1 comment

    First, LNCS is a place where 90% of the papers are not worth publishing. They are just the enemy of trees and the first cause of global warming in academia.

    Second, it does not support the bibtex format exporting. Who the hell wants your RIS format citation?

    For every citation from Springer, I have to spend 3 minutes in reformatting everything to a bibtex format. For those terrible papers I have to cite (some of the reviewers are so stupid, they force us to read a paper in LNCS, saying that our work would be complete without noticing some “significant” work published in a workshop held in the middle of no where in Europe by a group of unknown people. Come on, if you have some self-respect, you won’t want people to cite your own f* work published in a f* bad conference talking about a f* terrible idea without any intellectual merit], I have to write a script to change it from RIA format to bibtex. What should I waste time on these stupid things. All other publisher like ACM and IEEE (even Citeseer) supports the bibtex format.

    Shame on you, Springer, your LNCS sucks!

  • Know your shell and GNU coreutils

    Posted on July 25th, 2009 Eric No comments

    A friend of mine was frustrated by the fact that in his bash, the `pwd` command gave him the following `unwanted` results:

    When he is in the directory `/usr/a`, pwd gives ‘/usr/a/’. In this directory, if he has a symbolic link ‘b’ pointing to /sys/b, then after using `cd b`, pwd gives him `/usr/a/b/` instead of `/sys/b`.

    What he wants is the physical/absolute path name as the result, but he can’t get that in bash. (Later we know that we have to use `pwd -P`, but this trick is not stated in `man pwd`, this is in `man bash`) He tried to consult man page, but man pwd redirects him to the man page of pwd in the coreutils, while using it in shell doesn’t give him the expected result indicated by the pwd command in coreutils . Strange, isn’t it?

    The problem here is that for commands like ‘pwd’ (and ‘cd’, ‘echo’, etc.), your shell will not actually start a process to execute these commands, instead, your shell has build in functions to do the job. If you consult the man page of pwd, there is one line in the man page stating:

    NOTE: your shell may have its own version of pwd, which usually supersedes the version described here. Please refer to your shell’s documentation for details about the options it supports.

    Aha! Blame the shell !!!

    Why your shell wants to replace the pwd from GNU? Well, the advantage this kind of replacement is that now you have efficiency, because your shell can execute the build in code without forking a new process. The downside is that, now you put your bet on the shell. If the shell behaves differently than you’ve thought, you are screwed.

    This is exactly what we want a platform independent tool set. For every Linux distribution, GNU coreutils is always included. If you force your shell to use the pwd from coreutils by typing /bin/pwd, you are insured that even on different platforms with different shells, all results will be the same.

    Some shell-dependent features:
    alias, echo, cd, printf, background/foreground process (& syntax), pipe and IO redirecting, env variable setting/accessing.

    Suffice it to say that you should know your shell’s behavior under some circumstances, especially when you want a consistent sh shell scripts behavior.

    Happy hacking!

    –EOF–

  • Using Arduino IDE without an Arduino

    Posted on July 16th, 2009 Eric No comments

    Arduino is essentially an AVR microcontroller interfaced with an USB/Serial chip to compter. It’s not hard to build your own arduino, and there are a lot of resources on the internet about this. See this.

    However, all these tricks requires you to buy an USB interface such that you can program your arduino. That small chip or cable usually costs you more than 20 dollars. For a cheap person like me, I don’t want to do that. However, the arduino IDE is really handy. I love to program in it, even though I use VIM a lot, I still want to use this IDE to program my AVR. So I really want to use this IDE such that I can upload the file to the arduino with one click. However, I don’t want to invest any money on the buying an arduino, since I know it’s just a uC with interface, and I usually use my uC in a naked way.

    I know that the IDE uses avr-gcc and avrdude.Avr-gcc compiles any thing into a standard hex file to the avr uC. Thus, the IDE didn’t do anything special here. The avrdude program supports way more programming methods to an AVR chip than the Arduino way (usb/serial). Thus, it is possible to make a cheap ass ISP programmer to the uC, and then modify the IDE such that it calls avrdude with the function you want.

    To make things easier, I give a very simpler version to make a cheap arduino (I will call it naked avr chip with battery included):

    An AVR uC, for instance, ATMEGA8L ($3 here? My uncle in China mailed me many. Pick the uC with suffix L, meaning a 3V voltage is high enough for it to work, you don’t need 5V. For using 5V, you might have to buy a 7805 regulator, which I don’t want to.)

    Some LED to test it. (Radio Shack, around $3 for 20, any LED will be good. They are cheap and robust, you don’t need transistors to protect them, or your uC)

    A 2-AA battery box (Radio Shack, less than $2)

    A breadboard and some jump wire  (ebay, 20$ for both, free shipping, find the best deal)

    You don’t need a 20Mhz clock and capacitors around it, you can just use the clock inside the AVR chip.

    —————–

    If you want to DIY an DB-25 ISP programmer cable:

    A DB-25 connector (male, you plug it to your computer’s parallel port)

    Some wire

    To see these simple steps to make a parallel port programmer, see this link:

    You can also buy one online, for like $8.

    Connect your ISP to your AVR correctly (you can find the instructions easily online), you don’t need any resistor or any capacitor whatever on the breadboard, seriously. Again, your AVR is robust enough to handle things under 3V voltage AA battery power. 3V voltage won’t destroy your LED either, so don’t even bother connecting your LED to a transistor (I know it’s suggested, but I just want to show you that you can be lazy here. Every transistor/capacitor on the breadboard will scare away half hobbists ).

    OK, here is the real hack.

    1. To burn the bootloader down, choose your board, and your cable (w/ parallel programmer, depends on your ISP cable), you can see that there is a menu item for it. You can see if it works. Mine doesn’t, because my cable is called stk200, and arduino assumes another interface. What I did was go to your hardware/tools folder, you will find avrdude there. I changed avrdude to avrdude1 and then write a bash script called avrdude and calls avadude. In this way, I use echo $* to see the command line passed to avrdude. I then changed the fifth option to -t stk200, which is my ISP programmer protocol.

    Actually it’s not that important to burn bootloader, especially everytime you actually use ISP programmer instead of using the bootloader. I write it here because I hacked it and in case you want to burn the bootloader for your AVR in Arduino environment.

    2. To upload. I tried to click the “Upload to uC with I/O” button in the IDE. It complains that there is no Serial port. Of course there is not, because I don’t use it :). I also found the exception stack saying something about AvrdudeUploader. Haha, that’s it. So, I checked the souce code out from arduino website using:

    svn checkout http://arduino.googlecode.com/svn/trunk/ arduino-read-only

    Then, you edit app/AvrdudeUploader.java, you will find a function called “uploadViaBootloader“, that’s exactly the function that IDE calls to upload the program. Here, comment out the String protocol = line, change it to something like

    String protocol = “your_protocol”;

    Assign it to the protocol you use ( for instance, I use stk200, or the parallel cable protocol). Remove the line with comment “don’t erase” (yes, erase it :), remove the whole “if (Preference.get…)” chuck, and remove the link that contains “upload.speed“, then go to the build/linux folder, ececute the make and dist script. It will create a folder called arduino-0016 something, and you can go inside to the lib/ director, copy all the “.jar” files to the install director of your arduion install directory.

    Now, do everything you want on your naked avr, using arduino IDE ;)

    (I quick tip, Arduino uses pin 13 as the default LED pin. It it used as SCK pin for the programmer, so, when you test “Blink”, you’d better use another pin, otherwise, unplug your programmer from the uC. The programmer draw sink the current such that you won’t see the blinking light.

    I will post some photos later about my hack.

    Happy hacking.

  • I am engaged

    Posted on July 3rd, 2009 Eric 2 comments

    I proposed to my fiancee last month. I was so lazy to add a post to this blog :)

  • How to fix your firefox (and other software) library not found error in Ubuntu

    Posted on July 3rd, 2009 Eric No comments

    I recently crashed my Firefox for no reason. I guess I accidentally removed the ia32-libs. However, when you install Firefox using apt-get, ia32-libs is not listed as the dependency. Therefore, no matter how hard you try, if you don’t have lib-ia32, you can’t use firefox, even though

     apt-get install firefox

    works fine.

    Anyway, here are some generic methods I’ve used to fix the “library not found” problem in using firefox and other pieces of software. In short, you have to use two family of tools.

    First step: Find the missing library file using ldd, objdump and nm

    The first family of tools is related you the dynamic linked library, it includes ldd, objdump and nm.

    Objdump and nm are from gnu binutls and ldd is from gnu libc. Usually, when your software complains about not finding a symbol or a missing library, you can generally use ldd to see the libraries required by your software. For instance, if your software executable file is called aaa and it is dynamically linked against some missing libraries, you can just use

    ldd aaa

    to see what are the libraries used by your software. You can use grep to filter the information you want.

    If there is a “.so hell” problem (you can find the library find you can’t find the symbol), you have to use objdump to see where is the missing symbol. Usually, you can google the missing symbol to decide the library that contains it. Anyhow, you have to first locate the library. “nm” servers a similar function. Read the man file and you will know how to use those three tools.

    Second step: locate the library file

    The second family of tools helps you to locate and get the library. They are apt-file. apt-get, gcc and Google.

    There are several possibilities for a library missing. The first is that you accidentally removed that. For this, the only problem is to find the package name that contains the missing library file. To do this, on Ubuntu, we can use a tool called apt-file. It searches all the packages in the apt repository and output all packages that contains the file name you entered. For install, if you want to find libxyz.so, you can just use

    apt-file search libxyz.so

    and it will output the package names that contains libxyz.so. There might be multiple packages, and usually it’s easy to try and decide which one is missing as if you’ve already had it on your machine, apt-get will tell you.

    Usually, you can fix your problem by installing the missing packages. But sometimes you have all latest package installed, and your software still complains about the undefined symbol. This is possible because your software may rely on an older version of the library and in the new version, some symbols get removed. For open source software, try to decide the version of the library file first, and then download the source code and compile it. Recently I crashed my gnome window manager, and it requires an older version of libxcb. I have to download the older version to let it work.If it is not the open source component, try to get a copy of the library file. Usually I will use google to find that file. Google is very good at finding files you need.

    That’s it.

  • Brute force English

    Posted on April 2nd, 2009 Eric 2 comments

    I reviewed a paper typesetted using M$ Word written by a non-native speaker, and I found a very good word called “brute force English” to describe a large category of mistakes people make in English writing with “audacity”.

    As you might know, Word is notorious in breaking paragraph into lines because it (a) uses a greedy algorithm instead of a dynamic programming algorithm to break the lines, (b) and never break the words to make nicer looking. For instance, if you have a long word, say, enterprise, in TeX, if this word makes the width of the line overflow and it’s also ugly to move the entire word to the next line because then you will have too much blank on this line, TeX will break the word to something like enter-prise with a hyphen in between them. However, Word doesn’t support this.

    OK, go back to the previous topic. In the paper I reviewed, the author has paragraphs like this:

    My fellow citizens: I stand here today hum
    bled by the task before us, grateful for t
    he trust you have bestowed, mindful of the
    sacrifices borne by our ancestors.

    Yes, he uses “line break within the word”!

    This aroused my curiosity: why is he brave enough to write this down? An alternative question is, why we, ESL writers, usually violate the rules in English writing and still feel confident?

    My answer to the above question is that, the ESL writers, when facing some confusing in writing, usually use the “brute force” way to write. For example, we will choose the word that means A in English to the blank where it really needs A’. Perhaps in their native language, A and A’ are similar,  but not the case in English. They will probably also use sentence patterns that resemble the patterns in the their native language, but not in English; they will “invent/borrow rules” that they wish or think to be correct; they will put words and grammatical structures down bravely, without consulting a book or a dictionary.

    I have the same problem. I am confident about my writing skill and style in Chinese, thus I will stick to the direct translation in writing. When I meet some phrases in Chinese that can not be translated to English directly, I will use brute force–inventing the almost-always-not-correct rules to reconstruct my sentence in Chinese to English.

    I think a good writing is definitely a mixture of style and language, and actually language is always one of the most the limitations in writing for ESL writer. We usually find that there are some rules, some patterns we want to use that are not in English but only exist in our native language. The right way is to overcome this limit is to use English in the English way, by more reading and practicing, instead of inventing rules to pass around it.

    If we use the set language, the point I want to make is as follows. English and our Native language are two different sets with some possible intersections,  but they are not the subset of each other. Therefore, we should not expect to find a one-to-one onto mapping from our native language to English, expecting that the results by using the mapping to the native language pattern (or some pattern in our brain which is a mixture of English and the native language, e.g. Chingish) is the correct English. More often than not, it is not the correct English.

    Note to myself: do not use brute force English, because it is not the right way to do English writing.

  • Generate Ambient White Noise on Linux

    Posted on March 11th, 2009 Eric 1 comment

    Here is the link for the software:

    http://pessimization.com/software/whitenoise/

    It supports frequency cutoff. I’ve been using it for a whole day, it is wonderful.

  • An incomplete idea on Linux–stdctrl

    Posted on March 10th, 2009 Eric 1 comment

    Linux command line tools connected by pipes are cool. However, everything disappear on the X11 environment.

    We should have a stdin-like file descriptor for each X11 application such that we can pipe control operations to them. In this case, we can automate firefox or other stuff all in a transparent and de-coupled way. For instance, to visit google, we can pipe

    Ctrl L

    www.google.com

    Enter

    to firefox’s stdctl, and firefox will visit google.

    There are some command line tools like “expect” that can send applications input, but it is not general.

    On MacOS, applescript can sort of accomplish the same goal.

    My idea is to redesign the shell such that it supports the stdctrl syntax. The shell will create the process using popen and then send control signal to them. (replace expect). Hopefully we can finally control firefox without using any firefox API, we can just send Firefox X11 level control sequences.