Wednesday, November 24, 2010

Another disturbing story

There is an Ugly Betty actor hacking his own mom to death with a samurai sword. Disturbing, ugly story here.

The guy obviously is mentally disturbed and imagined his mom has the devil within.

And this is not the first time I read stories about family killing like this... and the guy has a Bible in his hand.

READ that Bible, how does Jesus deal with the devil? He simply tell him go away. He did NOT hack Peter when Peter suggested Jesus not to go on the cross. Ooh, Satan was there. (See Matthew 16:21-23)
Look, dealing with the devil is God's job, not yours.

The Bible is SUPPOSED to be able to calm the baddest criminal. How unfortunate is this story.

I hope it is not the "over reading" of the Bible that caused the actor's mental disturbance.

Tuesday, November 23, 2010

Ant vs Maven

Ant is "Another Neat Tool" that lets you do builds by writing instructions in XML. Need to compile using javac? use <javac>. Need to make make a jar? Use the <jar> task. You define "targets" to run and dependencies... It is neat if you don't mind crafting XML. Ant scripts are usually quite followable. Go head, spend a few minutes with ANT for fun. EVERY java programmer should know a thing or two about ANT.

Waita minute... just why am I wrapping commands with tags? Ok, here is why. ANT is cross platform and batch file stinks.. it is hard to make targets and stuff in a batch file.

Maven is the newer XML based tool that lets you do builds and much more. It is a new approach... you don't follow Maven scripts like an ANT script. Go ahead, spend 5 minutes with Maven.
Every java programmer should also know a thing or two about Maven also.

The following is instant-turn-off, you want me to type WHAT?

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app
-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false


Ooh, it generates a pom.xml for me and even some tests. Test Driven aficionados would instantly fall in love with it.

The big feature of Maven is dependencies handling. Most programs nowadays are not all made by your home grown parts... You may have the Log4J component, you may have Struts, Spring, Hibernate. Normally you would need to download all that stuff and jam your classpath with all those dozens of jars to build. With Maven, it will download those jars for you in the repository.
Your pom.xml does not contain the nuts and bolts of the command to compile your stuff and make the jar... they are behind the scene.

Deadly artillery attack in Korea is worrisome

US newspaper headline is about things such as holiday travel or about the Popes comment on condoms. These are not as worrisome as news about North Korea striking South Korea resulting deaths.

Look, this is "the first direct artillery attack on South Korean territory since the Korean War ended in an armistice, not a formal peace treaty" in the 1950s. Sadly, many Americans who barely studies any history only know Korea has great phones and great spicy dishes. That bloody conflict involved North Korea and the Chinese communists vs America + United Nations resulted in stalemate with millions dead.

Strong reliation will result in more deads and may snowball into much larger conflict.
No reliation may result in more aggression.

Repeating the Korea War is just going to cause more deaths, stay out America!
Some say the goal of the attack is to make them North Korea louder at the bargain table.

Wednesday, November 17, 2010

Javascript for Syntax Highlighting

Try this for beautiful syntax highlighter written in javascript.
Insert your code in a <pre> tag and it will be pretty.

<link type="text/css" rel="stylesheet" href="http://syntaxhighlighter.googlecode.com/svn/trunk/Styles/SyntaxHighlighter.css"></link>


<pre name="code" class="java">
public class Fun {

public static void main(String arg[]) {
System.out.println("Hello Beautiful World\n");
}

}
</pre>
<script language="javascript" src="http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js"></script>
<script language="javascript" src="http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJava.js"></script>
<script language="javascript" src="http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushXml.js"></script>
<script language="javascript">
dp.SyntaxHighlighter.ClipboardSwf = 'http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
</script>

On Latin

Google Translate now offers an exotic language in translation... Latin!

This language is now mostly dead... Only the ultra educated scholars can still speak fluently with this once-Europe-dominated language. Modern European languages are derived from it.. see this chart for instance . This is almost like HTML is derived from SGML.

Even the number of alphabets is not always the same... in the real old days, there was no W, Y and Z! and there was no lowercase!

Latin is not entirely obsolete... They are in your pennies: E pluribus unum. Mathematicians like Q.E.D at the end of their proof.

Some other Latin abbreviations lurking in English:
i.e. means "in other words"
e.g means "for example"

