Monday, May 31, 2010

Why is MYSQL ODBC slow?

I encountered a strange issue today, when we migrated data from one server to another.

Users are connecting to MySQL server via MyODBC connector for Windows. The application seems hang when it hits the MySQL.

The issue seems complicated but easy to solve. I added the following to My.CNF on the server:

skip-name--resolve
skip-host-cache

With these directives, ODBC connection is much faster now.

Why?
MySQL has built-in security to ascertain whether request from a given hostname is genuinely from its IP address, instead of from IP spoofing.

When a client request hit MySQL server, the server will first resolve the hostname to IP. With this the server will again do a reverse lookup from DNS to ensure that IP in the request packet tally with IP given by the DNS.

In our case, the new DNS does not keep the record of the hostname after DHCP issue a leased IP to the client.

Thus, MySQL will have to wait for timeout to response to the request, this makes MySQL seems slow.

Who is Tomorrow?

When Apple's market capitalization overtook Microsoft last week, became the largest IT company on earth, the IT world is entering to the Apple era.

Apple was a near bankrupt company a decade ago, with share price as low as USD6 at the time Steve Jobs returned to Apple, compare to average of USD250 now.

Steve managed to get Bill Gates, his rival for many, to inject fresh fund on Apple. With products such as iMac, iPod, iPhone, and the recent iPad, Apple sweeps everyone in the tech world, Nokia, Google and Microsoft included, to be the No 1.

Coincidently, it was Apple and IBM brought Microsoft up to its size and influence today. Microsoft made the CPM/80 card, bundled with MBASIC for Apple II. Excel and Word were developed for the Macs back in 1980's before Windows firm its dominant position with Windows 3.0.

IBM on the other hand spurred the growth of PC by opening up the PC hardware design, allowing others like Compaq (now HP) to use the design and compete with IBM.

Microsoft benefited most from IBM and IBM's openness on PC hardware, and eventually took over IBM as the largest IT company with its PC/MSDOS and Windows.

Thus, it was IBM, the largest IT company of yesteryear, brought Microsoft up.

It was Microsoft, the largest IT company of yesterday, brought Apple back on track with its financial and products (Word and Excel for Mac) support on Macs.

Who will Apple groom to eventually replace its dominant position?

Anyone?

Remote failover

We have a couple of offices around. Recently a department located in HQ is moving to another location, miles away. But they still need to refer to data from HQ.

We put up a Linux server replicating some part of our MSSQL server data using PHP. Since we have multiple ISPs connected at the HQ, I was having the idea of making sure that pulling data from HQ should continue as long as 1 line is up.

In the pass, we have to mess around with the PHP code to change the server IP, or change our DNS forwarder to redirect to a working line should the main line goes off.

So I told myself there must be a way to deal with the situation.

OK, I found a solution from the Net here.

The author uses a simple trick to see if there's reply from a HTTP socket connection. If there's a reply, then the server is alive, else, the server is off.

I took the code below:


// Function to check response time
function pingDomain($domain){
$starttime = microtime(true);
$file = fsockopen ($domain, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;

if (!$file) $status = -1; // Site is down
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}
?>


and added the below to my main PHP code, to decide if the server is accessible via a given line.

$line1="X.X.X.X";
$line2="Y.Y.Y.Y";
$siteport=":1433";

if(pingDomain($line1))
{

$MSSQL=$line1.$siteport;
}elseif(pingDomain($line2)){

$MSSQL=$line2.$siteport;
}

echo $MSSQL;

with the above, my code is now with failover function, even if is not really polished, it does work well.


Sunday, May 30, 2010

民联何国阵有何分别?

蔡锐明也呼吁卡立,将雪州官联机构的空缺由公正党党员出任。

“据我所知,雪州官联机构有1000个空缺。我恳求(大臣卡立)能将这些空缺拨给在党内奋斗十多年的基层同志。我和再益依布拉欣都不需要,因为我们才加入一年,我们还是‘婴孩’,我将机会让给其他人。”

Saturday, May 29, 2010

Anwar, why still tangled with defection?

Anwar has been talking about defection, criticizing BN/UMNO for paying PR/PKR representatives.

But there are other issues which Anwar should be focusing. As the Economic Adviser to the Selangor State Government, Anwar should look closely into Selangor's economy, and how the state government's policy will further helping residents of Selangor.

As the Opposition Leader, he should focus on why voters should vote PR/PKR, giving voters confident that PR can form a better government if given the mandate.

Besides Economy Agenda introduced in the 12th GE, Anwar, and the Selangor state has failed to detailed the implementation, and measure its progress.

We agreed that poverty should be addressed, addressing by merely expressing concern is far from enough.

What are the steps to help the poor in Selangor? Have they been implemented? What is the results? Is there any public reviews on such implementation? Mr Anwar? Can Selangor be made the model for the rest to follow?

Those who have left PR/PKR are least concern for the ordinary people. They wanted to know what you can do to ensure better future and not to see you licking wound in public.

To summarized, you, and PR, have not done enough to warrant support from the majority. By hating BN/UMNO itself does not mean that PR will be able to form the next government.

We are keeping our eyes open

Friday, May 28, 2010

你搞砸后,我们来承担?

这是什么道理?简直就是威胁!

国家独立以来都是你们当政府,这十年你们挥霍无度,欠下3620亿,平均一年362亿!

欠下那么多,早就应该想法子开源节流,可是你们这群败家子,坐拥上天赐予的天然资产,居然面不改色的一一败光!

明明知道自己连底裤都败光了,还要大量买军火,花钱搞公关,搞什么风帆赛?

除了偷鸡摸狗的勾当,好像买青蛙,我帮你、你帮我,在国外砸钱买报纸广告出风头,你就只会向我们开刀。

告诉你,不要有难时要我们跟你一起担。

你做不来,就请你懒西,没有你,我们明天会更好!


“要修正还是陷国家于危机”
纳吉促全民思考汽油津贴存废
http://merdekareview.com/news/n/13543.html

【本刊黄书琪撰述】汽油津贴存废与否,端看接下来的人民反应,首相纳吉出席巫统最高理事会后告诉媒体,政府将继续正在进行的程序,取得人民、公民团体的意见之后再考虑下一步,形容这是“观察期”,并指油价津贴议题必须全民一起思考,决定是否舍弃津贴制度还是承受领取津贴的后果。

纳吉(左图)是在傍晚6时20分左右召开记者会,向在场媒体表示,政府将依据表现管理和传递单位(PEMANDU)属下的津贴重组实验室(Subsidy rationalisation laboratory)正在进行的程序,收集人民意见,其中包括特定社群的看法,之后政府将总结方案,简言之,这是未来政策的观察期。

他说:“就交由人民思考这些事情,从长期来看,我们究竟要修正,还是要捍卫现存的(制度),陷国家于危机之中。”

首相署部长首相署部长兼表现管理和传递单位行政总裁依德利斯嘉拉(Idris Jala)是在今天对外表示,由于政府已背负巨额债务,削减津贴势在必行,我国必须从现在开始削减津贴,以避免在2019年步希腊后尘,沦为破产国家。 【点击:我国油价调涨势在必行 不削津贴恐步希腊后尘】

根据该部门建议,我国政府可能在今年中旬上调汽油价格10分至15分,并在接下来五年逐步调整油价。这项宣布对长期享有汽油津贴的我国国民而言无疑是项重大冲击,而纳吉受询时拒绝透露政府究竟会在何时做决定,“这先照程序走吧!等我们知道人民回应之后,看人民到底要不要修正,我们要人民知道整个过程,并涉及其中。”

纳吉表示,取消汽油津贴乃是大议题,必须全民参与,“因为这是个大问题,我们要与人民分享这项议题,以让人民了解到这是我们必须一起做的决定,假设我们选A,就得A后果,假设我们选B,就得B后果。”

指迁站获得巫统认同

除了回应汽油津贴问题,身为巫统党主席的纳吉也在记者会上宣布巫统今日最高理事会所讨论的事项。

纳吉周一访问新加坡并与新国总理李显龙取得共识,他表示,马来西亚铁道局丹绒巴葛车站迁站事宜获得最高理事会成员一致认同,“其他我已经向最高理事会解释的议题,包括《马来亚铁道公司在新加坡土地发展协议要点》(Points of Agreement,简称POA),而且,最高理事们也接受我的解释,最高理事会认为这是一个同时惠及两国的解约方案。”

纳吉告诉媒体,最高理事会成员认为这个协议将“让两国关系朝正面发展,同时,促进两国发展。”

拒透露诗巫败选检讨

今天的巫统最高理事会议上也讨论了诗巫补选败选原因,但当记者进一步询问内容时,纳吉却拒绝透露原因,“我们有好些优势与弱点,但我们不会公开,就依照我党内部程序走,比起公开一切,内部处理方式会比较好。”

不过,纳吉向媒体解释巫统内部讨论诗巫补选的原因,“我们已经总结出政党应该修正的部分,虽然这是砂拉越国阵的事情,但是巫统也必须知道,我们在国阵之内也依靠友党力量,尤其是在砂州。”

代表国阵出战的人联党在5月16日的诗巫补选中,以398票落败,把诗巫国会议席拱手让给民联的民主行动党。

另外,纳吉也在今天的记者会上宣布巫统清理党员名册工作至今,已经摘除38万个名字,该党现有315万9444名党员。



- Posted using BlogPress from my iPhone

Wednesday, May 26, 2010

Boycott

Despite numerous boycott of mainstream media(MSM) on biased reporting, spinning news, and invisible hands manipulating at the back, why isn't MSM changed?

Many has misperception that media is relying on readership to survive. This is partly true.

If we look carefully into to media business, we will know that almost all media rely on advertising dollar to survive. And to get advertising dollar, they will have to convince the advertisers their command on readership, either sanctioned or not.

And many do not know, for example, the print media, is actually using advertising dollar to subsidize the selling price. This is to ensure that they are still in the competition. Several free print media operates entirely on advertising revenue such as the Sun.

Now you may ask, why media is not addressing to calls from the public to deliver unbiased information, and still continue to be sodomized by the power would be, and serving respective political masters, despite the fact that their readers are desperately wanted them to do otherwise.

The answer is simple: readership is important but it is not the factor that will affect the survival of media.

Give an example, the per copy price you pay for newspaper is probably subsidized almost 50% by advertising revenue. This means if the media is popular, it has to look for more advertising dollar to cover the subsidy.

On the other hand, media loves advertisers. Advertisers are the rice bowl for media and not you, the person on the street.

So if you want to send MSM a strong message, you should take away their rice bowl so that they will listen, else any effort to create awareness will have no impact on them, since they don't really care less about you, especially you are just one of the millions of readers.

How to take away their rice bowl?

First, you must continue buying as you did, instead of boycotting. This will of course maintain if not increase media circulation. On the other hand, this is also getting them to incur higher cost, since direct material cost such as newsprint and ink are two of the major costs for print media. The third major cost is logistic and distribution.

So help the person you hate to spend more, rather than spending less.

With higher circulation, they need to have more advertisers on board to pay their bills and pay on your behalf.

Now this is the fun part:
What you need to do is to tell advertisers that you will not buy their products if they advertise in the targeted media.

Yes, you may ask why should advertisers listen to you. The answer is simple: you are taking away the advertisers' rice bowl if they continue to advertise.

But how to effectively tell the advertisers? Simple, if you wanted to buy something, and you found that the merchant is advertising on targeted media, you either tell them off that you will not buy unless they stop advertising in targeted media. Call you telco for example to tell them that you are switching unless they withdraw their advertisements from targeted media.

This is not going to be an overnight success, but it will eventually forcing advertisers to stop paying media for their campaign since advertisement is no longer serving its purpose, ie induce sales but it actually hurt sales.

When advertisers starting to withdraw their advertisement support to the media, the media is then in a situation either to survive by listening to your call, or simply go bust as they cannot stay long in the business keep subsidizing while no advertising dollar.

So start from today, go get your copy of newspaper, then go thru the advertisements. If the merchant you are dealing with is supporting the paper, tell them you are switching and state the reason.

With concerted effort, you will eventually bring media to its knee unless they can find other funding.

Then tell media what you want them to do, they will then listen.


- Posted using BlogPress from my iPhone

Friday, May 21, 2010

MPPJ, are you telling us that your staff take bribe from developers?

When I came across this blown-up issue, I was stunt not because of the allegation that MPPJ staff are taking away allocation meant for settlers.

Council says staff encouraged to buy surplus low-cost flats

I was speechless for the courage of MPPJ to issue such statement to tell the world that their staff is openly taking bribe by accepting offers from various developers offering low cost units.

Why should the developers be so kind hearted to offer MPPJ staff, and not to the rest of the world? Or atleast others who are eligible?

If the low cost units were built under condition that development project must comply with certain quota for low cost units, of which the intention of such condition attached is meant for those who can't afford a shelter, ended up that MPPJ staff snatched their opportunities, then, isn't these MPPJ staff, from top to bottom, are worse than snatch thieves on the street?

And I am just wondering this happened since 2001, yet MACC has no action against this.

Hello MACC, these people are not walking in the corridor of power whom we duly understand your difficulty of getting these people to convict on their crime.

They are just ordinary public servants who have limited or no authority to cost your career or your life, and yet you let them go?

Perhaps one day, we will change our national anthem from Negara Ku, and copy the tunes from the Great Britain's, name it: "GOD save MAD Malaysia"!

Monday, May 17, 2010

Why BN been buried in Sibu

Rosmah Surprises Crowd At Sibu Gateway

SIBU, May 15 (Bernama) -- A gathering of 3,000 people at the Sibu Gateway had a pleasant surprise when the Prime Minister's wife, Datin Seri Rosmah Mansor was among the singers to entertain them during a meet-the people session there on Saturday night.

Rosmah had sportingly accepted requests to render two numbers during the occasion, including one song in Mandarin, just after Datuk Seri Mohd Najib Tun Razak concluded his speech.

Several well-known Malaysian artistes including "golden-voiced" Jamal Abdillah entertained the crowd at the function.

Rural and Regional Development Minister Datuk Seri Mohd Shafie Apdal, Energy, Green Technology and Water Minister Datuk Seri Peter Chin Fah Kui and the Barisan Nasional's (BN) candidate for the Sibu by-election, Robert Lau Hui Yew, were among those who attended the gathering.


- Posted using BlogPress from my iPhone

Sunday, May 16, 2010

Why BN lost Sibu

Bcoz:

Fat Mama did not campaign

Jibby should give money without any condition

White hair should show his hair and his face

Congrates to PR and DAP, next, pray for another long serving MP go see God, and grab the seat.


- Posted using BlogPress from my iPhone

Friday, May 14, 2010

你以为我真的需要你的选票吗?

你真的以为我需要你的选票?

继续发梦吧!

你真的以为我没有你的选票就不掂?

去睡觉吧!

你以为我要你的选票才拨款给华小独中?

去发你妈的春秋大梦吧!

你以为我会为了你而作出牺牲?

你不如多点见周公!

没有你的选票,我还是高高在上,你永远是我脚下的蚂蚁。

民主?见阎王去了!

- Posted using BlogPress from my iPhone

Wednesday, May 5, 2010

iPhone 4.0 Beta 3 installed

Ok, I admit that I am quite frustrated with iPhone 4.0 beta 2, sluggish, crash often, cannot charge at times.

Worse, it sometimes just jam the baseband. Yes, I still get signal, but cannot call or receive calls, cannot receive SMSes, cannot even get push notifications when it jammed up.

I never notice until I want to make calls, or just wondering why no one email me.... The solution is: reboot the iPhone.

So in a day, I have to reboot donkey times to make sure I get connected, sigh....

Entering beta 3. Everything seems well. Camera now works, although no zoom feature as yet. Phone is responsive, so far. I am glad.

But I am just wondering why Apple pulled off beta 3 a few hours after it is made available, no message, no notes, nothing.

Don't care. I will keep beta 3 until the next cycle comes, I had enough for beta 2.

Last note: the folder feature where apps can be arranged in folder does not seems to work well with iTunes.

iTunes will somehow screw up, and mess up the whole thing.

Good to have folders, but it is not the priority.

Next post, I am going to write something about JQuery.