Thursday, December 26, 2019

Make your browser talk

I am trying to come up with a spelling bee quiz in javascript and see if I can find a little API that can do text-to-speech for me. Chrome can do this right out of the box!

2 lines:

var msg = new SpeechSynthesisUtterance("hello my friend");
speechSynthesis.speak(msg);

Friday, August 2, 2019

Hong Kong Chaos

Over a million people protested the proposed Extradition Law to China and it has met with police violence. It was on world news for may be a couple days then the world focus on other news as the chaos go on. Week after week there are new conflicts as the Hong Kong people demand full withdrawal and resignation of the Chief Executive and releasing the arrested.

A million people marching for something is remarkable. It all rooted from someone who killed his girlfriend in Taiwan and fleed back to Hong Kong. What should be done about this guy? There is law that explicitly say can't take this guy back to Taiwan (and China). Oh so let's change that to fix a loop hole is the original plan. The problem is people mistrust China and afraid anyone can be taken back without a fair trial.

So there was protest met with violence. and the law is not officially stopped. And protest go on with more strange police and thug cooperation in endless revenge.

There is no clear ending in sight as both the protesters and police-backed-by-mainland-forces are turning violent. Peaceful protest only work when public opinion get shifted. When both sides are firm only who has the biggest fist win.

This is causing unimaginable damage to Hong Kong's future. People would stop coming (to spend money). Foreign investments may start leaving. How do you restore trust between people and the police?

The wisest thing to do is stop the protests. Give it a break. Calm down a bit. Don't get hurt anymore.

Strike is going to be next move. What other self inflict damage tactics do you have left? Hunger strike? Then what. Jump into the Victoria Harbour?

So just what to do with that murder case? No one even talking about that. How can justice to be brought?

There is hope if entire China up rise demand freedom from big-brother-watching, fair trial and the guys up on top actually grant such wishes.

But the billions apparent fine with what they got so at this moment. Hong Kong protests will just be met with violence until they stop.

Why not stop voluntarily? Fix up the brutal police and go on with your lives

Viral math problem reached my news feed

A problem baffled mathematicans and physicians. https://nypost.com/2019/08/01/viral-math-problem-baffles-mathematicians-physicists/.

Wow, I'm like it must be complex.

But it is just:

8÷2(2+2)

Come on. evaluate the parentheses first. 2+2=4. Still parantheses 8 ÷ 2(4). So you do it. So you have 8 ÷ 8 = 1.

Elementary school stuff. What is to argue.

Well the argument is should you do 8 ÷ 2 first. Gee. look at that parantheses 2(4). It begs to get evaluated first.

Answer is 1. Not 16. Stop arguing. Arithmetic isn't ambiguous.

Friday, May 3, 2019

console.log and more

So in Javascript programming the first crude debug tool was the alert... like alert("Hello"). that give you an (annoying) little message box. Well it is a bit distracting so later on there was the console.log(). Great now the messages show in the Developer console, like printf in the C world and System.out.println in the Java world.

But wait, there's more. There is also console.group and conole.groupEnd where you can indent your stuff. and have warning etc, Neato isn't it?

https://developer.mozilla.org/en-US/docs/Web/API/Console/group

Tuesday, April 16, 2019

Notre Dame in Flames

Along with much of the rest of the world I am saddened by the huge damage of the Notre Dame fire. This is a great visual guide describing what happened. You can even slide the before-and-after pics there.

It does not look like terrorism is involved... that's good. The world will vow to kick any groups dare to do that.

Just the lots-of-wood structure catches fire somehow. And gosh, the roof is so high that firemen can't reach. Now the Notre Dame is a few hundred years old... and took more than one hundred years to build! Back in those Middle Age Days... there were nothing else much better to do than to build ever-bigger cathedrals and make complex symphonies... a display of power.

Now to reflect.. what's the use of the cathedral just before the fire? Do people still worship in there? Not really it is a hot tourist spot and awesome architecture display. People (with plenty of money) vow to reconstruct it! What for? So they can go back to worship? You do not need a spectacular building to worship. I hope they reconstruct with plenty of fire safety features built in... and it is time to... fire protect other great buildings in the world, especially if it is made of wood.

I am glad nobody say it is a omen.. or wrath of higher being onto the people there.

Who would be responsible for this terrible incident/accident?

Monday, April 1, 2019

This is why one should learn some history

Especially if you are part of history.

1) GOP did not make an amendment to block FDR

Ocasio-Cortez falsely says GOP changed Constitution to block FDR from re-election.

2) There aren't 3 Mexican countries

https://www.nbcnews.com/business/business-news/fox-news-apologizes-graphic-about-3-mexican-countries-n989526

Calling http/https API

The apache httpclient is a de facto standard in calling http within Java.

Here is an excellent introduction with examples: https://www.mkyong.com/java/apache-httpclient-examples/

Now in http calls, you using do POST and GET, and pass parameters like in a html form... sometimes you have to header variables and pass JSON in body too in calling API. The link above provides nice examples. Hard to do from scratch.

What if you have to do https?

Boom! You may get this infamous exception:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: 
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
 unable to find valid certification path to requested target 
The problem here is you need certificates, you can create one with not-so-straightforward commands lines with the keytool command that comes with your JDK. (Go ahead google for it)... and you have to pass in -D parameters in your JDK call.

Or you can choose to allow everything. See this Stackoverflow doc: https://stackoverflow.com/questions/875467/java-client-certificates-over-https-ssl

Thursday, March 14, 2019

I am now an AWS Certified Solutions Architect Associate

I am now an AWS Certified Solutions Architect. Here is the badge link.

I use AWS things at most current work places. I hear people say things I don't fully understand... and I want to understand and figure out how to make things work better. And of course, AWS is the big brother of cloud computing and hot for the moment and good to know. (But note what's hot for the moment may seem ancient years from now, Windows 95 was hot in 1995).

AWS is evolving/changing rapidly. Documentation on AWS is everywhere on the web. More than anyone can handle to read them all. Best way to learn is through paper reading, from a book. I bought this book last year: AWS Certified Solutions Architect Official Study Guide: Associate Exam, thinking that should be fairly complete and adequately prepare me. It is nice book, explaining quite clearly on things, with in depth review chapter review questions. Many 5 star reviews. So must be good buy.

Then I came across Udemy.com and its black friday discounted training videos on this topic... I'm like why not it was just $9.95. The videos were hours long, while the lecturer is not bad but it is hard to keep up with nothing concrete to read to follow along. There is this Orion Paper thing but it is hard to study from and lacking text descriptions... it has some review questions and a full length final exam... and the explanation of the exam for your incorrect answers is most helpful... waita minute. Udemy covers A LOT of topics not on the Official Guide! AWS has evolved! The Official Guide is outdated! and a new one is not even available yet as of today (it won't be available until March 19)

Then I decided to get another book: AWS Certified Solutions Architect Associate All-in-One Exam Guide. Nice explanations and many updated topics.. and the review questions are nice... but many of them... too easy!

Then I look for sample practice questions on the web... sometimes hard to find... but Udemy offers sample question pack for $9.95. Sure I'll give it a shot. There are 6 exams, all quite difficult to get 70%. But the explanations of answers were really helpful!

Ok after going through them, and total studying for about 3 months or so, by reading books twice and jotting notes along... I go for the real test.

Amazon does not tell you what's the passing grade. It could be 70% or perhaps lower, not sure. 2 hours 65 questions. I need every second of it to think through. Some seems tricky... and seems even harder than the Udemy exams. But I managed to pass with a bit of luck. So I have to thank Udemy.