Also, is this a TYPO engraved in stone here in the Civic Opera Hovse in Chicago? No, it is intended, it just tries to be classic. There was... simply no W. (English speakers call this double-u, Spanish and French call it the double-v, which makes more sense. See, we don't even know what to call "w")

Why bother learning Latin? Pharmacy students wannabes flock to Latin classes in high school as they believe this will help their vocabulary. I wonder if that actually help them at all. I prefer learning languages that are still in wide use.

Languages are evolving... in a slower pace than a typical lifetime.

Friday, November 12, 2010

Genius Chinese 16-year-old chess player

This news captured my attention. (English equivalent: here). A 16 year old Chinese girl vs a world champion and just lost 1 game out of 6 (and able to draw 5 games). Amazing amazing.

I also discovered the New York Times chess blog. There is a java chess viewer there! Good stuff! It is impossible for me to appreciate a sequence like this: 1.e4 e5 2.Nf3 Nc6 3.Bb5 Nf6... I need pictures.

SO WHAT if you are good at chess? Think it is just some useless mental gladiatorship?

Hmm, SO WHAT if you can dunk a basketball for 2 points or push away all the heavyweight guys and reach the touchdown line? So what if you can swing a piece of metal and put a ball into 18 holes with fewer strokes than others?

Just do the sports and play the games you enjoy.

Wednesday, November 10, 2010

No man zone

News says teachers are earning poor grades.

So here we are, in a country full of poor performing students and teachers, in a poor economy. The future of this country just seems depressingly hopeless.

How come there are so few male teachers? Look at that picture: 100% ladies.


Look at a classroom of math, computer science, electricial engineering or the geekiest subject you can think of, you are likely to find a few female students. How come so few men go to education? Yes, it doesn't pay so well, and gosh and lot of paperwork. Unfortunately I am not capable enough to be one (not enough tough-kid-dealing-with-skills is one reason), but there are got to be more capable men out there.

Parents must instill the idea to the kids that one needs an education. Teach your kids what you know is just a start... they will probably need more than what you know to survive in the future world. Don't just rely on the poor performing teachers!

To deal with poor performing teacher-to-be students... come on, let's raise the bar. Simply don't let them graduate if they don't pass.

Hibernate revisited

JDBC is old school and Object Relation Mapping is mainstream (and has been around for years). ORM tries to abstract tried-and-true SQL and provides objects. Theoretically you can just change from Oracle to SQLserver just by tweaking the config file and no more dealing with different SQL syntax. ORM usually means Hibernate. Anything other than Hibernate such as Toplink gets you nowhere. Java programmers today need to list Spring/Hibernate on their resume unless you run your own shop. I previously read about it and now I have some time to look into more detail... to get something simple running.

So people is not happy with the simple JDBC approach because there are some boilerplate code to open and close connections and don't like hardcoding query strings. They don't want to transfer columns into their own value objects and demands more object wrappers.

So how do your objects know about columns of your table? You provide the mapping! (1. in xml or 2. annotation)
You have to include many jars in your classpath to make it compile happily.

It comes with 2 flavors of querying: the Criteria, and HQL. To prevent a few lines of boilerplate code, you'll need to learn a new query language.

If logging is on, you will see what query, insert, update statements that it is doing. For insert, update statments it gives you lots of question marks! That's PreparedStatements in action. But there is no obvious way to see exactly what it is inserting or updating.

You know internally that it is a wrapper to JDBC and your goal is to make Hibernate crank out statements that you would use

directly in JDBC.

I fail to share the enthusiasm.... long learning curve to get something straight forward. There should be tools that generate all that mapping, POJOs for me, perhaps it would becomes useful. No one should be hacking XML or error-prone annotation by hand.

Thursday, November 4, 2010

Eco-friendly suggestions for Whole Foods

Whole Foods is definitely THE most successful grocery store around even items there are more expensive. Many people concern the evil aspects of genetically engineered food... even though they have consumed A LOT already.

Organic food is just one thing. If your local grocery store also sell organic food, is it going to be as big business as Whole Food? Probably not. It takes excellent decorations to attract customers... that really is an important factor of a successful business.

I like the eco-friendly theme in almost everything they have. The tables are made of bamboo, paper bags over plastic bags, and recycle bins everywhere.

But I saw also these enemies of environment: single-use chopsticks and individually wrapped utensils. Sure, individually wrapped utensils are cleaner, but I don't mind using those that are not individually wrapped... that amount of plastic wasted is huge.

Wooden single-use chopsticks used up a lot of woods... yes, there are some eco-friendlier options but they are not popular enough. Perhaps someone should made them in aluminum and you can toss them in same bin as cans? The world needs even more innovations to reduce garbage!

Here is one idea for Whole Food: reward-driven recycling.

Deposit recyclable items (cans, glass, etc) into vending machine... and rewards will be added to a smartcard for points... collect enough points to earn a discount.

Tuesday, November 2, 2010

Gaming New Era?

The Kinect is almost here. See News. I am sure it would be somewhat fun.

But it is also scary to me:
Using a 3-D camera, depth sensors and voice-recognition software, it recognizes your face, voice and gestures as you move around and talk, without requiring you to hold a controller or wear a headset.... It will even take a photo of you doing these things so you can post it on Facebook for everyone’s amusement.


A bit too powerful and intrusive.... SOMEBODY IS WATCHING ME. An evil programmer can spy on you if that game console connects to the internet.

Is it taking gaming to new era? or has it gone too far?

Emperor and Christianity

While browsing classics, I noted the great emperor Kangxi is a Christian and wrote a classic poem!

《基督死》

功成十字血成溪,百丈恩流分自西。
身列四衙半夜路,徒方三背兩番雞。
五千鞭撻寸膚裂,六尺懸垂二盜齊。
慘慟八垓驚九品,七言一畢萬靈啼。

For an excellent analysis, see here

Monday, November 1, 2010

Halloween... BOO!

The world needs reasons to party (and need to make some money to sell candies and partying items). It started as some All Saint Days and becomes a day of costume and trick-or-treating with a theme of horror. Great info here at wiki. Ah, the reason for wacky costumes is to camouflage yourself from actual evil spirits. In one old job, some co-workers full of mustache and beard give themselves a reason to wear a DRESS on Halloween.

Halloween also inspired many TWISTED minds filming twisted horror movies. Some colleagues sent some links of twisted videos to me. Though I am not too scared (no one actually got hack sawed apart) but I am sicked by twisted stuff conceived by some twisted minds.

About trick-or-treat... this is blackmail and parents encourage kids to do that? Ok ok it is... tradition. Let them dress up as something cute.

But I am not telling kids to actually eat candies from strangers.

Why isn't anyone thinking the "OtherWorld" on any day other than Halloween?

Look folks, there is positive and negative charge, ying and yang, matter and anti-matter, kickass programmers and dumbass programmers... good and evil.

World and Otherworld?