[Quick Reminder]IE compatibility issue fixes

See this

Advertisements

[Reading notes]Huainanzi – Dao/Tao/Way of _____

Keep in mind these are just my reading notes, I do not wish to read the book over and over again to rediscover the key points so I’m just jotting down stuff I find important. They may or may not contradict with each other, but these are just my own understanding of the passage, not necessarily opinion. But hey, my own opinion can contradict too as time go by.

It is hard to find relevance in today’s world, but I wish to take notes and review them regularly and hopefully relate with future events


人生而静,天之性也;感而后动,性之害也;物至而神应,知之动也;知与物接,而好憎生焉。好憎成形,而知诱于外,不能反己,而天理灭矣。故达于道者,不以人易天,外与物化,而内不失其情,至无而供其求,时骋而要其宿。小大修短,各有其具,万物之至,腾踊肴乱而不失其数。是以处上而民弗重,居前而众弗害,天下归之,奸邪畏之,以其无争于万物也。故莫敢与之争。

This passage talks about the nature of human and the benefit tao (I’m sure Tao te Jing is more popular, might be a familiar term, it means the way, the way universe works, the way we interact with nature, the way ____) brings.

It’s saying we are born still, in peace and calm; As we start experience this world our soul start becoming polluted:
When we receive material goods, our soul responds, and wisdom/intelligence start to develop.

(In tao te jing, Lao Tsu advocates suppression of intelligence, he believes intelligence is the source of evil, it tells us to do things the wrong way.)

This passage suggests when intelligence is associated with material goods, we develop opinions, a liking or distaste towards the things we touch, events we experience, over time, we lose ourselves in this material world.

But someone who follows the way of tao does not try to change the nature, and looks to be in harmony with the outside world but their inner self remains with them. Pure and in peace. When they require something, they will obtain it even if they have nothing, they will be invited to dwell even if they are always traveling. The point is, no matter how much they don’t have, such a person is always has what they need.

Because they do not fight with others, people will not be hurt by them, thus no one will compete either because they have no chance.

Now it all sounds very magical but I think it’s just an introduction on what we can expect if we follow the way. The passages that follow provide some examples of people who follow the way of tao as described in other passages and originally from Tao te jing.


夫临江而钓,旷日而不能盈罗,虽有钩箴芒距、微纶芳饵,加之以詹何、娟嬛之数,犹不能与网罟争得也。射鸟者捍鸟号之弓,弯棋卫之箭,重之羿、逢蒙子之巧,以要飞鸟,犹不能与罗者竞多。何则?以所持之小也。张天下以为之笼,因江海以为罟,又何亡鱼失鸟之有乎?故矢不若缴,缴不若无形之像。

No matter how good a fisherman’s fishing rod is. Even if he plants himself beside water all day, he cannot compete with how much he could get using a net. No matter how skillful a bowman is, they cannot catch as many birds with bows and arrows compared to using a net. Why? Because of the size of the tools. Now on this planet earth, what available resource is bigger than the heaven and earth? So if you follow the way of nature, you can catch as much fish and birds as you wish.


So now it is starting to make some sense, now historical examples

夫释大道而任小数,无以异于使蟹捕鼠,蟾蠩捕蚤,不足以禁奸塞邪,乱乃逾滋。…禹知天下之叛也,乃坏城平池,散财物,焚甲兵,施之以德,海外宾伏,四夷纳职,合诸侯于涂山,执玉帛者万国。故机械之心藏于胸中,则纯白不粹,神德不全。在身者不知,何远之所能怀?是故革坚则兵利,城成则冲生。若以汤沃沸,乱乃逾甚。是故鞭噬狗,策蹄马,而欲教之,虽伊尹、造父弗能化。欲𡧢之心亡于中,则饥虎可尾,何况狗马之类乎?故体道者逸而不穷,任数者劳而无功。

People who ignore the way but trusts their intelligent tricks are using the wrong tool for the wrong job.
Emperor Yu knew about the betrayals in his domain, what he did was not to strike. Instead he teared his defenses down, dismissed his army and spread his wealth with the kingdoms nearby. Now there is nothing to gain from him, and because of his generosity everyone respects him and gathered to honor him.

夫峭法刻诛者,非霸王之业也;棰策繁用者,非致远之术也。离朱之明,察箴末于百步之外,不能见渊中之鱼;师旷之聪,合八风之调,而不能听十里之外。故任一人之能,不足以治三亩之宅也。修道理之数,因天地之自然,则六合不足均也。是故禹之决渎也,因水以为师;神农之播谷也,因苗以为教。

The person with the best vision could barely see further than a hundred feet away, cannot see the fish in the deep blue see. The greatest hearing could not hear more than 10 km away. So no one person can manage the whole three hector of land (including residents). But by trusting the heaven and earth and follow its rule then nothing is impossible. Therefore when Emperor Yu treated flood, he dug new tunnels for water to go and let nature take its course. When Shen nong planted seeds, he used the nature as basis of his teaching.


