Featured Post

The great debacle of healthcare.gov

This is the first time in history when the president of the United States of America, or probably for any head of state around the world,...

Wednesday, December 26, 2007

Add command prompt option to the windows explorer context menu

For Windows XP:
In Explorer, open Tools, Folder Options.
- Select the File Types tab.
- Go to NONE / Folder.
- Press Advanced button.
- In the action block type “Command Prompt” without the quotes.
- In the app block type “cmd.exe” without the quotes.
- Save and exit Folder Options.

I used this in my university time but later on I forgot how to activate that. I found an article in the web and put it in my blog so that I don't have to struggle again to recall it.

Friday, November 30, 2007

Useful UNIX Commands

Command: grep
Description: finds text within file
Options:
-n - prepend line number into the output file
Example:
grep searches for the into the file
Variation: all

Command: ifconfig
Description: to set network connection
Options:
a - to show all options
Example:
Variation: all

Command: stty
Description: To set the terminal setting.
Options:
a - to show all options
Example: stty erase to set the backspace key to erase command line text.
Variation: all

command: uname
Description: To show the system information
Options: -snrvmapiX
-a - to show system detail
-X - to show detail
Example:
Variation: all

command: Get release version
Description:
cat /var/sadm/softinfo/INST_RELEASE OR cat /etc/release

Command:
sar
Description: Memory usage
Variation:
Solaris

Command:
psrinfo -v
Description: CPU specification
Variation: Solaris

Command:
mpstat
Description: Process Usage
Variation:
Solaris


Command:
prstat
Description: process detail
Options:
-s size
Variations: Solaris

Command:
/usr/sbin/prtconf | grep size
Description: Memory available
Variation: Solaris

Command:
swap
Description: Swap space
Options:
ls
Variations: Solaris


Command:
find /usr/local/web -size +20000 -print
Description: Find the files with minimum given size: it prints file names more than 10MB of sizes
Options:
find
-size
-print
Example: find /usr/local/web -size +20000 -print


Command:
> find . -name file-name
Description: Find a file
Options:

-name
Variation: Solaris
Example:
find . -name file-name

Command: du
Description: Disk usage
Options:
. : current directory
-s: sum of disk usage
-k: in Kilobytes
-h: human readable format
Example: du -sh *
Variation: All

Command: df
Description: Disc space occupied by the filesystem directory/files
Options:
-k: in Kilobytes
Example: du -k | grep /usr/local would show you the size and percentage of usage

Setting environment variable
C Shell
:
Setting environment: setenv PATH "${PATH}:/usr/local:/usr/local/bin"
Unsetting environment: unsetenv PATH


Re-executing the changed shell file
C-Shell: source .cshrc
Korn Shell: . .profile
Bash-Shell: . .bashrc

Check if a process is running:
ps -ef | grep
e.g. to check if apache webserver is running
ps -ef | grep httpd


Change permission and ownership of file
chmod 777 file_name/dir_name
chmod o+rwx file_name/dir_name

chown user_name file_name

Command: checkuser -n netgroup
checkuser -u username
get the detail of the user id

Resourceful Unix command site:

http://www.computerhope.com/unix.htm
http://sysunconfig.net/unixtips/solaris.html
http://www.panix.com/~elflord/unix/grep.html - Grep tutorial

Wednesday, November 28, 2007

Tips: Javascript

Adding text to the OS clipboard

function copyTextToClipboard()
{
var textElement = document.getElementById(
);
if (window.clipboardData && clipboardData.setData)
{

clipboardData.setData("key", textEelement.value);
}

}

In the onClick() event of the relevant command button would invoke this javascript function (javascript:copyTextToClipboard()). Then the text would be available in the clipboard and can be paste into any text editor.


Show page loading image

If it is a long processing in the server side, sometimes users are confused whether the page has been submitted or not. It becomes worst if the status bar is made hidden on the browser. So the user could submit the page again and again. In previous we were doing lots of hardwork to make the buttons uneditable or hidden immediatedly after clicking it or submitting the form. Now a days, the popular and smart solution of this is to showing some animated image that gives a illusion of loading the page or processing in server side. It can be achieved by a simple javascript method call.

i. Put the entire body content of your html page in a <div> tag with some name e.g. body
ii. Trap the onClick event of html button and call the below javascript method:

function submit()
{
document.forms[0].action="/submit.do";
document.forms[0].submit();
document.getElementById('body').innerHTML=
"<div style='position: absolute; left: 40%; top: 50%; '><img
src='/images/ajax-loader.gif' alt='This will display an animated GIF'/>

}


Confirmation dialogue box using Yahoo API

1. Get the required yahoo .js files from the yahoo site and put it into your page:
<script src="js/event.js"></script>
<script src="js/dragdrop.js"></script>

<script src="js/container.js"></script>
<script src="js/connection.js"></script>

<script src="js/animation.js"></script>

2. set the namespace

YAHOO.namespace("test");


3. Initialize the dialogue boxes:

YAHOO.test.confirmDialog = new YAHOO.widget.SimpleDialog("dialog", {visible:false,
width: "30em", effect:[}effect: YAHOO.widget.ContainerEffect.FADE, duration:0.2}],
fixedcenter:true, modal:true, draggable: true});
YAHOO.test.confirmDialog.setHeader("Confirmation"); YAHOO.test.confirmDialog.setBody("Do you confirm?"); YAHOO.test.confirmDialog.cfg.queueProperty("buttons", [{ text: "Ok", handler:handleOk, isDefault:true}, {text: "Cancel", handler:handleCancel"}]); var keyListener = new YAHOO.util.KeyListener(document, {keys:27},
{fn:handleCancel, scope:YAHOO.text.confirmDialog, correctScope:true});
YAHOO.test.confirmDialog.cfg.queueProperty(keyListeners", keyListheners); YAHOO.text.confirmDialog.render(document.body); YAHOO.util.Event.addListener(window, "load", init);

4. Write the handler functions

var handleCancel=function() { this.hide(); } var handleOk = function() { document.forms[0].submit(); this.hide(); }

5. Call the dialogues from the form

onclick=YAHOO.test.confirmDialog.show();

Resources

http://www.htmlgoodies.com/beyond/dhtml/ Good site to get DHTML tips