Archive for the ‘Trick’ Category

Remove CNNIC from Root CA Certificate in Firefox

Saturday, June 5th, 2010

I don’t like China (don’t know why H), but I really like this tip:

In Firefox (Ubuntu), go to Edit => Preferences => Advanced => Encryption => View Certificates

Find CNNIC in the list, select & delete it asap

More information why you should remove CNNIC from Root CA Certificate in Firefox: http://www.dinhnguyen.info/wordpress/2010/02/10/quan-trong-khua-firefox-3-6-va-bao-mat

Install (downgrade) php 5.2.x in Ubuntu 10.04 Lucid

Monday, May 24th, 2010

Today, all computers in my PHP department has been changed to Ubuntu 10.04. That’s awesome ^^

But my current project is running on out of date PHP & Zend Framework versions that was deprecated from PHP 5.3.0

Our Windows server running on PHP 5.2.x version, so we decided… downgraded to 5.2.x, too :) )

If you install LAMPP on Ubuntu 10.04, you’re getting PHP 5.3.2 & it is not the version you want. You have at least 2 options to install PHP 5.2.x:
- Download & build from source code
- Change source.list to get older version

(more…)

IE message: Operation aborted

Wednesday, November 18th, 2009

Few days ago, I assigned a task to fix a problem: IE showed an error message box and crashed when load a heavy page (it took about 40-50s to load completly) .

I thought, maybe cause of problem is Javascript (syntax error) and I checked whole the page. Hix, nothing happened :( After I Googled, I found the main reason are:

  1. The HTML file is being parsed
  2. Script is executing
  3. The executing script attempts to add, or remove an element from an unclosed ancestor in the markup tree (not including the script block’s immediate parent element).

So I refactored code by move all JS function call into $(document).ready( … ) (I used jQuery) to make sure the script will be excute after the page loaded successful. whew, the problem has been resolved :)

Enable windows Vista Aero glass transparency effect

Friday, October 9th, 2009

Nếu như phần cứng đáp ứng đủ yêu cầu tối thiểu để sử dụng hiệu ứng Aero glass transparency mà Windows vẫn không chịu enable hiệu ứng đấy lên thì làm như sau:

  1. Go to Start button, then click on Run.
  2. Run “regedit”.
  3. Browse and navigate to HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ registry branch.
  4. On the following registry subkeys, edit and change the default value:Composition to 1
    CompositionPolicy to 2
  5. Exit registry editor.
  6. Go to Start and click on Run again.
  7. Execute and run the following commands one by one:

net stop uxsms
net start uxsms

Source: http://www.mydigitallife.info

Parse single Javascript object in Jquery by $.ajax method

Tuesday, September 8th, 2009

Chưa thử test với Jquery phiên bản mới nhất, mới chạy trên bản 1.2.1 (dự án hiện tại đang dùng :( ). Khi sử dụng $.ajax như bên dưới thì phát sinh lỗi:

?View Code JAVASCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$.ajax({
	type: "POST",
	url: document.location.href,
	data: "card_type=" + cardType + "&card_number=" + cardNumber,
	dataType: 'JSON',
	cache: false,
	success: function(responses){
	    if(!responses.has_error)
	    {
	 	alert("Please enter valid Card Number.");
	 	return false;
	    }
       }
});

thì bị lỗi. Mặc dù response là {‘has_error’: false;} nhưng lại không nhảy vào khối lệnh IF.
Cách khắc phục rất đơn giản:

?View Code JAVASCRIPT
1
2
3
4
5
6
7
8
9
...
success: function(responses){
    var obj = eval('('+responses+')');
    if(!obj .has_error)
    {
	alert("Please enter valid Card Number.");
	return false;
    }
}

Lưu ý: Chỉ xảy ra lỗi này nếu response là single object, nếu nó là mảng các object thì cứ $.each rồi get theo key, val thì lại ko sao :(