12/29/11

12/16/11

Java Graphics Tutorial II - Layouts

In the previous tutorial of Java Graphics, I explained about panels, frames and windows which we can put our items. But we didn't set the layout of the window , panel or frame in our last tutorial, what we did was we used the default layout.

Today in this tutorial we will be understanding about the different types on Layouts that are available for us to use and manipulate our GUI.


12/13/11

Python Tutorials : Data Types - NUMBERS

This Post is about numbers and mathematical operations. In this tutorial we shall be covering data types, operators and type conversion. To represent 'Numbers' in python, we have int, float, complex datatypes. For conditional statements, we have 'Bool' datatype

Type ipython on the Terminal ( Ctrl + Alt + T ) to start the interpreter :

$ ipython

12/10/11

Python Tutorial : Installing IPython (Ubuntu)

Hello Guys, Code 2 Learn starts off its Python Tutorial. Like Java, C++, C etc, Python is also a Programming Language. Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability.

IPython provides a rich toolkit to help you make the most out of using Python interactively. Its main components are:


  1. Powerful Python shells (terminal- and Qt-based).
  2. Support for interactive data visualization and use of GUI toolkits.
  3. Flexible, embeddable interpreters to load into your own projects.
  4. Tools for high level and interactive parallel computing.


12/3/11

Java Array tutorial with Examples

After seeing many people having doubt about using arrays (in Java) and how they are stored, when are they created etc. i decide to do a post on Arrays in Java, to give my readers a broader and clear view about Arrays declaration, creation and intialization.



Definition, Arrays are complex variablesthat store a group of values under a single variable name.

Declaring Arrays :


An array is imply a sequence of either objects or primitives, all of the same type and is put together under one identifier name. A specific element in an array is accessed by an index or subscript. The index of the array is in a continuous order whereas all array elements are stored at contiguous memory location.

You can declare arrays of any type, either primitive or class :

char[] s;
Point[] p; // Where Point is a class


In Java Programming language, creates a reference to the array that you can use to refer to an array. The actual memory used by the array element is allocated dynamically either by a new statement or by an array initializer.


11/26/11

Java Problem Set 2

Write a function which calculates the sum of even Fibonacci numbers.

public static void main(String args[]) {
    for(int i=1;i<22;i++)
        System.out.print(sumofEvenFibonacci(i) + " ");
}

public static long sumofEvenFibonacci(int n) {
    // add your code here.
    return sum;
}

prints

0 0 2 2 2 10 10 10 44 44 44 188 188 188 798 798 798 3382 3382 3382 14328



11/22/11

11/19/11

Java Graphics Tutorial - 1

As we all know that we can make games with the help of java libraries that provide us with the graphics needed for making them. So today I will be starting a very new section on Java Graphics. I had earlier made posts on How to make an income tax calculator.

To start with here are some prerequisites :

-You should have fair idea about java syntax because I am not going to teach that. Graphic Design College is a good educational resource in learning more about Java. 
-You should have Eclipse downloaded (anyone will do i.e Indigo, Galileo, Ganymede etc.)
- You should Download acm.jar file and include it into your project as an external jar file.




11/18/11

Java Certification (O1Z0-851) : uCertify

In today's world if you are an IT professional so you are bound to have certain certification to increase your value in the IT industry. So today I am going to review an uCertify Certification course for Java (O1Z0-851)

Before we proceed lets have an idea about uCertify. uCertify is one of the best in providing certifications of different languages, software ranging from Microsoft, Oracle, Cisco etc. It gives materials which has an in-depth information of the topics that are there, and these training materials are called 'prepKits'.


11/16/11

Java Tutorial : Exceptions in Java

An exception is a problem that arises during the execution of a program. An exception can occur for many different reasons, including the following:
  1. A user has entered invalid data.
  2. A file that needs to be opened cannot be found.
  3. A network connection has been lost in the middle of communications, or the JVM has run out of memory.


11/14/11

Static Keyword in Java

While you are programming you would want to use some class members independently of any object of that class. Normally a class member is accessed with the help of the object of that class. However, it is possible to create class members that can be used by itself. To create such a member, the keyword static has to precede its declaration. 


Multilingual SEO


Search Engine Optimization is very crucial for the success of any online business. With the help of SEO, you can get your website optimized in such a way that you receive good traffic inflow from your target audience.



