Saturday, July 21, 2007

Free Source Code: How To Backup Blogger Blog

I love Blogger. All of my blogs is hosted by them. It's the ease of use and the customisability of it's template that make Blogger blogs famous. In fact, all you need to do is know the Blogger template tags to be able to customize your own template.

But sometimes you might want to use or transfer your existing blog to other blogging engine such as Wordpress. Your biggest problem would be how to back up your existing blog. The good news is, you can.

Blogger provides a formula to view all of your blog's post. See below:

http://blogname.blogspot.com/search?max-results=N


blogname - the name of your blog
N - the number of post in your blog

For example, if your blogs name is free source codes and that blog has less than 1000 posts, you can view all the post through this URL:

http://freesourcecodes.blogspot.com/search?max-results=1000


Once all in that page has been loaded, save it using the <File> -> <Save page As> menu in FireFox or <File> -> <Save As> menu in IE. Make sure you select "Web Page, complete" in the "Save as type" combo box.
You can download, use and modify any source codes posted here in just one condition, that you give credit to this blog.
Technorati | del.icio.us | Digg it | Google | Netscape | StumbleUpon | Yahoo

Friday, July 20, 2007

Free Source Code: Blogger Tag Definition

To really customize your blogs in blogger, you should understand the tags that the Blogger engine use. In this way, you can really harness the power of Blogger and make your own Blogger templates.

Blogger tags are called meta tags, because they represent data stored in the Blogger database about your blog. For example, the tag <BlogItemAuthorEmail> is the email address of the author of a post, as stored in the Profile section.

Below is a list of the Blogger meta tags that you will find in your default Blogger template, with their explaination:

<$BlogEncoding$> - The encoding setting used in a content-type declaration

<BlogSiteFeed> - Start of site feed section
<$BlogSiteFeedUrl$> - URL of blog site feed
</BlogSiteFeed> - End of site feed section

<$BlogTitle$> - The title of the blog.
<$BlogDescription$> - The description of the blog.

<$BlogOwnerFirstName$> - Blog owner firstname
<$BlogOwnerLastName$> - Blog owner lastname
<$BlogOwnerEmail$> - Blog owner email address
<$BlogOwnerFullName$> - Blog owner fullname
<$BlogOwnerPhone$> - Blog owner phone

<Blogger> - Start of blog contents
<BlogDateHeader> - Start of date header section
<$BlogDateHeaderDate$> - Date header
</BlogDateHeader> - End of date header section

<BlogItemTitle> - Start of item title section
<$BlogItemTitle$> - Item title text
</BlogItemTitle> - End of item title section

<$BlogItemBody$> - The text of a post
<$BlogItemAuthor$> - The author of a post
<$BlogItemAuthorNickname$> - The nickname of the author of a post
<$BlogItemAuthorEmail$> - The email address of the author of a post
<$BlogItemAuthorURL$> - The homepage URL of the author of a post
<$BlogItemDateTime$> - The Date and/or Time of a post
<$BlogItemNumber$> - The unique ID number of the post
<$BlogItemArchiveFileName$> - The archive filename of the post
<$BlogItemPermalinkURL$> - The permalink or URL of the item

<BlogDateFooter> - Start of footer section
</BlogDateFooter> - End of footer section
</Blogger> - End of blog contents

<BloggerArchives> - Start of archive
<$BlogArchiveURL$> - Archive URL
<$BlogArchiveName$> - Archive name or text
</BloggerArchives> - End of blog archive

Labels:

You can download, use and modify any source codes posted here in just one condition, that you give credit to this blog.
Technorati | del.icio.us | Digg it | Google | Netscape | StumbleUpon | Yahoo

Thursday, July 19, 2007

Free Source Code: Tree Traversal Program

In computer science, tree-traversal refers to the process of visiting each node in a tree data structure, exactly once, in a systematic way. Such traversals are classified by the order in which the nodes are visited.

This is a complete Tree Traversal program which I wrote as requirement for my Discrete Mathematics subject in college. This program is written in in C/C++.

