Friday, August 29, 2008

Surprise surprise in McCain's VP pick

McCain's VP pick is Sarah Palin, the governor of Alaska. Wow, what a surprise. News tell me the most likely pick is Romney or some other guy (sorry don't remember his name).... and now, it is another possible female going to the White House.... While a lot of people predicted Hilary would be the first woman on either of the top 2 positions, it may be this previously rather unknown Sarah who would be able to do this. This election sure will be a remarkable chapter in future US history book: whoever the winner may be.

I'd like to hear Palin speak, hear her ideas.I hope to hear something revolutionary.
The presidential debates (and vice presidential debates) will be my must-watch TV.

Thursday, August 28, 2008

Computing Constants

This site http://numbers.computation.free.fr/Constants/constants.html contains lots of interesting information about math constants such as π, e, sqrt(2). Nice presentation. Gosh I know so little.

But the Programs link is even more interesing, especially the Tiny Programs page. Ok, I have a minor gripe: this webpage has frames.... the direct URL is http://numbers.computation.free.fr/Constants/TinyPrograms/tinycodes.html.

Gosh, the following short C code computes digits for π

int a=10000,b,c=8400,d,e,f[8401],g;

main(){
for(;b-c;)f[b++]=a/5;
for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)
for(b=c;d+=f[b]*a,f[b]=d%--g,d/=g--,--b;d*=b);
}

I have no clue how this code work... I would expect a program to sum up some known series for π... what's this 8400 and -14?? No clue.

I tested it and it works. I am just AMAZED.

Who is the winner?

Beijing Olympics has come and gone, leaving awes in memories of those who have watched the opening and the spectacular performances of the athletes. What's the outcome? Who is the big winner?

I read a (Chinese) newspaper article griping that China should be reported as the world winner as they have the most gold medals, and that author is slamming American media for saying USA is the winner because they count total number of medals. That author even say some people even use total number of medals starting from the first Olympics, and of course USA would be the winner if you count that far.

Look folks, the athletes won, not you.

Olympics is often used as a measurement somewhat in world power. Some may have a sense of superiority over others if your country win.

Hmm, do you think Kenya and Jamaica have a louder voice in say a United Nation meeting because they have the fastest runners?

World power, I think, should be measured by GNP, military power and all that. I think the Olympics is supposed to celebrate athletes' achievements together, worldwide. So it is CLEAR that Chinese won the most number of gold medals. USA won the most number of medals. You decide who is the true winner. No hard feelings.

The Olympics athletes are the few, the talented, the dedicated. Americans should produce and watch TV shows documenting their tough trainings and dedications (and show them in prime time).

Much of the rest of America have much to work on.... that obesity ratio! that low reading and math score!

It is not enough to say "don't be a fool stay in school", it should be "you too! should excel in school!"

And yikes, our jobs are flowing overseas, quickly! To keep America strong, the entire nation needs to work hard.

Monopoly World Record

Thousands of people gather to set world record on playing Monopoly together.
See this news. London, Tokyo, Frankfurt, Bogota, Lisbon, Hong Kong, Las Vegas and more than a dozen additional locations...

I played Monopoly maybe once or twice. Roll dice. Build house. Go to jail suddenly... go around and around. It can go on for hours. Yawn. Boring. Just how do you gather that many people to play that game? Chess, Clue, Yahtzee, Scrabble, and even Life are much more fun and have a forseeable end. Not so with Monopoly... I don't quite understand why people enjoy it so much.

Monopoly has so many local and even world editions. I have even seen Monopoly for Transformers! I don't know how well those sell. There are many editions for chess too... but only the standard looking ones are authentic.

Wednesday, August 27, 2008

Ant and Maven

You write Java and you don't know ANT? You must live under a rock. Everybody uses it. It is open source, downloadable from Apache.

Gimme a break, if it is on Apache, I must use it? Then you will forever be slave to open source libraries.

It is a strangely named tool "A Neat Tool"

This is Java's makefile, in the form of XML (and you must call it build.xml). People use makefiles for decades. Instead of the classic (but arcane) C/C++ makefile with tabs, ANT uses XML. Yes, every new tool is required to embrace XML. ANT essentially calls your javac.exe and you can write batch-file like commands to make jar files out of your compiled files the way you want it.