11/12/11

H1 Tags in SEO

H1 tags are one of the most important part of SEO which is the header tag situated in body of a website. It can be termed as the most simple form of header found on a web page. Through h1 tags search engines come to know about the site content details.




Problem Set 3


The below questions are very interesting and amazing questions. So please do try it.

QUESTION 1

int a=5,*b=&a;
printf("%d",a**b);



11/11/11

5 Easy Ways to get Traffic from Facebook

This is my First Guest Post on Code 2 Learn. and my personal Blog is DailyTechTips for SEO and Wordpress Stuff.

No Doubt Facebook is the best Social Networking Site. It gets Millions of Daily Visits, so if seen from a Blogging eye, it can get tons of traffic to your Blog. Many use Facebook for Marketing and the results they reveal are too awesome. So just think to get huge traffic from Facebook.




Methods Explanation : Java Tutorial

A Java method is a collection of statements that are grouped together to perform an operation. When you call the System.out.println method, for example, the system actually executes several statements in order to display a message on the console.

Now you will learn how to create your own methods with or without return values, invoke a method with or without parameters, overload methods using the same names, and apply method abstraction in the program design.

Creating a Method : 

In general, a method has the following syntax:
 modifier returnValueType methodName(list of parameters) { 

  // Method body;

 }


11/10/11

Problem Set Java

 Predict the Output  


 Question 1


class Base {
    public void Print() {
        System.out.println("Base");
    }
}
class Derived extends Base {
    public void Print() {
        System.out.println("Derived");
    }
}
class Main{
    public static void DoPrint( Base o ) {
        o.Print();
    }
    public static void main(String[] args) {
        Base x = new Base();
        Base y = new Derived();
        Derived z = new Derived();
        DoPrint(x);
        DoPrint(y);
        DoPrint(z);
    }
}


11/8/11

Problem No.1

The below program is hideously slow. CAN YOU SPOT THE REASON?

public static void main(String args[]){
      Long sum=0L;
      for ( long i=0; i < Integer.MAX_VALUE; i++){
          sum += i;
      }
      System.out.println(sum);
}



11/4/11

Reading and Writing File in Java

Java like other programming languages supports both reading and writing of files. For reading purpose we use FileReader and for writing we use FileWriter.


FileReader Class :

The FileReader class creates a Reader that you can use to read the contents of a file. Its two most commonly used constructors are shown here:

FileReader(String filePath) 
FileReader(File fileObj)


11/3/11

Public static void main(String args[]){} : Explained


public static void main(String args[]){

}

Now lets understand why do we write the above statement, the way it is written above. 

Why not change it?

Before we move to the topic make sure you understand the Keyword Static, to learn about it here is our tutorial on Static Keyword in Java.