See the source codes below:

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <graphics.h>
#include <conio.h>
#include <string.h>

struct list
{
char num[3];
}
node[35];

void pre_order();
void in_order();
void post_order();
void enter_node();
void initialize();

char ch;
int x,X,stack[15],top,ptr;

void main()
{
while(1==1)
{
textattr(15+(0<<4)); clrscr();
window(3,2,78,24); textattr(15+(1<<4)); clrscr();

textattr(14+(1<<4));
gotoxy(25,4); cprintf("???<> TRAVERSAL PROGRAM <>???");
gotoxy(2,23); cprintf("<Enter a letter to choose>");
gotoxy(26,5); printf("Developed by JOEL BADINAS");
gotoxy(20,6); printf("As a requirement for Discrete Mathematics");

textattr(10+(1<<4));
gotoxy(32,12); cprintf("<*> MENU <*>");
textattr(7+(1<<4));
gotoxy(29,13); printf("???????????????????");
gotoxy(29,21); printf("???????????????????");
gotoxy(30,14); cprintf("[ ] - Preorder");
gotoxy(30,16); cprintf("[ ] - Inorder");
gotoxy(30,18); cprintf("[ ] - Postorder");
gotoxy(30,20); cprintf("[ ] - Quit");
textattr(14+(4<<4)+128);
gotoxy(31,14); cprintf(" P ");
gotoxy(31,16); cprintf(" I ");
gotoxy(31,18); cprintf(" O ");
gotoxy(31,20); cprintf(" Q ");
ch=0;
while(ch != 'P' && ch != 'I'&& ch != 'O'&& ch != 'Q')
{
ch=toupper(getch());
}
switch(ch)
{
case 'P': pre_order(); break;
case 'I': in_order(); break;
case 'O': post_order(); break;
case 'Q': exit(0);
default : printf("%c",7); exit(0);/*break;*/
}
}
}

void pre_order() /***********PRE_ORDER***********/
{
window(3,2,78,24); textattr(14+(1<<4)); clrscr();
textattr(10+(1<<4));
gotoxy(14,1); cprintf("?????????????<> PREORDER TRAVERSAL <>?????????????");
initialize(); enter_node();
gotoxy(1,15); cprintf("PREORDER : ");
ptr=1; top=1; stack[top]='\0';
while(ptr!='\0')
{
printf("%s ",node[ptr].num);
if(strcmp(node[ptr*2+1].num,"X")!=0)
{
top++; stack[top]=ptr*2+1;
}
if(strcmp(node[ptr*2].num,"X")!=0)
{
ptr=ptr*2;
}
else
{
ptr=stack[top]; top--;
}
}
getch();
}

void in_order() /**********IN_ORDER**********/
{
window(3,2,78,24); textattr(14+(1<<4)); clrscr();
textattr(10+(1<<4));
gotoxy(15,1); cprintf("?????????????<> INORDER TRAVERSAL <>?????????????");
initialize(); enter_node();
gotoxy(1,16); cprintf("INORDER : ");
ptr=1; top=1; stack[top]='\0';
IN_ORDER:
while(strcmp(node[ptr].num,"X")!=0)
{
top++;
stack[top]=ptr;
ptr=ptr*2;
}
ptr=stack[top]; top--;
while(ptr!='\0')
{
printf("%s ",node[ptr].num);
if(strcmp(node[ptr*2+1].num,"X")!=0)
{
ptr=ptr*2+1;
goto IN_ORDER;
}
ptr=stack[top]; top--;
}
getch();
}

