Peaceful Revolution
a computer scientist’s thoughts-
An incomplete idea on Linux–stdctrl
Posted on March 10th, 2009 1 commentLinux 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.
-
Towards beautiful LaTeX
Posted on February 26th, 2009 2 comments(I will collect my random pieces of latex tricks here)
Several hidden tricks in LaTeX.
1. Text after italic text has a smaller blank space. To adjust that, you use \/ after {\it} group2. Always use ~\cite{} instead of ” cite{}” because the tilde symbol will prevent latex to have a line break here.
3. When you end a sentence with capitalized word, for example, if you want to say “I am a fan of NASA.” You should type
I am a fan of NASA\@.Otherwise the . will be considered as part of NASA acronym.
4. A tool called lacheck can help you find a lot of these common “uglies”.
-
Better than helloworld
Posted on February 19th, 2009 2 commentsI saw that on reddit:
while (1) if (1 != 1) printf(“cosmic ray detected\n”);
Obviously it doesn’t make sense in the first version, because a modern C compiler will usually optimize the code such that the printf part is not in the executable code.
However, here are some wonderful programs in the comment:
volatile int x = 0;
volatile int y = 0;
while (1) if (x != y) {
printf("Cosmic ray detected\n");
y = x;
}
OK, I have to say that this is a better version. And here is a geedy comment about this:
What if the cosmic ray comes during the execution of printf?
Concurrency issues, man. You’ll need a cosmic ray detector inside your printf statement there, which puts you dangerously into yo dogg territory.
LOL, I mean, seriously.
Some other funny comments:
The SETI source code has been leaked.
And,
I had a student in a class I graded for once write the following:
if(x)
....
else if(!x)
....
else
printf("Something is really messed up!\n");
My personal favorite is of course this:
while(!asleep()) sheep++; -
Access WUSTL vpn on Ubuntu 8.10
Posted on February 17th, 2009 2 commentsI have to say, WUSTL has a very good network, but it’s technical support sucks a lot.
1. To use the VPN of WUSTL Engineering school, you can go to this page and download the vpn client.
2. You can download the CISCO client for Linux, which is called
vpnclient-linux-x86_64-4.8.02.0030-k9.tar.gz.
3. Then you use
tar -zxvf vpnclient-linux-x86_64-4.8.02.0030-k9.tar.gzto extract the contents out.
4. Naturally, in the extracted folder, you want to use
./vpn_installto install the VPN client. However, it does not work.
5. You have to go to this page to download a patch file (the second one).
6. Copy the patch file to the directory that has vpn_insatll. Issue
patch -p1 < 4.8.02-64bit.patchto patch the file.
7. Use
./vpn_insatllto install the VPN client. Using the default parameters is recommended.
8. Use
chmod -R o-w /etc/CiscoSystemsVPNClient/
/etc/init.d/vpnclient_init startto start the kernel service for VPN.
9. Since wustl EIT didn’t bother giving you a profile, you have to create it of your own. Go to
/etc/CiscoSystemsVPNClient/Profiles, make a duplicated copy of sample.pcf as wustl.pcf viacp {sample,wustl}.pcf10. Edit the wustl.pcf and make the following changes (if you are using CSE VPN. For further information, visit http://eit.engineering.wustl.edu/help/VPN_setup.asp ):
Host=csevpn.seas.wustl.edu
GroupName=cse
Username=your_user_name11. Use
vpnclient connect wustl
to connect the VPN.
-EOF-
-
A good “big picture” about the stimulus package
Posted on February 17th, 2009 1 commentIt is the best diagram I’ve seen so far on describing the stimulus package.
Leave a comment if you find a better one.
-
Some understandings of mine about H1B
Posted on February 15th, 2009 5 comments1. H1B visa is a non-immigrant visa for foreign workers in the United States. Usually, half of them goes to high tech workers.
2. There is a quota for H1B visa every year. As far as I know, now the amount of visas issued every year is 65,000.
3. Professors/University employees (post-docs) are exempted from this quota.
4. Some Americans blame this policy for “taking their jobs”.
5. Some companies are willing to hire H1B workers because they can pay the employees less.
6. Some Indian companies even hold the visa quota, and hire some `slave’ workers who want H1B visas. They will contract you out and you get paid little. This is called H1B visa fraud.
7. In the stimulus plan, there is an attachment stating that employer must not fire an American worker and then hire an H1B worker to replace him within 6 months. This is a big nail on the coffin of H1B program.
Everything is tough in this season.
-
Some LaTeX tricks you might want to know
Posted on February 14th, 2009 1 comment1. TeX does not support multi-line comments. You can do a trick like this:
\newcommand{\comments}[1]{}Then you can use
\comments{ something }to make multi-line comments.% I learned this from my advisor.
2. Every time you use
\cite{}, make sure you use tilde (~\cite). This is from TeXbook. A tilde will prevent the line break between the text and the citation brackets.3. If you want to extract text from LaTeX, you can use
detex your_fileUse
sudo apt-get install texlive-extra-utilsto install tetex.
4. For spelling check for your LaTeX file, you can use
aspell -c your_file.tex -
Secret keeper
Posted on February 13th, 2009 3 commentsObviously, my girlfriend knows all the gifts I am going to give her tomorrow. I am usually an early bird in shopping for gifts, but not a good secret keeper.
Last Christmas, I knew that her mom would give me something, because her mom emailed her asking for gift ideas in an email titled: “Don’t let Eric see this”. I saw that title, thus, I asked her what my Christmas gifts from her mom were. She wouldn’t tell me. I threatened her by saying something like: “OK, then I will go to China to find another wife“; or “I will steal your baby penguins and sell them to a penguin serial killer“. She just kept her mouth closed.
Finally, one day, when she was half asleep, we had a conversation like this:
“Honey, will I get a T-shirt this Christmas? My T-shirts are so sloppy. ”
“You might.”
“What else?”
“I don’t know.”
“I will leave you for China.”
“O, NOEZ, a fluffy turkey. ”
“What?”
“Yes, a fluffy turkey. ”
“OK, if I don’t get a fluffy turkey, I will kill you.
”Then, she ordered a fluffy turkey online and asked them to ship it to her parents’ house. I got a fluffy turkey, on Christmas, Yes, a stuffed turkey, on Christmas!
Anyway, she is a good secret keeper, and I am not.
-
Lincoln’s 200th birthday
Posted on February 12th, 2009 No comments
Abraham Lincoln
Abraham Lincoln (February 12, 1809 – April 15, 1865) was the 16th President of the United States. He successfully led the country through its greatest internal crisis, the American Civil War, preserving the Union and ending slavery. [From wikipedia]
Here is his famous “The Gettysburg Address“, which is my favorite.
Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
But, in a larger sense, we can not dedicate — we can not consecrate — we can not hallow — this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us — that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion — that we here highly resolve that these dead shall not have died in vain — that this nation, under God, shall have a new birth of freedom — and that government of the people, by the people, for the people, shall not perish from the earth.
President Barack Obama is giving a speech in Springfield, IL, the hometown of Abraham Lincoln, now. I am watching it live on CNN. He interprets the “union” and “by the people” in Lincoln’s heritage to a “large government picture” in the context of economic crisis. He is a genius speaker.
-
Some useful tools for you to write English articles on Linux
Posted on February 12th, 2009 1 comment(This is a re-post from my previous Chinese blog)
http://blog.youxu.info/2007/07/11/some-useful-tools-for-you-to-write-english-articles-on-linux/As an ESL (English as a Second language) student, I usually have a fear of writing articles. Nevertheless, I have to write about one article per week, either for learning English or for recoding my ideas. For many people in China, their killer applications are Word and Kingsoft Ciba. They simply type a Chinese phrase/word into the electronic dictionary, click the “translate” button, copy/paste the English word, do a grammar check in Word, and that’s all. After doing all of these, if Word stops reporting any spelling and grammar errors, they feel a great sense of achievement. I was one of those people before.
Meanwhile, as a Linux deadhead, I dislike M$ products emotionally. It seems to me that the only way out is to use AbiWord or Openoffice. I’ve used both for a while. Yet, I have to say that they are helpful but not perfect. To use them, I have to prepare a text file, which is inconvenient when you are working on a Tex file. For MacOSX, the other thing is I have to install X11. Don’t get me wrong, *nix is industrial-strength and designed to do everything solely with the shell. (Well, WoW is the last thing on my mind.)
After painful Googling, now I have at least four tools for helping with ESL writing.
1. GNU Aspell.
GNU Aspell is a Free and Open Source spell checker. It supports spell checking for source codes, script comments and TeX files, as well as HTML web pages and email. Aspell provides its users both interactive and batch modes. It contains several advanced features that are missing in both M$ Office and OO, such as a text-file-based user-defined dictionary and a “sound like” feature (e.g., know and no). GNU Aspell is definitely for literate programmers or PhD. students who want to write elegant code comments and academic articles.
2. GNU diction
GNU diction originates from the `diction’ on AT&T UNIX. It is actually a rule-based style checker. I’ve read the code thoroughly and found that almost every piece of the rules came from a book titled “The Elements of Style” authored by William Strunk. That is to say, you have an “Elements of Style” in your pocket now. Please note that the simple grammar checker in Word has nothing to do with style checking. GNU diction is a charming complement to Word/Openoffice if you insist on using them.
As it is rule-based, it sometimes provides redundant information even if your usage is indeed correct. As D.E. Knuth has mentioned in “Mathematical Writing”, the analysis of diction is quite superficial. “However, said Don, these programs are kind of fun. And they do provide an excuse to read the document from another point of view. Even if the analysis is wrong it does prompt you to re-read your prose, and this has to be a good thing”.
3. GNU Style
GNU style is contained in the GNU diction package. It will report the readability of your article based on several well-known linguistic indexes. For the native speaker, these are used for improving the readability of articles. Nevertheless, for ESL students, these indexes would be viewed as the writing level in terms of “what grade/school year is needed to understand your article for the average American”. In my opinion, we ESL students should prevent over-using simple words and simple sentences in technical writing. But, definitely don’t use a million-dollar word where a one-dollar word will do. Yet for ESL students, trying to use some new and sophisticated words will eventually boost writing ability.
4. LanguageTool (GPLed)
It is an open source language checker for English and other languages based on Java. I began to use it recently. It’s better than the embedded grammar checker in Openoffice. Moreover, it does support CLI mode and web mode. This is the missing tool on the Linux platform for grammar checking.
I can remember that when I was a college student, I struggled to write English articles with M$ word or Openoffice. My personal experience with English writing and M$ Word grammar checker brought me the truth that we should never let the quality rely on the damn grammar checker. As a rule of thumb, the best way to improve ESL writing skill is to write and to practice.
BTW: In preparing this article, I’ve employed vim, aspell, diction, style, languagetool and other tools on the Linux and Mac platform.




Recent Comments