Find a value appears twice in a table

March 8th, 2011

SELECT * FROM t1 AS t
WHERE 2 = (SELECT COUNT(*) FROM t1 WHERE t1.id = t.id);

Clear Facebook Cache

February 28th, 2011

http://developers.facebook.com/tools/lint

How to customize Facebook Link Sharing

February 28th, 2011

Put the following metatag in the html header of the sharing page. FB will pick this up automatically.

Customize logo Customize Title

Customize Description

Cannot delete or update a parent row: a foreign key constraint fail

December 25th, 2010

To delete a table that has a foreign key constraint, you will get the following error.

Cannot delete or update a parent row: a foreign key constraint fail

You can temporarily disable the foreign key referential check by the following command.

SET foreign_key_checks = 0;
drop table xxx;
SET foreign_key_checks = 1;

Shorten the URL for Gmail Hosting Services

October 13th, 2010

there is a way to shorten the url for gmail hosting services, all you have to do is to create a CNAME record in your DNS Server.

For example, this is the long URL to access to the gmail hosting service.
https://google.com/a/mydomain.com

Create a CNAME record in your DNS server.
mail IN CNAME ghs.google.com.

then when you type
http://mail.mydomain.com

it will redirect to your gmail hosting url
https://google.com/a/mydomain.com

Multiple Smart Relay for Exchange 2007 SBS

October 7th, 2010

The default SBS Console only allows you to add 1 Smart Relay to deliver email. If you need to setup multiple smart relay host – you will need to set it up from the Exchange Management Console

– Start up your Exchange Management Console
– Under Organization Configuration -> Hub Transport -> Send Connectors
– Click Properties
– Under Network
– ADD / DELETE the smarthost from there

Multiple SmartHost for Exchange 2007 SBS

Search and Replace in VI

September 18th, 2010

To Search and Replace in VI.

:%s/search_string/replacement_string/g

% is equal to all lines in a file
g is equal to global. Replace all occurrence of the search result.

Install Mac Mini Server without a DVD ROM Remotely

August 29th, 2010

There is a number of ways to install a Mac Mini Server Remotely. I found the following way seems to be the easiest among the others.

Pre-requistics:
1. you have a Mac Mini Server connected to a Network (preferably over Gigabit Ethernet)
2. you have a Mac Book connected to a the same Network with the Mac Mini Server (preferably over Gigabit Ethernet)

Procedures:
1. Insert the Installation DVD onto the Mac Book.
2. on your Mac Book, Open the HDD > Applications > Utilities, Start Remote Install Mac OS X
3. Press and Hold the “OPTION” key (or “ALT” on a PC Keyboard) on the Mac Mini Server and turn on the power
4. Select the Target Installation Disc to start up the computer

Enable Error Reporting for PHP

August 5th, 2010

If you don’t have access to the php.ini or have issue setting up .htaccess to enable error reporting.

You can try the following code

ini_set( ‘display_errors’, true );
error_reporting( E_ALL );

Finding out the process is occupying the Network Port on Windows and Linux

August 3rd, 2010

You ever have a problem trying to start an application and it failed to start because the network port was occupied by another application? To find out the application that using the port is painstaking. The following commands could help you.

In the following example, I am trying to find what is the process that is occupying the port 8080.

Windows

C:\Documents and Settings\terence>netstat -aon | findstr 8080
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 1748

C:\Documents and Settings\terence>tasklist | findstr 1748
TNSLSNR.EXE 1748 Console 0 6,264 K

Linux

[root@mail03a ~]# netstat -nap | grep 8080 | grep LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 2685/openvpn