void post_order() /**********POST_ORDER**********/
{
window(3,2,78,24); textattr(14+(1<<4)); clrscr();
textattr(10+(1<<4));
gotoxy(13,1); cprintf("?????????????<> POSTORDER TRAVERSAL <>?????????????");
initialize(); enter_node();
gotoxy(1,17); cprintf("POSTORDER : ");
ptr=1; top=1; stack[top]='\0';
POST_ORDER:
while(strcmp(node[ptr].num,"X")!=0)
{
top++;
stack[top]=ptr;
if(strcmp(node[ptr*2+1].num,"X")!=0)
{
top++;
stack[top]= -1*(ptr*2+1);
}
ptr=ptr*2;
}
ptr=stack[top]; top--;
while(ptr!='\0'&&ptr>0)
{
printf("%s ",node[ptr].num);
ptr=stack[top]; top--;
}
if(ptr<0)
{
ptr=ptr*-1;
goto POST_ORDER;
}
getch();
}

void enter_node()
{
window(3,2,78,24); textattr(7+(1<<4)); /*textattr(7+(1<<4));*/
gotoxy(2,23);
printf("Enter 'X' to indicate that a node has no LEFT/RIGHT child!");
gotoxy(2,5); cprintf("Enter root node : ");
gotoxy(45,5); scanf("%s",&node[1].num);
if(strcmp(node[1].num,"X")!=0)
{
gotoxy(2,6); cprintf("Enter children of %s : ",node[1].num);
gotoxy(35,6);scanf("%s",&node[1*2].num);
gotoxy(55,6);scanf("%s",&node[1*2+1].num);
}
if(strcmp(node[2].num,"X")!=0)
{
gotoxy(2,7); cprintf("Enter children of %s : ",node[2].num);
gotoxy(30,7);scanf("%s",&node[2*2].num);
gotoxy(40,7);scanf("%s",&node[2*2+1].num);
}
if(strcmp(node[3].num,"X")!=0)
{
gotoxy(2,7); cprintf("Enter children of %s : ",node[3].num);
gotoxy(50,7);scanf("%s",&node[3*2].num);
gotoxy(60,7);scanf("%s",&node[3*2+1].num);
}
if(strcmp(node[4].num,"X")!=0)
{
gotoxy(2,8); cprintf("Enter children of %s : ",node[4].num);
gotoxy(27,8);scanf("%s",&node[4*2].num);
gotoxy(33,8);scanf("%s",&node[4*2+1].num);
}
if(strcmp(node[5].num,"X")!=0)
{
gotoxy(2,8); cprintf("Enter children of %s : ",node[5].num);
gotoxy(37,8);scanf("%s",&node[5*2].num);
gotoxy(43,8);scanf("%s",&node[5*2+1].num);
}
if(strcmp(node[6].num,"X")!=0)
{
gotoxy(2,8); cprintf("Enter children of %s : ",node[6].num);
gotoxy(47,8);scanf("%s",&node[6*2].num);
gotoxy(53,8);scanf("%s",&node[6*2+1].num);
}
if(strcmp(node[7].num,"X")!=0)
{
gotoxy(2,8); cprintf("Enter children of %s : ",node[7].num);
gotoxy(57,8);scanf("%s",&node[7*2].num);
gotoxy(63,8);scanf("%s",&node[7*2+1].num);
}
}

void initialize()
{
int x;
for(x=1; x < 36; x++)
{
strcpy(node[x].num,"X");
}
}

Labels:

You can download, use and modify any source codes posted here in just one condition, that you give credit to this blog.
Technorati | del.icio.us | Digg it | Google | Netscape | StumbleUpon | Yahoo

Free Source Code: Visual Basic Hellow World Program

I know this is too newbie, but since "Hello World" programs are the standard program you are told to write when you are learning programming, I decided to put my own series using all the programming language I know.

This one is written in Visual Basic 6. To try this, open a Visual Basic project. In the default form, add a CommandButton control and in the code window add the source codes below. Now run the the program and click the "Say Hello World" button.

Private Sub Command1_Click()
MsgBox "Hello World!", vbInformation, "Free Source Codes"
End Sub

Private Sub Form_Load()
Command1.Caption = "Say Hello World"
End Sub

Labels:

You can download, use and modify any source codes posted here in just one condition, that you give credit to this blog.
Technorati | del.icio.us | Digg it | Google | Netscape | StumbleUpon | Yahoo

Free Source Code: Hello World Program

