Nice article on oracle DATE and TIMESTAMP's. Good place to go for quick reference.
Just go either here or here to read in detail.
Read more about "A Comparison of Oracle's DATE and TIMESTAMP Datatypes"!
Thursday, April 17, 2008
A Comparison of Oracle's DATE and TIMESTAMP Datatypes
Friday, April 04, 2008
Maven: a lot better then Ant
Maven is a software tool for Java project management and build automation similar in functionality to the Apache Ant. Now a days a lot of open source java project are using Maven.
Some of the main features are:-
- Making the build process easy and it is network-ready
- A way to share JARs across several projects
- Providing guidelines for best practices development i.e. to write unit test
- Creates common configuration for eclipse for users of same project.
- more...
also checkout http://en.wikipedia.org/wiki/Apache_Maven
A sample web project would look like
/project-name
/project-name/src/main/java
/project-name/src/main/resources
/project-name/src/test/java
/project-name/src/test/resources
/project-name/pom.xml
/project-name/src/main/webapp/project-name/src/main/webapp/WEB-INF
Some of the commands i use
mvn eclipse:eclipse
mvn clean
mvn install
more ...
Read more about "Maven: a lot better then Ant"!
Continuous integration
Continuous integration describes a set of software
engineering practices that speed up the delivery of software by decreasing ntegration times -Wikipedia
This is a cool concept to use which helps faster development and minimize bugs. Some of the key features are:-
- Maintain a code repository
- Automate the build
- Make your build self-testing
- Everyone commits every day
- Keep the build fast
- Test in a clone of the production environment
- Make it easy to get the latest deliverables
- Everyone can see the results of the latest build
- Automate Deployment
For more details checkout http://en.wikipedia.org/wiki/Continuous_integration
For java developers i would recommend Hudson since its feature rich and Free!
Read more about "Continuous integration"!
Eclipse and ANT build problem with jdk1.3
You can't do an ANT build inside eclipse if your chosen jdk is 1.3. Here is a the error message you get...
BUILD FAILED
java.lang.NoClassDefFoundError: org/xml/sax/SAXException
at org.apache.tools.ant.ProjectHelper.getProjectHelper(ProjectHelper.java:228)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.parseBuildFile(InternalAntRunner.java:189)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:400)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
nice little trick to fix that...
Inside Eclipse Go to Window->Preferences...->Ant->Runtime
In the classpath tab, add a new entry to the Ant Home Entries to the xerces jar file inside your eclipse/pluggins folder. In my case the file was org.apache.xerces_2.8.0.v200705301630.jar.
Now go ahead an run your build again successfully :)
update: When I updated my eclipse to 3.4, this again stopped working for me. The above fix did not work.I then saw a mailing list where the user executed the ant script by right clicking the ant script and choosing Run->Ant build..
Now change the JRE it runs in. It should be set to the option which says "Run in the same JRE as the workspace"
The mailing list thread is here
Read more about "Eclipse and ANT build problem with jdk1.3"!
How to use Read more!
Write your header message...
<span class="fullpost">Keep other stuff within your span tags</span>
I did this from here!
Only thing left to do is to enable or disable the "Read more!" which shows up at the bottom of each post!
Read more about "How to use Read more!"!
Replace ROOT context in tomcat without deleting or replacing the ROOT directory
This is a neat trick. At least it works in tomcat-4.1.24.
The first part to this trick is to know you can deploy a war file to the webapps in tomcat without adding the context in the server.xml of your tomcat installation. Suppose the name of your war file is HelloWorld.war, create an xml file called HelloWorld.xml and add the context snippet you would have added to the server.xml file to HelloWorld.xml. Now deploy both HelloWorld.war and HelloWorld.xml to the webapps folder. Voila! Your web application should now work.
The second part is to make your webapplication be the ROOT context. The ROOT context by default is the Tomcat welcome page. One way of doing this would be to just delete everything under ROOT and deploy your application in there. Well there is another way... In your Context file, just leave the path empty. Here is an example of the contents of the context file for HelloWorld.war without any resources:
<context path="" docbase="HelloWorld.war" debug="0" reloadable="true" crosscontext="true" />
That should do it.. Just bring up Tomcat and enter your url in your favourite browser.
Read more about "Replace ROOT context in tomcat without deleting or replacing the ROOT directory"!
Redirect stdout and stderr to same file
I keep forgetting the correct syntax....
% script 2>& logfile
Read more about "Redirect stdout and stderr to same file"!
Wednesday, August 08, 2007
More unix find tips
There are so many little things to remember in this command that I always have to lookup what switches to use. So here are a few ways of using find
To find all files modified in the last 24 hours (last full day) in current directory and its sub-directories:
find . -mtime -1 -print
Flag -mtime -1 option tells find command to look for files modified in the last day (24 hours). Flag -print option will cause find command to print the files’ location. -print can be replaced with -ls if you want a directory-listing-type response.
To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:
find /directory_path -mtime -1 -print
The command is basically the same with the earlier command, just that now you no need to cd (change directory) to the directory you want to search.
To find all files with regular file types only, and modified in the last 24 hours (last full day) in current directory and its sub-directories:
find /directory_path -type f -mtime -1 -print
To find all files that are modified today only (since start of day only, i.e. 12 am), in current directory and its sub-directories:
touch -t `date +%m%d0000` /tmp/$$
find /tmefndr/oravl01 -type f -newer /tmp/$$
rm /tmp/$$
The first command can be modified to specify other date and time, so that the commands will return all files that have changed since that particular date and time.
Find a file or directory
# find . -name TEMP -print
or
# find . -name TEMP -exec echo {} \;
Find core files in this directory tree and remove them
# find . -name "core" -exec rm -f {} \;
Find junk directories and remove their contents recursively
# find . -name "junk" -exec rm -rf {} \;
Find a pattern in a file using the recursive grep (ignore case)
# find . -type f xargs grep -i MYPATTERN
Find files modified in the past 7 days
# find . -mtime -7 -type f
Find files owned by a particular user
# find . -user esofthub
Find all your writable directories and list them
# find . -perm -0777 -type d -lsor# find . -type d -perm 777 -print
Find all your writable files and list them
# find . -perm -0777 -type f -lsor#find . -type f -perm 777 -print
Find large file sizes and list them
# find . -type f -size +1000 -lsor
# find . -type f -size +1000 -print
Find how many directories are in a path (counts current directory)
# find . -type d -exec basename {} \; wc -l
53
Find how many files are in a path
# find . -type f -exec basename {} \; wc -l
120
Find all my pipe files and change their permissions to all writable
# find . -name "pipe*" -exec chmod 666 {} \;
Find files that were modified 7 days ago and archive
# find . -type f -mtime 7 xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified more than 7 days ago and archive
# find . -type f -mtime +7 xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified less than 7 days ago and archive
# find . -type f -mtime -7 xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified more than 7 days ago but less than 14 days ago and archive
# find . -type f -mtime +7 -mtime -14 xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files in two different directories having the "test" string and list them
# find esofthub esoft -name "*test*" -type f -ls
Find files in two different directories having the "test" string and list them
# find esofthub esoft -name "*test*" -type f -ls
Find files in two different directories having the "test" string and count them
# find esofthub esoft -name "*test*" -type f -ls wc -l
12
Find files and directories newer than CompareFile
# find . -newer CompareFile -print
Find files and directories older than CompareFile
# find . ! -newer CompareFile -print
Find files and directories but don't traverse a particular directory
# find . -name RAID -prune -o -print
Find all the files in the current directory
# find * -type f -print -o -type d -prune
Find an inode and remove
# find . -inum 968746 -exec rm -i {} \;
Avoid using "-exec {}", as it will fork a child process for every file, wasting memory and CPU in the process. Use `xargs`, which will celeverly fit as many arguments as possible to feed to a command, and split up the number of arguments into chunks as necessary:
find . -depth -name "blabla*" -type f xargs rm -f
Also, be as precise as possible when searching for files, as this directly affects how long one has to wait for results to come back. Most of the stuff actually only manipulates the parser rather than what is actually being searched for, but even there, we can squeeze some performance gains, for example:
- use "-depth" when looking for ordinary files and symollic links, as "-depth" will show them before directories
- use "-depth -type f" when looking for ordinary file(s), as this speeds up the parsing and the search significantly:
find . -depth -type f -print ...
- use "-mount" as the first argument when you know that you only want to search the current filesystem, and
- use "-local" when you want to filter out the results from remote filesystems.
Note that "-local" won't actually cause `find` not to search remote file systems -- this is one of the options that affects parsing of the results, not the actual process of locating files; for not spanning remote filesystems, use "-mount" instead:
find / -mount -depth \( -type f -o -type l \) -print ...
Read more about "More unix find tips"!
Tuesday, April 17, 2007
Copy and paste in Vi/Vim
This is a neat trick to know and saves a lot of time:
Read more about "Copy and paste in Vi/Vim"!
Tuesday, February 13, 2007
Tips on unix find
Here is a nice tip on unix find..
$ find . cpio -pdumv /path/to/destination/dir
the files found by find are passed into cpio and it copies the files with the same permissions to the destination directory.
Read more about "Tips on unix find"!
Tuesday, January 30, 2007
linux tip on tar
If you untar a package, and it makes a mess of your directory because the packager didn't include the files in his tarball in a directory, you can use
% rm `tar ftz package.tar.gz`
to quickly get rid of those cluttering files.
% rm `tar ft package.tar`
does the same thing.
Read more about "linux tip on tar"!
Wednesday, November 08, 2006
Linux Admin's handbook for development server
Lets say for a small project(prjxxx) with 6 member team (name1, name2, name3, name4, name5, name6) we have to create a Linux based development server.
So after installing a brand new Linux Fedora/Ubuntu what are the steps a Linux admin should do:
1. Enabling sudo (its bad practice to login as root)
2. Installing Apache , MySQL , PHP , Subversion
http://www.linuxhelp.net/guides/lamp/
http://mkaz.com/ref/php/setup_linux.html
3. Subversion http://systhread.net/texts/200607subver.php
http://svnbook.red-bean.com/en/1.1/ch06s03.html
http://queens.db.toronto.edu/~nilesh/linux/subversion-howto/
subversion daemon
2. Creating users i.e. name1, name2 ...
3. Creating group and adding those 6 member to group (teamx)
5. Backups
To be continued...
For future reference:
http://techpages.wordpress.com/2006/08/29/configure-apache-mysql-php-solaris/
http://ashterix.blogspot.com/2006/09/faq-during-interview-for-unixlinux.html
http://acid-test.blogspot.com/2006/10/windows-vista-kill-switch-or-linux.html
Read more about "Linux Admin's handbook for development server"!
Friday, August 25, 2006
50 COMMON INTERVIEW Q&A
Source - http://bhuvans.wordpress.com/2006/08/19/50-common-interview-qa/ 1. Tell me about yourself: 2. Why did you leave your last job? 3. What experience do you have in this field? 4. Do you consider yourself successful? 5. What do co-workers say about you? 6. What do you know about this organization? 7. What have you done to improve your knowledge in the last year? 8. Are you applying for other jobs? 9. Why do you want to work for this organization? 10. Do you know anyone who works for us? 11. What kind of salary do you need? 12. Are you a team player? 13. How long would you expect to work for us if hired? 14. Have you ever had to fire anyone? How did you feel about that? 15. What is your philosophy towards work? 16. If you had enough money to retire right now, would you? 17. Have you ever been asked to leave a position? 18. Explain how you would be an asset to this organization 19. Why should we hire you? 20. Tell me about a suggestion you have made 21. What irritates you about co-workers? 22. What is your greatest strength? 23. Tell me about your dream job. 24. Why do you think you would do well at this job? 25. What are you looking for in a job? 26. What kind of person would you refuse to work with? 27. What is more important to you: the money or the work? 28. What would your previous supervisor say your strongest point is? 29. Tell me about a problem you had with a supervisor 30. What has disappointed you about a job? 31. Tell me about your ability to work under pressure. 32. Do your skills match this job or another job more closely? 33. What motivates you to do your best on the job? 34. Are you willing to work overtime? Nights? Weekends? 35. How would you know you were successful on this job? 36. Would you be willing to relocate if required? 37. Are you willing to put the interests of the organization ahead ofyour own? 38. Describe your management style. 39. What have you learned from mistakes on the job? 40. Do you have any blind spots? 41. If you were hiring a person for this job, what would you look for? 42. Do you think you are overqualified for this position? 43. How do you propose to compensate for your lack of experience? 44. What qualities do you look for in a boss? 45. Tell me about a time when you helped resolve a dispute betweenothers. 46. What position do you prefer on a team working on a project? 47. Describe your work ethic. 48. What has been your biggest professional disappointment? 49. Tell me about the most fun you have had on the job. 50. Do you have any questions for me?
The most often asked question in interviews. You need to have a short
statement prepared in your mind. Be careful that it does not sound
rehearsed. Limit it to work-related items unless instructed otherwise.
Talk about things you have done and jobs you have held that relate to
the position you are interviewing for. Start with the item farthest
back and work up to the present.
Stay positive regardless of the circumstances. Never refer to a major
problem with management and never speak ill of supervisors, co-workers
or the organization. If you do, you will be the one looking bad. Keep
smiling and talk about leaving for a positive reason such as an
opportunity, a chance to do something special or other forward-looking
reasons.
Speak about specifics that relate to the position you are applying for.
If you do not have specific experience, get as close as you can.
You should always answer yes and briefly explain why. A good
explanation is that you have set goals, and you have met some and are
on track to achieve the others.
Be prepared with a quote or two from co-workers. Either a specific
statement or a paraphrase will work. Jill Clark, a co-worker at Smith
Company, always said I was the hardest workers she had ever known. It
is as powerful as Jill having said it at the interview herself.
This question is one reason to do some research on the organization
before the interview. Find out where they have been and where they are
going. What are the current issues and who are the major players?
Try to include improvement activities that relate to the job. A wide
variety of activities can be mentioned as positive self-improvement.
Have some good ones handy to mention.
Be honest but do not spend a lot of time in this area. Keep the focus
on this job and what you can do for this organization. Anything else is
a distraction.
This may take some thought and certainly, should be based on the
research you have done on the organization. Sincerity is extremely
important here and will easily be sensed. Relate it to your long-term
career goals.
Be aware of the policy on relatives working for the organization. This
can affect your answer even though they asked about friends not
relatives. Be careful to mention a friend only if they are well thought
of.
A loaded question. A nasty little game that you will probably lose if
you answer first. So, do not answer it. Instead, say something like,
That’s a tough question. Can you tell me the range for this position?
In most cases, the interviewer, taken off guard, will tell you. If not,
say that it can depend on the details of the job. Then give a wide
range.
You are, of course, a team player. Be sure to have examples ready.
Specifics that show you often perform for the good of the team rather
than for yourself are good evidence of your team attitude. Do not brag,
just say it in a matter-of-fact tone. This is a key point.
Specifics here are not good. Something like this should work: I’d like
it to be a long time. Or As long as we both feel I’m doing a good job.
This is serious. Do not make light of it or in any way seem like you
like to fire people. At the same time, you will do it when it is the
right thing to do. When it comes to the organization versus the
individual who has created a harmful situation, you will protect the
organization. Remember firing is not the same as layoff or reduction in
force.
The interviewer is not looking for a long or flowery dissertation here.
Do you have strong feelings that the job gets done? Yes. That’s the
type of answer that works best here. Short and positive, showing a
benefit to the organization.
Answer yes if you would. But since you need to work, this is the type
of work you prefer. Do not say yes if you do not mean it.
If you have not, say no. If you have, be honest, brief and avoid saying
negative things about the people or organization involved.
You should be anxious for this question. It gives you a chance to
highlight your best points as they relate to the position being
discussed. Give a little advance thought to this relationship.
Point out how your assets meet what the organization needs. Do not
mention any other candidates to make a comparison.
Have a good one ready. Be sure and use a suggestion that was accepted
and was then considered successful. One related to the type of work
applied for is a real plus.
This is a trap question. Think real hard but fail to come up with
anything that irritates you. A short statement that you seem to get
along with folks is great.
Numerous answers are good, just stay positive. A few good examples:
Your ability to prioritize, Your problem-solving skills, Your ability
to work under pressure, Your ability to focus on projects, Your
professional expertise, Your leadership skills, Your positive attitude
Stay away from a specific job. You cannot win. If you say the job you
are contending for is it, you strain credibility. If you say another
job is it, you plant the suspicion that you will be dissatisfied with
this position if hired. The best is to stay genetic and say something
like: A job where I love the work, like the people, can contribute and
can’t wait to get to work.
Give several reasons and include skills, experience and interest.
See answer # 23
Do not be trivial. It would take disloyalty to the organization,
violence or lawbreaking to get you to object. Minor objections will
label you as a whiner.
Money is always important, but the work is the most important. There is
no better answer.
There are numerous good possibilities:
Loyalty, Energy, Positive attitude, Leadership, Team player, Expertise,
Initiative, Patience, Hard work, Creativity, Problem solver
Biggest trap of all. This is a test to see if you will speak ill of
your boss. If you fall for it and tell about a problem with a former
boss, you may well below the interview right there. Stay positive and
develop a poor memory about any trouble with a supervisor.
Don’t get trivial or negative. Safe areas are few but can include:
Not enough of a challenge. You were laid off in a reduction Company did
not win a contract, which would have given you more responsibility.
You may say that you thrive under certain types of pressure. Give an
example that relates to the type of position applied for.
Probably this one. Do not give fuel to the suspicion that you may want
another job more than this one.
This is a personal trait that only you can say, but good examples are:
Challenge, Achievement, Recognition
This is up to you. Be totally honest.
Several ways are good measures:
You set high standards for yourself and meet them. Your outcomes are a
success.Your boss tell you that you are successful
You should be clear on this with your family prior to the interview if
you think there is a chance it may come up. Do not say yes just to get
the job if the real answer is no. This can create a lot of problems
later on in your career. Be honest at this point and save yourself
future grief.
This is a straight loyalty and dedication question. Do not worry about
the deep ethical and philosophical implications. Just say yes.
Try to avoid labels. Some of the more common labels, like progressive,
salesman or consensus, can have several meanings or descriptions
depending on which management expert you listen to. The situational
style is safe, because it says you will manage according to the
situation, instead of one size fits all.
Here you have to come up with something or you strain credibility. Make
it small, well intentioned mistake with a positive lesson learned. An
example would be working too far ahead of colleagues on a project and
thus throwing coordination off.
Trick question. If you know about blind spots, they are no longer blind
spots. Do not reveal any personal areas of concern here. Let them do
their own discovery on your bad points. Do not hand it to them.
Be careful to mention traits that are needed and that you have.
Regardless of your qualifications, state that you are very well
qualified for the position.
First, if you have experience that the interviewer does not know about,
bring that up: Then, point out (if true) that you are a hard working
quick learner.
Be generic and positive. Safe qualities are knowledgeable, a sense of
humor, fair, loyal to subordinates and holder of high standards. All
bosses think they have these traits.
Pick a specific incident. Concentrate on your problem solving technique
and not the dispute you settled.
Be honest. If you are comfortable in different roles, point that out.
Emphasize benefits to the organization. Things like, determination to
get the job done and work hard but enjoy your work are good.
Be sure that you refer to something that was beyond your control. Show
acceptance and no negative feelings.
Talk about having fun by accomplishing something for the organization.
Always have some questions prepared. Questions prepared where you will be an asset to the organization are good. How soon will I be able to be productive? and What type of projects will I be able to assist on? are
examples.
Read more about "50 COMMON INTERVIEW Q&A"!
Monday, July 31, 2006
Add Calendar to blogspot
I wanted to add a calendar to my blog and knew I dont have to re-create the wheel.. This is used mainly when you are in the archives section.
This section goes between <head> and </head><script type="text/javascript" language="JavaScript">
/* you absolutely, positively must change the value for dateType below to match your
"Date Header Format" as set in your blog's Settings
if your date format is:
"Sunday, June 24, 2001" use 1
"6/24/2001" use 2
"6.24.2001" use 3
"20010624" use 4
"2001/06/24" use 5
"2001-06-24" use 6
"24.6.01" use 7
"June 24, 2001" use 8
"june 24, 2001" use 9
something else, change to one of those and use the right number! */
dateType = "1";
tableFontStyle = "10px Verdana";
tableBackgroundStyle = "#eee";
tableBackgroundLinkStyle = "#ffff99";
// tableBorderStyle is the CSS style applied to the outside of the table, and around each cell
tableBorderStyle = "1px solid black";
// tableBorder is the ugly old HTML border attribute
tableBorder = "0";
/* change the lowMonthNames if you use a non-English language and you use one of the date styles
with the month name in the date, but be sure they are in lower case (these are used for
matching, not displaying */
lowMonthNames = new Array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december");
// you can change the displayMonthNames and displayWeekdayNames to anything that suits you
displayMonthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
displayWeekdayNames = new Array("Su", "Mo", "Tu", "We", "Th", "Fr", "Sa");
/* if you already do something with the body onload event (or want to later), add a call to
it in this function or put the "if (inArchives) drawCalendar();" call in your existing
onload function */
function doOnloadTasks(){
if (inArchives) drawCalendar();
}
// time to stop changing things, unless you are sure you know what you're doing!
links = new Array();
inArchives = false;
if (location.href.indexOf("<$BlogArchiveFileName$>") > -1) inArchives = true;
function datesplitter(date, datetype){
switch(datetype){
case "1" :
date = date.substring(date.indexOf(",")+2);
year = date.substring(date.length-4);
day = date.substring(date.indexOf(" ")+1,date.indexOf(","));
wordMonth = date.substring(0,date.indexOf(" "));
wordMonth = wordMonth.toLowerCase();
for (i = 0; i < 12; i++){
if (lowMonthNames[i] == wordMonth){
month = i;
i = 12;
}
}
break;
case "2" :
year = date.substring(date.length-4);
month = date.substring(0,date.indexOf("/"))-1;
day = date.substring(date.indexOf("/")+1,date.lastIndexOf("/"));
break;
case "3" :
year = date.substring(date.length-4);
month = date.substring(0,date.indexOf("."))-1;
day = date.substring(date.indexOf(".")+1,date.lastIndexOf("."));
break;
case "4" :
year = date.substring(0,4);
month = date.substring(4,6);
if (month.charAt(0) == "0") month = month.substring(1);
month = month-1;
day = date.substring(6);
if (day.charAt(0) == "0") day = day.substring(1);
break;
case "5" :
year = date.substring(0,4);
month = date.substring(date.indexOf("/")+1,date.lastIndexOf("/"));
if (month.charAt(0) == "0") month = month.substring(1);
month = month-1;
day = date.substring(date.lastIndexOf("/")+1);
if (day.charAt(0) == "0") day = day.substring(1);
break;
case "6" :
year = date.substring(0,4);
month = date.substring(date.indexOf("-")+1,date.lastIndexOf("-"));
if (month.charAt(0) == "0") month = month.substring(1);
month = month-1;
day = date.substring(date.lastIndexOf("-")+1);
if (day.charAt(0) == "0") day = day.substring(1);
break;
case "7" :
year = date.substring(date.length-2);
if (year.charAt(0) == "0") year = year.charAt(1);
year = parseInt(year);
if (year < 50) year = 2000 + year; else year = 1900 + year;
month = date.substring(date.indexOf(".")+1,date.lastIndexOf("."))-1;
day = date.substring(0,date.indexOf("."));
break;
case "8" :
year = date.substring(date.length-4);
day = date.substring(date.indexOf(" ")+1,date.indexOf(","));
wordMonth = date.substring(0,date.indexOf(" "));
wordMonth = wordMonth.toLowerCase();
for (i = 0; i < 12; i++){
if (lowMonthNames[i] == wordMonth){
month = i;
i = 12;
}
}
break;
case "9" :
year = date.substring(date.length-4);
day = date.substring(date.indexOf(" ")+1,date.indexOf(","));
wordMonth = date.substring(0,date.indexOf(" "));
for (i = 0; i < 12; i++){
if (lowMonthNames[i] == wordMonth){
month = i;
i = 12;
}
}
break;
default :
year = 1980;
month = 1;
day = 1;
}
oDate = new Date(year, month, day);
return oDate;
}
function countDays(date){
// given a date object, return number of days in that month
monthcount = new Array ("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31");
year = date.getFullYear();
if (year % 4 == 0){
if (year % 100 == 0){
if (year % 400 == 0){
monthcount[1]++;
}
}
else {
monthcount[1]++;
}
}
return monthcount[date.getMonth()];
}
function drawCalendar(){
// only executes in a DOM compliant browser
if (document.getElementById){
if (document.createElement){
// IE is just barely compliant, if you use a deprecated style of attribute setting
navigator.appVersion.indexOf("MSIE") > 0 ? isIE = true : isIE = false;
calStart = realDate;
calStart.setDate(1);
dayCount = countDays(calStart);
leadblanks = calStart.getDay();
oTable = document.createElement("TABLE");
oTBody = document.createElement("TBODY");
oRow = document.createElement("TR");
oCell = document.createElement("TD");
if (isIE)
oCell.colSpan="7";
else
oCell.setAttribute("colspan", "7");
oDateLabel = document.createTextNode(displayMonthNames[calStart.getMonth()] + " " + calStart.getFullYear());
oCell.appendChild(oDateLabel);
oRow.appendChild(oCell);
oTBody.appendChild(oRow);
oRow = document.createElement("TR");
for (i=0;i<7;i++){
oCell = document.createElement("TD");
oCell.style.border = tableBorderStyle;
oDay = document.createTextNode(displayWeekdayNames[i]);
oCell.appendChild(oDay);
oRow.appendChild(oCell);
}
oTBody.appendChild(oRow);
dayindex = 1;
while (dayindex <= dayCount){
oRow = document.createElement("TR");
for (i=0;i<leadblanks;i++){
oCell = document.createElement("TD");
oCell.style.border = tableBorderStyle;
if (isIE)
oSpace = document.createTextNode(" ");
else
{
oSpace = document.createTextNode("*");
oCell.style.color = tableBackgroundStyle;
}
oCell.appendChild(oSpace);
oRow.appendChild(oCell);
}
for (b=leadblanks;b<7;b++){
oCell = document.createElement("TD");
oCell.style.border = tableBorderStyle;
if (links[dayindex] != null){
oLink = document.createElement("A");
if (isIE)
oLink.href=links[dayindex];
else
oLink.setAttribute("href", links[dayindex]);
oLinkText = document.createTextNode(dayindex);
oLink.appendChild(oLinkText);
oCell.appendChild(oLink);
oCell.style.background = tableBackgroundLinkStyle;
}
else
if (dayindex <= dayCount){
oDayText = document.createTextNode(dayindex);
oCell.appendChild(oDayText);
}
else {
if (isIE)
oSpace = document.createTextNode(" ");
else
{
oSpace = document.createTextNode("*");
oCell.style.color = tableBackgroundStyle;
}
oCell.appendChild(oSpace);
}
oRow.appendChild(oCell);
oTBody.appendChild(oRow);
dayindex++;
}
leadblanks = 0;
}
oTBody.style.font = tableFontStyle;
oTBody.style.textAlign = "center";
oTable.appendChild(oTBody);
if (isIE)
oTable.style.background = tableBackgroundStyle;
else
oTable.setAttribute("bgColor", tableBackgroundStyle);
oTable.border = tableBorder;
oTable.style.border = tableBorderStyle;
calendarSpot = document.getElementById("CalendarHere");
calendarSpot.appendChild(oTable);
}
}
}
</script>
This goes in your <body> tag<body onload="doOnloadTasks()">
This goes where you want the calendar to appear<span id="CalendarHere"><!-- tells the script where to put the calendar --></span>
This replaces your <BlogDateHeader> to </BlogDateHeader> section<BlogDateHeader>
<script type="text/javascript">
var postDate="<$BlogDateHeaderDate$>";
realDate = datesplitter(postDate,dateType);
anchorDate = realDate.valueOf();
links[realDate.getDate()] = "#d" + anchorDate;
document.write("<a name='d" + anchorDate + "'></a>");
</script>
<$BlogDateHeaderDate$>
</BlogDateHeader>
Read more about "Add Calendar to blogspot"!