Sunday, December 28, 2008

Linux : Installing mplayer on centOS

Installing mplayer on centOS is simple ! Execute the following commands as root


% wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
% wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
% rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
% rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm
% rpm -i rpmforge-release-0.3.6-1.el5.rf.*.rpm
% yum check-update
% yum install mplayer

Tuesday, September 16, 2008

Bash : concatenate strings in bash

The problem -

You have $yr=2008
You want to obtain something like 2008_data.csv etc

$yr_data.csv does not work

The solution - Use curly braces to separate variables from strings
like this

${yr}_data.csv

Thursday, September 11, 2008

Linux : setting up hostname

Here's how you can set hostname of your linux machine

Become root, save hostname in /etc/hostname and tell the hostname
command to read the name from the file.
Here are the commands to do the same

% su
% echo your_hostname > /etc/hostname
% hostname -F /etc/hostname

However, on next reboot, hostname will be lost.

On Red Hat / centOS, edit HOSTNAME= entry of the file
/etc/sysconfig/network

This sets up the hostname permanently.

Sunday, August 10, 2008

MySQL : Delete all tables of a database

It seems there's no command to delete all tables of a database. I have
been just dropping the database and creating it again. Does anyone
know any better method ? If you don't have privileges to create/drop
db, my method is not going to work :-)

Friday, February 01, 2008

MySQL : grant command

The GRANT function is used both to create new users, and to assign privileges to users.
mysql>GRANT SELECT, INSERT, UPDATE, DELETE
->ON widgets.* TO widgetAdmin@localhost
->IDENTIFIED BY 'ilovewidgets';

Assuming that the user widgetAdmin did not yet exist when this query is executed, both the user and db tables will be updated with the necessary rows.

The above is taken from dev.mysql.com.

You can also use assign all privileges to a user on a certain database. Following is the syntax.

mysql> GRANT ALL PRIVILEGES ON
    -> test.* TO 'ketan'@'localhost'
    -> IDENTIFIED BY 'ketans_password';

I find this command exceedingly useful ! A quick way to set up privileges of a user on a db.

Thursday, January 03, 2008

PHP : Facebook application to solve jumbled words

Wrote a facebook application to solve jumbled words.

http://apps.facebook.com/word_jumble/

Try it out.