November 2011

Perl - file test operators

Perl have set of file test operators. It helps to test the file against exists, read, write... properties. This short hand file test operators return true or false.

1. How to check the file exists or not?

The -e operator helps to check the file exists or not.

if( -e $filename) {
print "File Exists";
}

2. How to check the file is not empty?

The -s operator checks the file not empty and return the size in bytes.

if(-s "test.txt") {
print "the file have content";
}

3. How to check the particular file in symbolic link?

The -l operator return true if the given file is symnbolic link.

Other most commonly used file test operators are

-f     To check the file is regular file.

-d     To check the file is directory.

-z     To check the file is empty.

-x     To check the file is executable by user or group.

-w     To check the file is writable by user or group.

-r     To check the file is readable by user or group.

Selenium - How to check the check box is checked or not?

To check the check box or radio boxes are selected in PERL selenium test, use command is_checked_ok.

For example

<input type="checkbox" name="media" id ="media" value="New Papers">
<input type="checkbox" name="media" id ="media" value="TV">
<input type="checkbox" name="media" id ="media" value="Mobile">

To test whether the media with value TV selected

$selCon->is_checked_ok("//input[\@id='media' and \@value='TV']");

Selenium - How to check the field is editable or non-editable?

To test the field is updatable that is not disabled for edit, there is command called is_editable available in WWW::Selenium PERL module.

1. Consider you have a field called first_name which is normal text field.

<input type="text" id="first_name" name="first_name">

To test the field is editable
$selCon->is_editable("first_name");

2. To test the field is not editable

<input type="text" id="user_name" name="user_name" readonly >

ok( not $selCon->is_editable("user_name"));

Selenium - How to check the field is not holding the specified value?

Suppose a field should not hold particular value then how to test that using Test::WWW::Selenium.

There is command for it called value_isnt to check the field not having that specified value.

<input type="text" id="user_name" name="user_name">

To test the field user_name doesn't hold value "admin"

$selCon->value_isnt(user_name,"admin");

DB2: Primary Key and Foreign Key

Primary Key
Primary Key is one of the column or group of columns (max 64 columns) used to identify a unique row in the table. Maximum you can have a column of length 254 bytes to define a primary key.

You can define this when you create table or use ALTER, if you already created the table.

Where to find the keys for the indexes
You can find the primary key for a Index in SYSIBM.SYSKEYS.

Foreign Key
Foreign Key is a column/columns of a table which is used to define the Referential integrity (ensuring data integrity between tables).

Where to find the foreign keys for the table
From SYSIBM.SYRELS you can find with which table there is RI and using the RELNAME from SYSIBM.SYSFOREIGNKEYS you will get The foreign keys.

CVS Commands Quick Reference

CVS (Concurrent Version Control System) commands:

1. cvs add test.php --> To add file to CVS

2. cvs commit test.php --> To commit the file to repository. It will open a editor, enter your commit comments and save using :wq

3. cvs status test.php --> Check the status of local file with CVS and display the details.

4. cvs diff test.php --> Display the difference of local file with latest head in CVS.

5. cvs update -A test.php --> Update the current file with latest head version.

6. cvs co test2.php --> To checkout the file from CVS.

7. cvs update -j version_number test.php --> To get the particular version.

8. cvs tag -b "Novfix" test.php --> Add the file particular tag.

9. cvs add -kb test.gif --> To add the image/binary file format.

10. cvs remove test.php --> To remove the file from CVS. (Need to commit after remove to get this file remove from repository.)

You can use cvs help command to get more help on the commands.

DB2 : What is simple, segmented and partitioned table space?

Simple Table Space:

* Can contain one or more tables
* Rows from multiple tables can be interleaved on a page under the DBA’s control and maintenance.

Segmented Tablespace:

* Can contain one or more tables
* Tablespace is divided into segments of 4 to 64 pages in increments of 4 pages. Each segment is dedicated to a single table. A table can occupy multiple segments.

Partitioned Tablespace:

* Can contain one table
* Tablespace in divided into parts and each part is put in a separate VSAM dataset.

DB2: What is a NULL value? What are the pros and cons of using NULLS?

A NULL value takes up one byte of storage and indicates that a value is not present as opposed to a space or zero value.

It's the DB2 equivalent of TBD on an organizational chart and often correctly portrays a business situation. Unfortunately, it requires extra coding for an application program to handle this situation.

DB2 : FREE command?

The FREE command can be used to delete plans and/or packages no longer needed.

DB2: sql code 922, 811, 818

What is sqlcode –922?

Authorization failure.

What is sqlcode –811?

SELECT statement has resulted in retrieval of more than one row.

What is sqlcode –818?

This is generated when the consistency tokens in the DBRM and the load module are different.

Perl: Difference between die and warn?

Difference between die and warn

die() - Print the list on STDERR and die.

warn - Print the list on STDERR like die, but doesn't exit.

Perl: Difference between die and exit?

die - Print to STDERR and exit with $! and $@.

exit - Exit immediately with the value of expression which default to 0. Calls END routines and object destructors before existing.

JQuery: How to set value to the div tag?

In the web pages, mostly we use the div tags. Sometimes we want to display the values return from server.
So to display that in div tag, we can use the text option like below.

jQuery("#divid").text("Success");

Or

jQuery("div.classname").text("Success");

Abend Codes

ABEND CODE Description
S002 Very large record length/ wrong record length
S0C1 Operation Exception. Check for subscript errors, missing DD card, file not opened.
S0CB Attempting to divide by 0 and not using ON SIZE ERROR.
S222 The job was cancelled (by subsystem or operator) because it violated some restriction.
S522 JOB or TSO session exceeded maximum job wait time OR operator did not mount the require tape within allowed time limit
S806 Load module not found
S837 Space problem, Allocated space is not enough for data set
S913 You are trying to access a dataset which you are not authorized to use.
SE37 Insufficient disk space.
SOC4 1. Index exceeds the size of table
2. Trying to use File Section variables without opening the file
SOC7 1. Moving non numeric value to numeric field
2. Not initializing the numeric variables before first use
Sx22 Job has been cancelled. The value of x will vary depending on the way the job was cancelled. S222 means job was cancelled by a user or operator without a dump. If a TSO session times out you will probably get an S522 abend code.
U1026 COBOL sort failed.
U1056 Program didn't close a file before ending
S322 Indicates a time out abend. The program has taken more CPU time than the default limit for the job class. Could indicate an infinite loop.

DBIx Query Construction - select, distinct, order by , not null, getting total number of records - Part I

Perl CPAN have module called DBIx::Class. It gives a object oriented layer for database. Each table in the database have one schema file in the perl.

These schema files are loaded using the single App/Shcema.pm using the load_namespaces().

The schema files contains the specification for columns, primary, unique keys, relation between other tables.

Google Music

Google launches its music store music.google.com. Where you can upload, search & find it and purchase music.

Once purchased can share with google+. so your follower can get full stream of music. It supports WMA, OGG, FLAC in addition with MP3, AAC.

LinkedIn - How to stop broadcasting the changes?

Whenever you add/edit your linkedin profile, that changes are broadcast to your entire linkedin network.

How to stop it?

1. Signed into linkedin.com
2. Click your name in the top right corner.
3. Click the settings.
4. Click on turn on/off your activity broadcasts (uncheck the box to stop broadcasting)

so your activities won't broadcasts.

Born Mathematic Genius Answer Paper

Find X?