I think this is important when running a business, and it’s right. We need more than just ourselves to be able to handle the difficulties this world throws at us. Although it is still hard to find a direct example, the underlying message does make sense

[Quick Reminder]Multiple submit buttons in the same HTML form

The trick us, use the same name but different values on the button.
For example, if we wanted to have both ‘Submit’ and ‘Cancel’ in the same form.

<form action=’blah.foo’ method=’post‘>
<input type=’text‘ name=’blah‘ />
<button name=’actionvalue=’submit‘>Submit</button>
<button name=’actionvalue=’cancel‘>Remove</button>
</form>

So now, in whatever language we use to treat the post request, we could simply read the posted data from these buttons


For example, in PHP

$action = $_POST[‘action’];

if ($action == ‘submit’)
{

}

else if ($action == ‘cancel’)
{

}


or in ASP.net
string action = Request.Form[“action”];
switch (action)
{
case “submit”:
break;
case “cancel”:
break;
case “default”:
break;
}

That’s why I need to start this blog…..I forgot how to get POST from ASP.net now. Something like Request.QueryString….?

People are doing more complex things now it’s taking on average more clicks to find these fundamental references

Fix `ereg is deprecated` errors in PHP 5.3

While helping someone making a php site, I ran into some old codes using ereg

To get rid of the deprecated warnings replace ereg with preg

Fix ‘ereg is deprecated’ errors in PHP 5.3

However, it didn’t quite work for me

It had something to do with some symbols being treated as delimiters when they shouldn’t be.

For some reason, the method described on that site did not fix it the issue (wrap the patterns with //)

What I ended up doing was to wrap it with

ie. ereg(“‘[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]?(/.*)?$'”, $text)
becomes
preg_match(“[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]?(/.*)?$“, $text)

and

ereg_replace(“([ \t\r\n])+”, “”, $text);
becomes
preg_replace(“([ \t\r\n])+“, “”, $text);

Firefox Radio button issue – Selects the next option on refresh

This is something I encountered in my last job, don’t know if it still happens

But in case anyone encounters the same problem. Here is the gist of it

Suppose a page has a radio button with three options like so

(#) Option 1
( ) Option 2
( ) Option 3

Selection will change on every refresh, suppose we pressed F5 to refresh the page, it will now look like this

( ) Option 1
(#) Option 2
( )  Option 3

This behaviour is only present on firefox, supposedly it has been a problem since 2007 but noone bothered to fix it: Bugzilla link

The “fix” is simple

Turn off autocomplete feature


<form autocomplete="off">

Or through jQuery



$(document).ready(function() {
 if($.browser.mozilla) $("form").attr("autocomplete", "off"); 
 }); 

What we can learn from Mike Babcock

What we can learn from Mike Babcock

Just read an article on Mike Babcock, head coach for the Detroit Red Wings, the point is, it doesn’t matter what he does as living. The point is about the way he approaches his job, he treats his position as an executive, he takes pride in developing his people.

So from the article, I see three things that are important with him, and in extension, important to excel at any position

1) Confidence: He’s not afraid to develop his assistants, he develops them knowing that they can take over his job, in fact, that is what his goal is. He is confident enough about his ability, he knows it does not matter if he loses his job to one of his subordinates, the important thing is: He is better when his subordinates get better, and when that happens, there is no need to worry about his job because he is always getting better at it.

2) Preparation: As Babcock challenges his assistants to bring new ideas every day, he challenges them to be fully prepared about their solution. Unlike what we see in most corporate jobs, he doesn’t just dismiss an idea, he expects his assistants to debate with him, challenge him and bring him new perspective.

“One of the things that I discovered is that it’s almost like being a lawyer,” McLellan said. “Create a case and show him why something different might work. As soon as you gain his trust he’s very open to ideas and thoughts. He wants to be debated with.”

That is how anyone should approach their job, be prepared to defend your reasoning. You can’t just say something sucks without a thorough analysis, it only makes the intended audience mad, but if you have reasoning and thorough analysis, you have their respect.

3) Hire people who you trust, and trust them

Babcock goes through the background of every candidate he is interested in, and only hires them when he knows absolutely certain they can be great NHL coaches

“I’m not looking for the best interview,” Babcock said. “I’m looking for the best coach.”

Whereas in corporates, we see a lot of emphasis on acing the interview, and when hired, learning how not to work too hard such that management always hold you on one position.

Let them grow, and make allies with them when they leave. The analogy would be how secretive a corporation is and how afraid they are about developing their employees because they don’t want the employees to compete with them after they leave. I strongly suggest looking at Mike Babcock: They flourish together even when they work for different teams.

Anyone can learn a lot from this guy.