But I am not so comfortable with the "everyone is using it so you must know it". *I* decide to use it or not. Ancient C/C++ tools create makefiles too, automatically. Programmers should not worry to much about making builds. I want to check files into the source control and let another person worry about builds.

Enter Maven: industry's new favorite of creating builds. Instead of starting a build.xml from scratch, you can run an arcane command to create a project. (See this 5 minutes guide). Then viola, it can make builds, wow, even create some junit testing code for you. It needs another must-be-called pom.xml configuration file. I have huge complain about the long arcane command in creating the project. The console spits out all sorts of messages that it wants to download download download stuff (patches?). And it gives unintelligentable error if you have a proxy but didn't set it right.

Look folks, any program, open source or not, need to give intelligentable error messages!

The end result is that it creates some directory, a Hello World file, and a JUnit for that. Everyone embraces JUnit Test, and I find it ultra hassle, good that someone cranks those out to satisfy shallow guys who actually think JUnit makes you write better code.

I like Websphere's File->Export to create EAR/JAR, and automatic build.

Monday, August 25, 2008

VP

"It's Biden". The weekend's headline is all over Obama's VP choice, followed by McCain's ads pinpointing what Biden says before he became the running mate...

So everyone says, Biden brings foreign policy experience, he is well-respected, etc. My question is this: how come he didn't get very far in his OWN bid for presidency?

I wonder what videos will McCain's ads play if Obama selects Hilary instead. All that bitter attacks are too many to fit in a 30 second commercial.

VP never caught this much attention. Did Cheney ever get much attention during his campaign with Bush? It was Bush vs Gore. It seemed like not many cared about Cheney and Liberman. Yes, Cheney did get a lot of attention by shooting his own friend.

I can never understand why the former Bush picked Quayle as running mate. Woo young voters is what I read. Elementary school kids who are not old enough to vote won't support him. They how to spell "potato." Yes, Quayle, you will forever be logged in this history book for this. Unimaginable for America if the former Bush was unable to become president somehow and Quayle became president. Besides potatoe, gosh there are much more stupid things he says. Read it in wiki.

Tuesday, August 19, 2008

倪匡論金庸

倪匡 and 金庸 are both super excellent novel writers. Yes, every Chinese heard of their names, read their novels or saw TV productions of those. Although many people have trouble understanding 倪匡 verbally but he writes so clearly in his excellent novels, and the following.

Read what 倪匡 thinks of 金庸's works here. Ok, this is written many years ago.
http://www.angelibrary.com/essay/ljy/index.html

倪匡 believes no one from history has achieved 金庸's greatness, nor would anyone in the future.

How can anyone predict the achievcement of future generations? But I do agree with 倪匡. Today's generations is hardly educated, and we live in a world full of media distractions. Who will put such amazing effort in writing excellent novels? Besides, in today's full of media world, how many read volumes of text, even if they are excellent?

Monday, August 18, 2008

PDF creation with Java

Adobe's PDF is the web's favorite document format. Word doc? It may not open correctly from your Mac and it seems too clumsy because it can contain too many Microsoft propreitary things. Even the IRS takes PDF generated from Tax software. Everyone loves the PDFviewer where you can zoom, find, print with ease.

Java can create PDF files. One way is via open-source library known as iText. This neat library allows you to create PDF from scratch or insert stuff to it. PDF files can actually handle form data too. It can be used to merge your text into fields. Just 1 jar, fairly easy to use. Great tool.

Of course, people would demand more. Business apps loves reports, pie charts! Of course, you can generate your reports easily on a web page. But can you save it, zoom into it or page up and down quickly like PDF files? Traditionally, people generate great looking reports with things like Crystal Reports: drag-and-drop fields, put header and footer, and voila. You can do that with Java and JasperReport.

Instead of drag-and-drop fields in WSYIWIG, JasperReport wants you to specify a report in their XML, and then plug into your datasource. Anyone created a GUI for creating that JRXML file? It can do all sorts of things. But I am not impressed with the way the demos are presented. You get a build.xml and you are told to run ant. But it errors and errors and errors. I am not impressed.

Look, demos need to run right out of the box. I should do no more than adding jars on my classpath.

