Some quick tips

Find and replace text within all files within a directory find PATH_TO_DIRECTORY -type f | xargs perl -pi -e ‘s/SEARCH_KEYWORD/REPLACE_KEYWORD/g’ Find a text in files in a directory and subdirectories find PATH_TO_DIRECTORY -exec grep -l ‘SEARCH_KEYWORD’ {} \; Find all modified file in last few …

How to reduce the size of JavaScript & CSS file?

Compress JavaScript / CSS file with the help of gzip:- With the help of php ob_start() function we can create gzip file for JavaScript. <?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], ‘gzip’)) ob_start(“ob_gzhandler”); else ob_start(); ?> We can use above code at the beginning of the JavaScript and <? …

Add a user to a group under Linux operating system

One can use useradd or usermod commands to add a user to a group. useradd command creates a new user or update default new user information. usermod command modifies a user account i.e. it is useful to add user to existing group. There are two …

How to get domain name from URL using javascript.

Use following javascript function to get domain name from URL. function fnGetDomain(url) { return url.match(/://(.[^/]+)/)[1]; } For ex: <script language=”javascript”>fnGetDomain(“http://mail.google.com/mail/?source=navclient-ff”);&lt/script> will return “mail.google.com”

How to apply TinyMCE editor only to specific Textarea?

>By default, TinyMCE applies to every textarea of a HTML page. There is a way to make it only load on like <textarea id=”mceEditor”>. just add the attribute ‘editor_selector’ in tinyMCE.init . The value for this attribute is a css class name which should be …

Edit whatever you want on any page – Images, Texts

>Open any web page, clear the address bar, and paste the code: javascript:document.body.contentEditable=’true’; document.designMode=’on’; void 0; and hit enter. Feel free to edit whatever you want on the page. With Firefox, you can even edit and save the modified pages to your computer.

How to mount external ntfs USB in RHEL?

>Follow the steps to mount external ntfs USB in RHEL or in any linux system. Get your kernel version: uname -r2.6.9-42.ELsmp (For my RHEL)……………..Install the package downloaded according to your kernel versionhttp://rpmfind.net/linux/sourceforge/l/li/linux-ntfs/rpm -ivh kernel-module-ntfs-2.6.9-42.ELsmp-2.1.20-0.rr.10.0.i686.rpm……………../sbin/modprobe ntfs (as root)……………..cat /proc/filesystems……………..Check volume names of your USB Drive.cat /etc/fstab………………Mount …

Export data to a CSV file using MySQL command prompt

> SELECT tableColumnName1, tableColumnName2 INTO OUTFILE ‘/path/to/file/data.csv’ FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘n’ FROM tableName; Access Denied Even if you have been granted the SELECT privilege, you will still need to be granted the FILE privilege, or else access will …

Perl – fork() example

>Here is a small example which demonstrate fork() implementation in PERL. while(1){ my @children; defined (my $pid = fork) or die “Cannot fork: $!n”; if ($pid) { # Parent Process… push(@children, $pid); wait(); my $ret = $?; if ($ret) { warn(“Abnormal child exit: $!n”); $daemon …

Edit MySQL stopword list [MySQL full text search]

>There are two ways to edit MySQL stopword list. Actually its not editing. Its all about creating a new file with your own stopwords & point MySQL to refer to that file location. 1st option———- Create File: e.g. /etc/stopword.txt* Change permission of this file, so …