The public keyword is an access specifier, which allows the programmer to control the visibility of class members. When a class member is preceded by public, then that member may be accessed by code outside the class in which it is declared. (The opposite of public is private, which prevents a member from being used by code defined outside of its class.


Good Practices : Programming Tips Java

One of the Good practices while programming using Java is listed below.


Consider Static Factory Methods instead of Constructors

The normal way for a client to obtain an instance of itself is to provide a public constructor. But apart from this their is another technique which should be the part of every programmer's toolkit. A class can provide a static factory method, which is static method which returns the instance of the class.


Java Tutorial : What is a Class?

Java class is nothing but a template for object you are going to create or it’s a blue print by using this we create an object. In simple word we can say it’s a specification or a pattern which we define and every object we define will follow that pattern.


What does Java Class consist of :
  • When we create class in java the first step is keyword class and then name of the class or identifier we can say.
  • Next is class body which starts with curly braces {} and between this all things related with that class means their property and method will come here.



10/31/11

OOPs Concept : Polymorphism

Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.


Any java object that can pass more than on IS-A test is considered to be polymorphic. In Java, all java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.


It is important to know that the only possible way to access an object is through a reference variable. A reference variable can be of only one type. Once declared the type of a reference variable cannot be changed.


10/23/11

OOPs Concept : Inheritance

After discussing Encapsulation, now its time for 'Inheritance' as OOP Concept.


Inheritance can be defined as the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.


When we talk about inheritance the most commonly used keyword would be extends and implements. These words would determine whether one object IS-A type of another. By using these keywords we can make one object acquire the properties of another object.


10/12/11

Conditions of Parallelism : Data Dependence

In Parallel or Sequential Execution of programs there are some concepts of dependence that we need to understand. These dependencies are known as Data,Control and Resource Dependence.


Here I will be focusing on Data dependence.


Data Dependence :


It can be explained as the ordering relationship between statements. There are five kinds of data dependence :


10/9/11

Object Oriented Programming (OOP) Explanation

Object-oriented programming (OOP) is a programming paradigm that uses "objects" to design applications and computer programs. It utilizes several techniques from previously established paradigms, including inheritance, modularity, polymorphism, and encapsulation. Today, many popular programming languages (such as Ada, C++, Delphi, Java, Lisp, SmallTalk, Perl, PHP, Python, Ruby, VB.Net, Visual FoxPro, and Visual Prolog) support OOP. 


10/6/11

10/1/11

9/29/11

How to avoid multiple lines in TD tag?

In some situation (viewing in different browsers) the single <td> tag displays content in two lines. If you want to display sentence in single line always in all browsers then use <td> attributes ‘nowrap’

For example,you may want username/userid/Name to be displayed in single line, but due to some reason or different browser it will display in two lines like below,
username/userid
/Name .


9/24/11

HeapSort ( array Based) implementation in Java

There are two types of heaps. First one is Max heap and second one is Min heap. Heap (Max/Min) is a special type of binary tree.The roots of  the max heap is greater than its child roots. Other heap is Min heap it is also a special type of heap which has minimum root than his child. We can sort the array values using heap sorting algorithm. In this algorithm the heap build is used to rebuild the heap.


9/17/11

9/12/11

OOPs Concept: Encapsulation

Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction. RFAZHE7YNFV8

Encapsulation is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding.

9/7/11

Java Modifiers Summary

The Modifier class provides static methods and constants to decode class and member access modifiers. The sets of modifiers are represented as integers with distinct bit positions representing different modifiers.
RFAZHE7YNFV8


9/1/11

SortableStack implementation in Java

I am implementing an interface for Stack which will help to push and pop in O(n) time and help in finding the highest, lowest and the middle element in O(1) time.


I will be using Arraylist (since I m using a standard jdk 6 and not some other package) because with using this we can implement the above interface in the least possible time.

8/12/11

Create Linked List using Java

The LinkedList class extends AbstractSequentialList and implements the List interface. It provides a linked-list data structure. It has the two constructors, shown here: RFAZHE7YNFV8
LinkedList( )
LinkedList(Collection c)
The first constructor builds an empty linked list. The second constructor builds a linked list that is initialized with the elements of the collection c.


Create Linked List using C

Introduction

Linked list is one of the fundamental data structures, and can be used to implement other data structures. In alinked list there are different numbers of nodes. Each node is consists of two fields. The first field holds the value or data and the second field holds the reference to the next node or null if the linked list is empty.
image001.gif
Figure: Linked list


7/22/11

Insertion sort with program code and tutorial

Insertion sort is divided into two parts:
     1. Straight Insertion Sort
     2. Shell Sort 

Insertion sort is a simple sort algorithm, a comparison sort in which the sorted array [or list] is built one entry at a time. It is much less efficient on large lists than the more advanced  Algorithms such as Quick sort, Merge sort or Heap sort.


7/10/11

Java : Using JDBC API Tutorial

You need to use database drivers and the JDBC API while developing a Java application to retrive or store data in a database. The JDBC API classes and interfaces are available in the java.sql  and the javax.sql  packages.


The commonly used classes and interfaces in the JDBC API are :


DriverManager class : Loads the driver for a database.


7/5/11

Merge Sort using Java with program code

In computer science, merge sort or mergesort is a sorting algorithm for rearranging lists (or any such linear sequential data storage structure) into a specified order. It is a particularly good example of the divide and conquer algorithmic paradigm. It is a comparison sort. Merging is the process of combining two or more sorted files into a third sorted file.


Conceptually, merge sort works as follows:


1. Divide the unsorted list into two sublists of about half the size
2. Sort each of the two sublists
3. Merge the two sorted sublists back into one sorted list


7/1/11

6/28/11

Java : Encryption and Decryption of Data using AES algorithm with example code

There are many problems when you try encrypting a string such password, credit card nos, phone no. etc ie
1. which algorithm to use.
2. how to store the generated Key in the database.
3. should i use MD5, AES etc.

Here is the question to all your answers. After spending sometime on this i finally got the best algorithm that a person can use to encrypt and decrypt data while he/she also wants to store those encrypted strings and later on want to decrypt it while retrieving the data.


6/23/11

Microsoft SQL Server 2008 installation tutorial

Using Microsoft SQL Server 2008 for the first time for me was difficult because of it UI. So I thought I would make a post for the rest of the people.


MicrosoftCertifications requires an individual to know about installing, troubleshooting, and maintaining Microsoft’s many products, like the SQL server. 

Before we start I would recommend you should download the SQL Server 2008 Express, From Here. After you have downloaded SQL Server then download SQL Server 2008 Management Studio Express, Click here and if you have a 64-bit PC then please download the SQL Server Service Pack 1 or you do it by using windows update after installing everything.

6/21/11

Java Servlet Basics

Servlet Basics
Servlets are Java programs running on a web server that produce  results viewed remotely on a web server. Servlets has the same purpose that CGI or PHP had in the past.Here in this tutorial we are going to learn about servlet request and response model, its life cycle, error handling etc.


6/8/11

Image Processing : Morphology based Segmentation using MATLAB with program code


Segmentation or contouring could be also obtained using morphological operations. Segmentation subdivides an image into its constituent regions or objects. The level to which the subdivision is carried depends on the problem being solved. That is, segmentation should stop when the objects of interest in an application have been isolated. For example, in the automated inspection of electronic assemblies, interest lies in analyzing images of the products with the objective of determining the presence or absence of specific anomalies, such as missing components or broken connection paths. There is no point in carrying segmentation past the level of detail required to identify those elements.



5/23/11

Excel 2007 : Charts and Graphs tutorial

In Microsoft Excel, you can represent numbers in a chart. On the Insert tab, you can choose from a variety of chart types, including column, line, pie, bar, area, and scatter. The basic procedure for creating a chart is the same no matter what type of chart you choose. As you change your data, your chart will automatically update.


5/19/11

Excel Formulas and Formatting Data tutorial

Excel Formulas and Formatting Data You are familiar with the Excel 2007 . A major strength of Excel is that you can perform mathematical calculations and format your data. In this lesson, you learn how to perform basic mathematical calculations and how to format text and numerical data. To start this lesson, open Excel.


5/18/11

Java: Declaring Your own Exceptions tutorial

You can create your own exceptions in Java. Keep the following points in mind when writing your own exception classes:
  1. All exceptions must be a child of Throwable.
  2. If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class.
  3. If you want to write a runtime exception, you need to extend the RuntimeException class.


5/5/11

4/14/11

Income Tax Calculator

With many of people giving Income tax each year this application would be a cool application for them as this will calculate their Income Tax in just few seconds. Its a java application. What you need to do is just change the tax % every year and then import it using ECLIPSE IDE..

Eclipse IDE has this feature of importing project as executable jar files which help them to run just by double clicking on them.

4/4/11

3/6/11

Android Installation in Eclipse

Here is an Android App. that helps the user to change the ringing profile from SILENT to NORMAL and vice-versa in just a simple touch on the phone. No need to go to the setting and change the ringtone style over and over again when in office,college etc.


2/23/11

Symbol Table in Java

Symbol Table Definition :

In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is associated with information relating to its declaration or appearance in the source, such as its type, scope level and sometimes its location. 


2/14/11

Image Processing : Edge Detection of Image Using MATLAB

There are many operators in MATLAB for finding images
1. Sobels Operator
2. Roberts Operator
3. Prewitts Operator
4. Laplacian of Gaussian Method
5. Zero-Cross Method, etc..

To use them in MATLAB there is a function called as edge(I).


Syntax :

BW = edge(I)

BW = edge(I,'sobel')

BW = edge(I,'prewitt')
 
BW = edge(I,'roberts') etc.

Description : 

BW = edge(I) takes a grayscale or a binary image I as its input, and returns a binary image BW of the same size as I, with 1's where the function finds edges in I and 0's elsewhere.

By default, edge uses the Sobel method to detect edges but the following provides a complete list of all the edge-finding methods supported by this function:
  • The Sobel method finds edges using the Sobel approximation to the derivative. It returns edges at those points where the gradient of I is maximum.
  • The Prewitt method finds edges using the Prewitt approximation to the derivative. It returns edges at those points where the gradient of I is maximum.
  • The Roberts method finds edges using the Roberts approximation to the derivative. It returns edges at those points where the gradient of I is maximum.
  • The Laplacian of Gaussian method finds edges by looking for zero crossings after filtering I with a Laplacian of Gaussian filter.
  • The zero-cross method finds edges by looking for zero crossings after filtering I with a filter you specify.
  • The Canny method finds edges by looking for local maxima of the gradient of I. The gradient is calculated using the derivative of a Gaussian filter. The method uses two thresholds, to detect strong and weak edges, and includes the weak edges in the output only if they are connected to strong edges. This method is therefore less likely than the others to be fooled by noise, and more likely to detect true weak edges.
The parameters you can supply differ depending on the method you specify. If you do not specify a method, edge uses the Sobel method.

Example :

Find the edges of an image using the Prewitt , Sobel and Roberts methods.
 

i = imread('far.jpg');
I = rgb2gray(i);
BW1 = edge(I,'prewitt');
BW2= edge(I,'sobel');
BW3= edge(I,'roberts');
subplot (2,2,1);
imshow(I);
title('original');
subplot(2,2,2); 
imshow(BW1);
title('Prewitt');
subplot(2,2,3);
imshow(BW2);
title('Sobel');
subplot(2,2,4);
imshow(BW3); 
title('Roberts'); 
 




2/5/11

2/4/11

SQL : Structured Query Language (basics)

SQL stands for Structured Query Language is a database computer language used for managing data when used with application  in a Relational Database Management System (RDBMS).

There are many database software available which used the same query language. Some of them are Oracle, My SQL, DB2 etc. 
As the name suggest Structures Query language so it uses QUERY for retrieval of data from the database, and that query has a structure which is same for all databases software.


1/24/11

1/18/11

HTML Tag Reader : Flash Application

Here is an flash application which reads some of the html tag and then gives the desired result.

I have used Action Script 3 for this application.

In the application you will get to know the usage of action listener (event listener), then Use of URLRequest etc. The rest I have defined below.

1/17/11

Working with DOM , nodes and Objects (part 1) : Adding Nodes

JavaScript is an Object Oriented Programming (OOP) language.

An OOP language allows you to define your own objects and make your own variable types.

Note that an object is just a special kind of data. An object has properties and methods.

The HTML DOM is a W3C standard and it is an abbreviation for the Document Object Model for HTML.


The HTML DOM defines a standard set of objects for HTML, and a standard way to access and manipulate HTML documents.


1/14/11

Signal Program using parent-child in UNIX

Let us now write a program that communicates between child and parent processes using kill() and signal().

fork() creates the child process from the parent. The pid can be checked to decide whether it is the child(==0) or the parent (pid = child process id).

The parent can then send messages to child using the pid and kill().

The child picks up these signals with signal() and calls appropriate functions. 


Two processes comunicating via shared memory in UNIX

We develop two programs here that illustrate the passing of a simple piece of memery (a string) between the processes if running simulatenously:
server.c
-- simply creates the string and shared memory portion.
client.c
-- attaches itself to the created shared memory portion and uses the string (printf).


1/13/11

Computer graphics : Hidden Surface Elimination

BACKFACE DETECTION: 
In a solid object, there are surfaces which are facing the viewer (front faces) and there are surfaces which are opposite to the viewer (back faces).

These back faces contribute to approximately half of the total number of surfaces. Since we cannot see these surfaces anyway, to save processing time, we can remove them before the clipping process with a simple test.


1/11/11

UML : Interaction Diagrams with Example

  • An interaction diagram is a graphical representation of how objects interact with one another in a scenario.
  • They capture the behavior of a single use case, showing the pattern of interaction among objects.
  • Objects communicate in an interaction diagram by sending messages.
  • Sending a message typically corresponds to invoking a method or function, where the message name is the name of the method.
  • A message may carry data as parameters being passed.


1/10/11

UML : StateChart Diagram with Example

This is a concept in Object Oriented Software Engineering, which is used to describe the behavior of the system.


State diagrams require that the system described is composed of a finite number of states; sometimes.


The below is an state chart diagram of  An Airline reservation system. I hope this helps people to solve their doubt about State Chart Diagram. For Interaction Diagram