This helpful page gets me started: http://www.cise.ufl.edu/~otopsaka/CIS4301/ReportDemo/ReportFromJava.html. I am able to generate a report out of Access!

Olympics and Conflicts

1/100 of a second: not sure if it is as fast as a blink of eye, is the difference between gold and silver medals in the Olympics. Yup, by now everyone has heard Michael Phelps's 8-medal victory. Amazing achievement. The second place is just 1/100 of a second behind. Even the 8th place guy is not that far behind... all within that second. All Olympics atheletes are amazing achievers.

Olympics making news headline is great... we celebrate amazing achievements from athletes worldwide. These atheletes keep pushing on human maximum ability... Hmm, I wonder if the amazing fast 100m Jamaica winner can outrun a cat when it is chased by a dog. My first grade music teacher says this: your dad walks like a half note. You walk like a quarter note, and cats and dogs (have 4 legs) run like 4 eighth notes!

Olympics is world participation, in a peaceful way. Unfortunately news of violence overshadow it as we see news from Russia and Georgia and other conflicts. It seems that no one is able to prevent tanks roaming and terrorists bombing the innocents.

I am glad the Olympics is going on peacefully. Let it continue without conflicts!

Monday, August 11, 2008

Twin Prime Conjecture

A "Conjecture" is a big fancy word for a "guess", usually for something that is probably true without a proof. The Twin Prime Conjecture is one of these oldest guesses ever known. A twin prime are two numbers with difference of 2 that are both primes. For example, 3 and 5, 11 and 13, 41 and 43, etc.

The guess is: is there infinitely many such pairs?

This is one of those simple-to-state, but hard-to-prove-or-disprove statement.

Euclid already proved that there are infinitely many primes (with a remarkable proof by contradiction). Chances are: there are infinitely many twin primes, but no one can say for certain.

Dry and boring you say? I found a great entertaining song!
http://www.pbs.org/wgbh/nova/sciencenow/3302/02.html

If presented right, math can even be an entertaining subject!

What does it matter if there are infinite or finitely many twin primes? Answer: Curiousity demands answers.

Hmm, let me start with the similar fashion as Euclid: let p and p+2 be the last set of twin primes... if I can find another set of twin primes beyond that, or another contradiction then I've got it!

Awesome Olympics Opening

Wow, that opening was awesome. 2008 drummers with lights creating LED effect! That fireworks! 2008 Tai Chi masters! That human paintbrush... and much more. Tremendous effort!

As the athletes march in, I feel sorry for the hundreds of cheerleaders clapping. Hard to do that for a couple hours straight!

It was a great geography lesson. Thanks to NBC who highlights the location of the countries. Gosh! I don't know most of the countries! Some of them I've never heard of! Ignorance! Ignorance! But when I was an elementary school student with homework exercise of coloring the world map, many of the countries don't even exist. BTW, I only need four colors to color any map.

But gosh it was interrupted by much commercials... I want to order a DVD one day! The only way to find interesting competitions is through watching recordings... Too hard to schedule the right time to watch it live.

Friday, August 8, 2008

Olympics begins!

The long waited Beijing Olympics began! Unfortunately I didn't watch the opening ceremony live. Saw some pictures on the web... it was the most elaborate and expensive opening ceremony ever. I have yet to see some videos.
Beijing has hosted many major ceremonies. Remember it is the home of emperors for dynasties. But those were probably not as big as the Olympics.

I am so glad no terrorists strike. Gosh, recently buses blow up and terrorists hacked police squad with swords in western part of China! How many remember these isolated incidents? These guys are like another al Queda. See this news for details. These are the descendants of the people that Mulan fought!

China is now in the spotlight on world stage. Even today's Red Eye free newspaper has Chinese title and "Beijing Olympics" in (simplified) Chinese.
It is prime opportunity to show the world how much progress China has made.

China still has a LOT to work on: is that odd number/even number days going to continue to control pollution? Is the rich going to be even richer and the poor more poor? Are those lead paint going to be out of our toys? Is human rights going to improve?

Here is classic word exchange about human rights: (how many times you hear this?)
US President: "We value human rights and religious freedom"
Some spokeperson: "No one should use human rights, religion or any reason to interfere with our internal affairs".
Then life goes on, absolutely no improvements can be made. After all, it is their internal affairs. If we value human rights so much, why are we tapping phone wires or torturing war detainees?

