How to Convert Text File From UTF-8 to ISO-8859-1 Encoding

January 29th, 2009

$ iconv --from-code=ISO-8859-1 --to-code=UTF-8 latin1.txt > utf8.txt

or simply

$ iconv -f ISO-8859-1 -t UTF-8 latin1.txt > utf8.txt

How to redirect pages to a new domain

January 5th, 2009

RedirectMatch 301 (.*)$ http://www.newdomainhere.com$1

Save this into .htaccess and upload on the root directory on your old domain.

How to set a MySQL Table AUTO_INCREMENT

November 18th, 2008

To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this:

mysql> ALTER TABLE tbl AUTO_INCREMENT = 100;

Find a string in files under Subversion

September 5th, 2008

As a programmer, I’ve been using find to locate string in my source code.  Issuing a find would include svn files too which is not my intension.  Here’s the command:

$ find . -not -regex '.*svn.*' -exec grep "$1" '{}' \; -print

How to Remove a MySQL Table constraint

August 26th, 2008

ALTER TABLE `attributes` DROP FOREIGN KEY `attributes_ibfk_1`;

MySQL ERROR 1005 (HY000): Can’t create table ‘Table.frm’ (errno: 150).  Here’s the solution.

Example:
ALTER TABLE `race` DROP FOREIGN KEY `race_ibfk_1`;

ALTER TABLE `race`
ADD CONSTRAINT `race_ibfk_1` FOREIGN KEY (`specieId`) REFERENCES `specie` (`specieId`) ON DELETE CASCADE;

How to mount an .iso image file?

August 25th, 2008

$ sudo mount -o loop /path/to/feisty-desktop-i386.iso /tmp/ubuntu-livecd

How to Find and Replace a String on the command line?

August 25th, 2008

This command will replace all instances of ‘replaceme’ with ‘newstring’ in files ‘*.php’ on /home/mysite/httpdocs.

find /home/mysite/httpdocs -name '*.php' | xargs replace 'replaceme' 'newstring' --

How to Refresh my DNS cached record?

August 24th, 2008
  1. Use OpenDNS free services by adding 208.67.222.222 and 208.67.220.220 on your /etc/resolv.conf.
  2. Go to http://www.opendns.com/support/cache/ then enter the website address.

How to list all users on a Linux machine?

August 16th, 2008

 cat /etc/passwd | cut -d":" -f1

Multiple SSL Certificate on Single IP

August 6th, 2008

Follow the links:

Virtual host examples from Apache website.

http://httpd.apache.org/docs/2.0/vhosts/examples.html

Turns out that it is possible to have multiple VirtualHosts on port 80 (Default http), but because of a limitation of SSL, we can’t have multiple VirtualHosts on port 443 (Default https).
I solved the problem as follows. I created the two VirtualHosts on port 80, one on port 443 and one on port 444.

Shared IP, multiple vhosts and multiple SSL certificates on Apache

The process is only 2 steps and involves modifying your Apache configuration.
1.  Create virtual hosts “map file”.
2.  Modify existing SSL vhost.

Caveat: The SSL certificate used will be common to all SSL vhosts.

Hosting multiple SSL vhosts on a single IP/Port/Certificate with Apache2

The following article discusses the following:
Basics Of Virtual Hosts, Name-Based Virtual Hosts, IP-Based Virtual Hosts, Configuring IP Aliasing, Virtual Hosts with IPs, Multiple Instances of Apache, Example for name based virtual hosts, Example for IP based virtual hosts.

Creating Name Based and IP Based Virtual hosts in Apache