Wednesday, October 28, 2009

Apache: .htaccess redirection

If you want visitors of your old website domain to be redirected to
the new domain, use the following code in .htaccess file placed in the
document root of your old website.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

This way, visitors of

http://olddomain.com/some_file.html
will be redirected to
http://www.newdomain.com/some_file.html

Wednesday, August 05, 2009

Linux: Avoid scp when copying a lot of files

When you are copying a lot of files files it may take a long time with
scp. This is because scp spawns a new process for each file and can be
resource intensive.

When using the -r switch, scp does not care about symbolic links and
will follow them, even if it has already copied the file. This can
lead to scp copying an infinite amount of data and can easily fill up
your hard disk.

Therefore, when you think of backups or remote copy of directories,
think of rsync.

Linux: Download whole website with wget

Command to download whole website

wget -r -p -np -k http://www.sonomamgmt.com

Friday, July 10, 2009

Linux : Install fonts on Linux

To install new fonts in your home directory (only for you; not
system-wide) follow this procedure.

If ~/.fonts does not exist,
% mkdir ~/.fonts

Download and copy the .ttf files into this directory and run

% fc-cache

For users who need to download Devanagari fonts, here's a good resource.
http://www.wazu.jp/gallery/Fonts_Devanagari.html

Wednesday, May 20, 2009

MySQL:Set up unique key ignoring duplicates

For many of you who might be having trouble setting up a unique key on
a table containing duplicates, here's the key

mysql> ALTER IGNORE TABLE table_name ADD UNIQUE(column_name)

Please note the keyword IGNORE in the above statement. That does the
work forcefully.

Sunday, February 15, 2009

Linux : tr (translate) command

I made a good use of the translate command recently to get month-name
in upper case. I needed this in a shell script. Here's the command

date +%b | tr [a-z] [A-Z]

Output: FEB

Learn more about tr using the following command

man tr

Monday, February 09, 2009

Consider freelancing !

Reasons why you should consider freelancing

* Freelancing provides you with chances to build your own business
contacts who will keep you busy.
* You are free to do many jobs at the same time.
* Nobody takes away your credit. You get rewarded for your work.
* You can work remotely from the comfort of your home. You save daily
commute which takes a lot of time.
* You can work when you are most productive. Flexibility of time is a
great advantage.
* You get good pay rate simply because there are no overheads. Money
is not lost to company administration or your manager :-)
* As I started writing this post, I thought someone must have done it
before so I googled and found that there's a list of 101 such reasons
on
http://www.hrworld.com/features/101-reasons-to-freelance-091007/
I never considered all those reasons before starting freelancing myself.
* Finally, because it's become hard to get a job when the world is hit
by recession.

Tuesday, February 03, 2009

Mysql: keep connection open for longer

These mysql queries will keep the connection open for 1800 seconds

SET @@local.wait_timeout=1800;
SET @@wait_timeout=1800;
SET @@local.interactive_timeout=1800;
SET @@interactive_timeout=1800;

Wednesday, January 28, 2009

MySQL: GROUP BY on datetime column

SELECT DATE_FORMAT(MyDate, '%d %M %Y') AS Date, COUNT(*) AS numRows
FROM Table1 GROUP BY Date;