Friday, April 28, 2006

PHP Script for genarate a calender

$cellWidth = 25;
$cellHeight = 25;
$month = 4;
$year = 2006;
$dateNames[1] = "Sun";
$dateNames[2] = "Mon";
$dateNames[3] = "Tue";
$dateNames[4] = "Wed";
$dateNames[5] = "Thr";
$dateNames[6] = "Fri";
$dateNames[7] = "Sat";
$firstDate = mktime(0,0,0,$month,1,$year); // time Stamp
$lastDate = mktime(0,0,0,$month + 1, 0,$year); // time Stamp
$currentDate = mktime(0,0,0,$month,1-date('w',$firstDate),$year); // time Stamp
    echo ""; 
    echo " "; 
    echo "".date('F',$firstDate)." $year"; 
    echo ""; 
    for($i=0;$i<7;$i++){
        echo " "; 
        for($j=1;$j<=7;$j++) {
            if(!$i) { echo "$dateNames[$j]"; } 
            else { 
                echo"".date('j',$currentDate).""; 
                $currentDate = mktime(0,0,0,date('n',$currentDate),
                    date('j',$currentDate)+1,date("Y",$currentDate)); 
            } 
        }
        echo ""; 
    }
    echo "";

Wednesday, April 26, 2006

Script for Autoincrement : Oracle 10

DROP TABLE PROFILE;
DROP SEQUENCE AutoIncrement;
DROP TRIGGER PROFILE_TRIGGER;

CREATE TABLE PROFILE
(

ID NUMBER PRIMARY KEY,
PROFILENAME VARCHAR2(25),
FONT VARCHAR2(25),
DEFAULT_PADDING NUMBER,
FONT_SIZE NUMBER
);
CREATE SEQUENCE AUTOINCREMENT
start with 1
increment by 1
nomaxvalue;
CREATE TRIGGER PROFILE_TRIGGER
BEFORE INSERT
ON PROFILE
REFERENCING NEW AS NEW
FOR EACH ROW BEGIN
SELECT AUTOINCREMENT.nextval INTO :NEW.ID FROM dual;
END;

INSERT INTO PROFILE(PROFILENAME) VALUES('some value one');
INSERT INTO PROFILE(PROFILENAME) VALUES('some value two');

SELECT * FROM PROFILE;

Tuesday, January 17, 2006

How to set Home Page : Java Script

Hyperlink tag
function setHomePage()
{
    this.style.behavior='url(#default#homepage)';
    this.setHomePage('http://gunasekara.coconia.net/');
    return false;"

}

Timed Recursive Function : Java Script

//
// function that executes recursively but it is timed.
//
function animate() {
    k++
    if (k == 5) k = 1
    document.images[k - 1].src = imgArray2[k - 1].src
    if (k > 1)
        document.images[k - 2].src = imgArray1[k - 2].src
    else
        document.images[3].src = imgArray1[3].src
    var timeOutID = setTimeout("animate()", 1000)
} 

Thursday, January 05, 2006

Charactor Validatin : Java Script

//
//A funtion for check a charactor input in a web form
//
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if ((charCode < 45 || charCode > 57) && charCode != 8 && charCode != 37 && charCode != 39) {
        alert("This field accepts numbers only")
        return false
    }
    return true
}
//
// you can access it from any contorl as follows
//
onKeyPress = 'javascript:return checkIt(event)'

Thursday, November 24, 2005

Print : Java Script

If you want to print a web page directly use this script code. Although it is simple, applicable for many cases

javascript: void (window.print())
<a href="javascript: void (window.print())" title="Print">Print</a>

.

Tuesday, November 15, 2005

A simple thing that I always forget

Developing a php script, but I spent a significant time for a small thing that I had done several times before

PHP Functions for get date and time

echo date('l dS of F Y h:i:s A'); out puts Tue Nov 15 th 2005
echo date("D M d S Y") out puts 15th of November 2005 03:33:35

Wednesday, May 18, 2005

First Appoinment at ITC

I got an appoinment at ITC (Information Technology Center) of Univercity of Peradeniya

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...