Monday, 26 December 2011

Car racing Game: Source code Step by Step - 1

I know that looking at plain code is not desirable, so just keep this code with you and wait for few days. The game, car racing, will be completed in few days. Just as i said, it is pain in the ass looking at the code that doesn't have an explanation but if you pay attention and need any help, i would gladly support you in any way.
I'm ready to explain every single line if you require. But first complete the game, and execute the game.
First thing is first.
So here code comes.

Tuesday, 20 December 2011

Car racing Game: Source code Step by Step - 0

I mentioned about developing car racing game earlier. So now i think i will supply the source code of it. Since it ain't small program, i'll make it several parts.
Here, i start with the main function, and next time i will add all necessary classes and its methods.
So, main function comes as follows

Wednesday, 7 December 2011

C#: System data types

C#
Shorthand
System Type
Range
Meaning in life
sbyteSystem.Sbyte -128 to 127Signed 8-bit number
byteSystem.byte 0 to 255Unsigned 8-bit
number
shortSystem.Int16 -32.768 to 32.767Signed 16-bit number
ushortSystem.UInt16 0 to 65.535Unsigned
16-bit number
intSystem.Int32 -2.147.483.648 to
2.147.483.647
Signed 32-bit
number
uintSystem.UInt32 0 to 4,294,967,295Unsigned
32-bit number
longSystem.Int64 –9,223,372,036,854,775,808
to
9,223,372,036,854,775,807
Signed 64-bit
number
ulongSystem.UInt64 0 to
18,446,744,073,709,551,615
Unsigned
64-bit number
charSystem.Char U0000 to UffffA single 16-bit
Unicode character
floatSystem.Single 1.5x10-45 to 3.4x103832-bit floating
point number
doubleSystem.Double 5.0x10-324 to 1.7x1030864-bit floating
point number
boolSystem.Boolean true or falseRepresents
truth or falsity
decimalSystem.Decimal 100 to 1028A 96-bit signed
number
stringSystem.String Limited by system memoryRepresents a
set of Unicode
characters
objectSystem.Object Any type can be stored
in an object variable
The base class of all
types in the .NET
universe

Saturday, 3 December 2011

PHP: Validating email address.

function emailValidate($email)
{
   if(!eregi("^[a-z]+[a-z0-9_-]*(\.[a-z0-9_-]+)*@[a-z0-9]+
      (\.[a-z0-9_-]+)*\.(\.[a-z]+){2,}$",$email))
  {
      return true;
  }
  return false;
}

eregi case insensitive regular expression math.

Friday, 2 December 2011

log2( x ): Binary Logarithm

In the math.h of Turbo C, binary logarithm ( log2( ) ) doesn't exists. When we are working with tree, we need to calculate depth of the tree, as well as the number of nodes in that depth.
The number of nodes in ith depth can be calculated using : 2i . formula
the max number of node in ith depth : n = 2i - 1 (complete tree).
You can use these formula to find the number of nodes in particular depth.

On the other hand, you may need to find the depth you are currently in.
There is a very easy way to do that. This is using binary logarithm to find the current depth.

...
#include <math.h>
double log2(double x)
{
       return log(x) / log(2);
}

If i made mistakes let me know
Good luck

Wednesday, 30 November 2011

PHP: data grid view

Lets demonstrate how to show data in data grid view using php.
When we are working on website, one of the most important things is to show the data in brief and in a nice way
To do that combining HTML tags along with php.
Now lets see small example

Tuesday, 29 November 2011

Binary Search

Very useful searching algorithm, in every step the number of data, which is going to be sorted will cut into half (fig 1). But keep it in your mind that it works on only sorted data.
Let N be the number of data then,
in worst case the comparison will be done log2(N) + 1 times. And in case of linear searching, the number of comparison would be N.
For example: if we are going to search a number among a million others, in the worst case scenario, the number of comparison would never be exceeded 20. But in case of linear searching algorithm, the number of comparison would be 1.000.000

Source code :

Saturday, 26 November 2011

Indian Wedding (Photos)

This is the wedding of one of the biggest college's principal's daughter. There was everything that you could possible eat in India, Most important thing is that they are all free hehe. I mean food




Tuesday, 10 May 2011

PHP : Login Page


Here is simple guide to create login page. About design, you can create one as you like using html. This is simple design that i created to demonstrate how login page works. You can use just two text-boxes and submit button, that is all.

Make sure that your text-boxes and submit button are inside the "Form" which uses method field and action field as shown below.

<Form name="Form1" method="post" action="login.php"> ...
When you hit login or submit button, all data which are inside this form will be thrown to login.php.
And they won't appear in address bar. Because method is post.

Saturday, 23 April 2011

C/C++ : Quick Sort

Here is the source code of quick sort. This algorithm also knowns as most efficient search algorithm.
I don't know why but it doesn't work appropriately. It works on 100 data but more than that it crushes.
If you find bug let me know, thank you.

I've used Hoare-partition
Here is the code.

int partition( int a[ ]int low, int high )
{
    int piwot, right, left;
    left = low + 1 ;
    right = high ;
    piwot = alow ];
    while(1)
    {
        while( aright ] > piwot ) right--;
        while( a[ left ] < piwot &&a left < high ) left++;
        if ( left < right )
            swap( a, left, right );
        else{
            swap( a, low, right );
            return right;
        }
    }
}

void quickSort( int a[ ]int low, int high)
{
    int part;
    if( low &lt; high )
    {
        part = partition( a, low, high );
        quickSort( a, low, part -1 );
        quickSort( a, part +1, high );
    }
}

Tuesday, 19 April 2011

C# : Detecting cursor position in RichTextBox

When i was working on RichTextBox the main thing that i had to handle was counting lines and detecting cursor position. Now lets see how to get these things done. Let me tell you about how to detect cursor position.

You need to use:
RichTextBox.SelectionStart and RichTextBox.GetLineFromCharIndex()
But make sure you use instance method of RichTextBox class as show
here :GetLineFromCharIndex[^] and GetLineFromCharIndex[^]
    
private static int EM_LINEINDEX = 0xbb;

int index, line, col;

[DllImport("user32.dll")]

extern static int SendMessage(IntPtr hwnd, int message, int wparam, int lparam);   


[DllImport("user32.dll")]
This line of code shouldn't be written in any method or functions.
You will find detailed explanation here:
 DllImportAttribute[^]

Monday, 18 April 2011

"Love" from Chicken Soup for the Soul

Love: The One Creative Force
Spread love everywhere you go: first of all in your own house. Give love to your children, to your wife or husband, to a next door neighbor. . . . Let no one ever come to you without leaving better and happier. Be the living expression of God's kindness; kindness in your face, kindness in your eyes, kindness in your smile, kindness in your warm greeting.
Mother Teresa

A college professor had his sociology class go into the Baltimore slums to get case histories of 200 young boys. They were asked to write an evaluation of each boy's future. In every case the students wrote, "He hasn't got a chance." Twenty-five years later another sociology professor came across the earlier study. He had his students follow up on the project to see what had happened to these boys. With the exception of 20 boys who had moved away or died, the students learned that 176 of the remaining 180 had achieved more than ordinary success as lawyers, doctors and businessmen.
The professor was astounded and decided to pursue the matter further. Fortunately, all the men were in the area and he was able to ask each one, "How do you account for your success?" In each case the reply came with feeling, 'There was a teacher."
The teacher was still alive, so he sought her out and asked the old but still alert lady what magic formula she had used to pull these boys out of the slums into successful achievement.
The teacher's eyes sparkled and her lips broke into a gentle smile. "It's really very simple," she said. "I loved those boys."
Eric Butterworth