Put the politics aside, watch the atheletes. But gosh, but is robbing kids from childhood to train them to do impossible gymnastics violating human rights?

Wednesday, August 6, 2008

A stab at American Education

I glanced over this book. It is another stab at poor math education of Americans. As you can expect, it talks about low scores and it hurts.... Poor textbook is one reason, the author says. I don't have time to read all the authors constructive suggestions to improve math education. I found the following interesting. Here is a quiz:

12/13 + 7/8.

What is it closest to? Here are the choices: 1,2,19,21.

Yikes, 13 and 8 are not nice to find common denominators.... I know how to do this... 13x8 = 104,....I am still working on it. The author explains: look, 12/13 and 7/8 are both fractions close to 1, so add them up the answer is going to be closest 2. Easy. Oops I didn't see that. Ok, gimme about 30 seconds I can do this problem even I don't see that. But it is alarming that 37 percent of 17-years-olds don't get it right. 17 year old should be almost ready for college, and that is just an elementary school problem? The problem is this: the students didn't understand fractions! Waita minute, did they have drills all the time? The problem is: they don't understand what they are drilling.

The next page the author interviewed a calculus student who says: I can find the limit by plugging the numbers in... but I just don't know what is it used for? I don't why I am doing this...

It seems like this student is on a Freudian chair by a psychologist expressing inner pain.

Unfortunately, my homework problems rarely ask me to evaluate limit by plugging numbers in. I usually get strange cases where infinity and divide-by-0 is involved... sometimes I may need the l'Hopital's rule. We should tell the students: RELAX, you probably don't need to evaluate limits in solving a real problem. BUT you need to know the derivative and integral are both defined by a limit. That epsilon and delta definition really shut many students off. However, math demands everything to be defined precisely. Informally, limit is simply "where are you going".

Students should know the amazing lim (x->0) sin x/x = 1... This is the key to derive many derivatives such as d/dx sin x = cos x.

I'd like to see that author write a math textbook. It is always easier to criticize than doing it right.

Friday, August 1, 2008

CSS controls printing

Cascade Style Sheet is very important in designing your HTML. It gives you exact sizes. Besides font size, you can also spice up your <table> and much much more. Recently I learned that you can also control paging in printing too. Try this.

<style>
.pagebreak
{
page-break-after: always
}
</style>

<u>Page 1</u>
<p>
There are a few CSS styles that can control paging. Though you only see 1 page here on browser, however if you print it, you will see multiple pages.

<div class="pagebreak"></div>

<u>Page 2</u>
<p>
There are other styles that you may use to control printing, including preventing your elements from chopping in half at end of your page.
See <a href="http://www.w3schools.com/CSS/css_ref_print.asp">here</a> for details

Eclipse

A total solar eclipse is going to be visible today in part of the northern hemisphere! See this news for details. Unfortunately this CNN news didn't tell me when. DON'T look at the sun directly. It is going to hurt your eyes. Don't look even if you have sunglasses. I've heard the best method is use reflection from water, or ink.

Here is an interesting quote.

Just to say how special it is, in the whole universe we might be among the few beings that have the chance of seeing something like that," said Michael Khan,
a mission analyst at the European Space Agency. "The fact that we have a moon and that the moon passes in front of
our sun, and that the apparent size of our moon is approximately equal to the apparent size of the sun -- all these factors combine to create the solar eclipse phenomenon."


Hmm, we are among the few beings... Do we even know of other beings?

Amazing that the sun and the moon (yin and yang) are approximately equal in apparent size. Won't be as fun if the moon is merely a dot on the sun isn't it?
Of course today we know the sun is actually gosh much much bigger than the earth and even much much more bigger than the moon.
Moonlight are actually reflected sun light! So the balance theory of yin and yang is out of whack! (Other yin yang balances are: male/female, positive/negative charge, north/south magnet, etc. of course: good/evil!)

Eclipse used to be omen of disaster! People dance around to try to scare away the evil takeover. Of course each time they are successful.

Some doomsday sayers in China say "gosh I am worried about the olympics". Please... no separatists or terrorists attack. It is a sports event.
Doomsday sayers please find other careers.

BTW, why does that omnipresent Java IDE called Eclipse?