Hello World program is a software program that prints the phrase "Hello World" in an display device. If you are learning programming, you will encounter this kinds of programs as this is the introductory program that you are task to create.

Almost all programming language tutorials for beginners has this kind of program in the first few chapters.

In this post, I will integrate all the hello world programs that I have posted in this blog

Here's the list:

1) Java Hello World
2) Visual Basic Hello World

Labels:

You can download, use and modify any source codes posted here in just one condition, that you give credit to this blog.
Technorati | del.icio.us | Digg it | Google | Netscape | StumbleUpon | Yahoo

Free Source Code: Java Hello World Program

This is a running example of the Hello World program in written in Java. This is very simple. As you notice there is no import statement. This is because the java.lang classes that includes the System class is implicitly imported - meaning it is already import by Java and readily available for you to use. Of course, you can import it if you want, it will not cause an error in your program.

/* HelloWorld.java */

public class HelloWorld {

/** Creates a new instance of HelloWorld */
public HelloWorld() {
}

public static void main(String args[]){
System.out.println("Hello World!!!");
}
}

Labels:

You can download, use and modify any source codes posted here in just one condition, that you give credit to this blog.
Technorati | del.icio.us | Digg it | Google | Netscape | StumbleUpon | Yahoo

Tuesday, July 17, 2007

Free Source Code: How To Connect To A Database In Java

This source codes, written in Java, demonstrates how to connect to a database using JDBC and ODBC. The source codes is well commented for you to follow easily.

import java.sql.*;

public class jdbcConnect {
//CLASS CONSTRUCTOR
public jdbcConnect() {
}

//THIS PROC WILL SET THE CONNECTION TO THE DATABASE,
//QUERY AND PRINT THE RESULT TO THE STANDARD OUTPUT
private void loadData()
{
Connection con = null;
Statement stmt = null;
ResultSet rst = null;

//SET ERROR TRAP FOR CONNECTION TO THE DATABASE
try
{
//FOR ODBC CONNECTION
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
//dsn_employee = data source name(dsn)
//un = username
//pw = password
con = DriverManager.getConnection("jdbc:odbc:dsn_employee;
UID=un;PWD=pw");

//CHECK IF THE CONNECTION TO THE DATABASE IS SUCCESSFUL
if(!con.isClosed())
{
//MAKE THE ACTUAL CONNECTION TO THE DATABASE
stmt = con.createStatement(rst.TYPE_SCROLL_SENSITIVE,
rst.CONCUR_READ_ONLY);
//EXECUTE THE SQL QUERY
rst = stmt.executeQuery("SELECT fullname FROM employee");

//CHECK IF CURRENT ROW IS THE LAST
while(!rst.isLast())
{
//SET THE ERROR TRAP FOR READING THE RECORDSET
try
{
//GO TO THE NEXT RECORD OF THE RECORDSET
rst.next();
//PRINT THE RECORD TO THE STANDARD OUTPUT
System.out.println(rst.getInt("fullname"));
}
//HANDLE TRAPPED ERROR ON READING THE RECORDSET
catch(Exception e)
{
//PRINT THE ERROR MESSAGE
System.out.println("ERROR: " + e.getMessage());
}
}
}
}
//HANDLE TRAPPED ERROR ON DATABASE CONNECTION
catch(Exception e)
{
//PRINT THE ERROR MESSAGE
System.err.println("ERROR: " + e.getMessage());
}
finally
{
try
{
if(con != null)
{
//CLOSE THE CONNECTION
con.close();
}
}
catch(SQLException e)
{
//PRINT THE ERROR MESSAGE
System.out.println("ERROR: " + e.getMessage());
}
}
}

//START OF PROGRAM
public static void main(String[] args) {
jdbcConnect dbConnect = new jdbcConnect();
dbConnect.loadData();
}
}

Labels:

You can download, use and modify any source codes posted here in just one condition, that you give credit to this blog.
Technorati | del.icio.us | Digg it | Google | Netscape | StumbleUpon | Yahoo