Tuesday, September 10, 2013

Flaw in Google Translation

When i try to translate Number to Tamil Numbers, Google doesn't show the proper Tamil numbers.
I had attached my sample screen to this

Flaw in Google Translation.

Sample Old Tamil Number from Wikipedia:

Sample Old Tamil Number.




Sunday, June 30, 2013

How to solve this issue?

I have installed java 7 in windows 7 32 bit machine. and i have set all my class path properly. When i compiled it works good and when i run it get error message window like "There was a problem starting java. The specified module could not be found" . Check out sample screenshot below


If yo have the solution steps comment it here. Thank you.

Monday, May 20, 2013

Google Hacking Database

Google Hacking Database is called as 'googledorks'. Querying the Google for getting the secured information of the website by the hacker and also used to search for getting the most relevant result that what we are expected.
 Some Example searching query:
S.NoQueryDescription
1.Query filetype:pdfGetting all the result as pdf file.The are some other file format can specify doc,ppt,swf,..
2."Query"Get the exact match of the query that passed to google.
3.Query siteurl:www.example.comSearch the query only in that particular site.
4.inurl:"/root/etc/passwd" intext:"home/*:"Inurl is used for that URL string must contain the specified string and intext specifies that description text must contain that home/ and fallowed that any number of character.It is used for geting the linux user information of that domain.


For more information Check out this Hackers For Charity or Exploit database.

Tuesday, May 14, 2013

How this Keyword Work in this program and problem in returning object?


Consider the fallowing example.

public class TestingThis {

int a=0;
TestingThis(int b){
a=b;
}
public TestingThis myPrint(){
System.out.println("Your value is : " + this);
return this;
}
public String toString(){
return a +"";
}
public static void main(String args[]){
TestingThis ba=new TestingThis(10);
TestingThis ba1=new TestingThis(11);
ba1=ba.myPrint();
ba1.myPrint();
}
}


1) In above program how this keyword in return  statement returns and in print statement calls the toString method, How this work internally in java compiler?

2) In last line of the program ba1.myPrint() statement i didn't assign return value to any object,When compile this program didn't get any error and when run this program it work's fine.My question is,Where the return object is stored? How java compiler work for this?

Thursday, May 09, 2013

Give me the solution for this Hard-disk Problem.



I am using Windows Xp service Pack 2.Due to some problem I have tried to Format the System. When I tried to Format my system using Xp service Pack 2 , I got Partition  window and I Formatted my C drive and then continue my process, After that selection for OS I got an error Something like “Hard Disk May crash or Check out Power Cable”. I check out my power cable, it’s well. Then restart the machine same problem continues. So that gets into an idea of Backtrack Linux. I have made it live and Boot via USB. Work’s Fine. In terminal window I am trying Hard Disk via fdisk command and disktype command it shows error something like “disktype: data read failed at position 0”,” unable to read /dev/sda”.

Is it any chance to make it work via Backtrack or some other way ? 

If possible post you command here or mail (svelmuruganrvs@gmail.com) me the procedure document.

Friday, April 26, 2013

Why Eclipse show this error?

Program :-


class A
{
int a;
float b;
double c;
String s;
StringBuilder s1;
StringBuffer s2;
public A(int a,float b,double c,String s,StringBuilder s1, StringBuffer s2)
{
this.a=a;
b=(float) 9.0;
this.b=b;
this.c=c;
this.s=s;
this.s1=s1;
this.s2=s2;
}
public String toString(){
return a + " : " + b + " : " + c + ": " + s + ":" + s1+":"+s2;
}
}
public class ClassTestCopy {
public static void main(String[] args) {
A a=new A(1, 2, 3,null, new StringBuilder("Null"),new  StringBuffer("hello"));
A b=a;
System.out.println(a.toString());
System.out.println(b.toString());
}
}


Error in Eclipse:-
Exception in thread "main" java.lang.NoSuchMethodError: A.<init>(IFDLjava/lang/String;Ljava/lang/StringBuilder;Ljava/lang/StringBuffer;)V
at ClassTestCopy.main(ClassTestCopy.java:25)

Javac Ouput :-
1 : 9.0 : 3.0: null:Null:hello
1 : 9.0 : 3.0: null:Null:hello

But when compiled by myself using javac and when run using java compiler it working fine. Then what is the problem in Eclipse?

Error Screenshot :-

Error Shown by Eclipse

Wednesday, April 24, 2013

How this problem occur in Java?

Example Program :

public class TestME {
public static void main(String args[]) {
StringBuilder s=new StringBuilder("Hello");
StringBuffer s2=new StringBuffer("Hello");
String s1="Hello";
new StringTest(s);
new StringTest(s1);
new StringTest(s2);
System.out.println("String Builder :" + s);
System.out.println("String :" + s1);
System.out.println("String Buffer :" + s2);

Integer i=0;
IntegerTest t=new IntegerTest(i);
System.out.println(i);
}

}
class StringTest{
StringTest(String s){
s="Welcome";
}
StringTest(StringBuilder s) {
s=new StringBuilder("Welcome");
}
StringTest(StringBuffer s) {
s=new StringBuffer("Welcome");
}
}
class IntegerTest{
IntegerTest(Integer s){
s=10;
}
}


Integer and String are Reference type. Then When we pass an argument it will pass as Reference .Once we change the argument value then it will also affect in argument original value.In this program it will not change the original value.How this stuff work's? and also what is the Difference between StringBuilder and StringBuffer ?

Post your command in command box and also mention if anything went wrong in this post.

Program Output :-

String Builder :Hello
String :Hello
String Buffer :Hello
0

Excepted :-

String Builder :Welcome
String :Welcome
String Buffer :Welcome
10


Saturday, April 20, 2013

Print in different language using Java print statement.

Can any one help me how use different language other then the English in Java Input and output Statement without changing the System Language.And also help me how to use this method in GUI Application.  Post our programs in command window below.

Thursday, April 18, 2013

Perform mathematical operation using bitwise operator in java

Performing mathematical operation's without using bitwise  operator in java.

Program:-

public class WithoutOperator {

public static void main(String[] args) {
System.out.println(add(3,10));
System.out.println(subtract(13,10));
System.out.println(multiple(190,11));
System.out.println(divide(124,11));
swap(12,89);
System.out.println(abs(-1109));
System.out.println(abs(1109));
System.out.println(small(10,90));
System.out.println(small(10,9));
System.out.println(small(1,90));
System.out.println(small(10,10));
System.out.println(isEven(111));
}

public static int add(int first,int secon){
while (secon != 0)
   {
int carry =first & secon;
first = first ^ secon;
secon = carry << 1;
   }
return first;
}
public static int subtract(int first,int secon){
return (add(first, add(~secon, 1)));
}

public static int multiple(int first,int secon){
int i=0,m=0,k;
while(secon>0)
{
k=secon%2;
if(k==1)
m+=first<<i;
i++;
secon/=2;
}
return m;
}

public static int divide(int numerator, int denominator)
{
int mask = 0x1;
int quotient = 0;

while (denominator <= numerator) {
denominator <<= 1;
mask <<= 1;
}

while (mask > 1) {
denominator >>= 1;
mask >>= 1;
if (numerator >= denominator) {
numerator -= denominator;
quotient |= mask;
}
}

return quotient;
}

public static void swap(int first,int secon){
first=first^secon;
secon=first^secon;
first=first^secon;
System.out.println("First: " + first + " Second : " + secon);
}

public static int abs(int first){
return (first^((~((first>>31)&1))+1)) + ((first>>31)&1);
}

public static int small(int first,int secon){
int r= first ^ ((first ^ secon) & -(first << secon));
return r;
}

public static boolean isEven(int no){
return ((no&1)==0); //Anding the right most bit in the given number with 1
}
}

Addition:-


1) consider two number first=10 and secon=3.
2) Binary representation of the number :
first   : 01010
secon: 00011

a)Check the secon is 0 or not.If it's 0 then return first.else perform addition in fallowing ways.
b)Get the carry bit by andding the first and second number .


first   : 01010
secon: 00011 &
----------------
carry : 00010 -2
----------------

c) XOR first and second number.


first   : 01010
secon: 00011 XOR

--------------------
first   : 01001 - 9
--------------------

d) Shift 1 bit left to make add carry to next time.
carry: 00010 <<1
------------------
secon: 00100
-----------------
e) Continue the process until reminder get's 0.

In steps:
carry : 00000 (0)
first   : 01101 (13)
secon: 00000 (0)

add method : 

public static int add(int first,int secon){
while (secon != 0)
    {
// carry now contains common set bits of first and secon
int carry =first & secon;
// Sum of bits of first and secon where at least one of the bits is not set
first = first ^ secon;
// Carry is shifted by one so that adding it to first gives the required sum
secon = carry << 1;
    }
return first;
}

Subtraction :

1) Add - sign to second number using not operator.when we use not sign then It will stores as 1's compliment + 1. so we have add 1 to the negative number to get proper negative number.

so that we use add(-secon,1) and add the return negative value of the number to first to get subtract.

subtract method:

public static int subtract(int first,int secon){
return (add(first, add(~secon, 1)));
}

Multiplication :

1) If second number greater then 0 then perform this operation.
2) Check second number is even or not.If that is odd then shift the element left by i times,else do nothing.
3) Increment i and store second number by 2 of it's.


Multiplication method :

public static int multiple(int first,int secon){
int i=0,m=0,k;
while(secon>0)
{
k=secon%2;
if(k==1)
m+=first<<i;
i++;
secon/=2;
}
return m;
}


Division:

Click here to refer division.

Divide method:


Public static int divide(int numerator, int denominator)
{
int mask = 0x1;
int quotient = 0;

while (denominator <= numerator) {
denominator <<= 1;
mask <<= 1;
}

while (mask > 1) {
denominator >>= 1;
mask >>= 1;
if (numerator >= denominator) {
numerator -= denominator;
quotient |= mask;
}
}

return quotient;
}

Swap two number :

Already we discuss this topic in this blog. Click here to go to the page.

Swap method:


public static void swap(int first,int secon){
first=first^secon;
secon=first^secon;
first=first^secon;
System.out.println("First: " + first + " Second : " + secon);
}

Absolute :

It is for 32 bit integer operation.If the given number is negative then first bit of the number is 1.if that number is positive first bit is 0.
Right shift the given number to 32 times and then and-ding with 1 we get 1 if negative else 0 for the positive.and add 1 to the result based on the previous result.and not the result get's negative(computer stores it in 2's complement) and -1 for negative number and 0 for positive number.
when XOR the number with the -1(1111111....0) we get signed bit 0. and we get positive number with on reduced and finally add the number with reduced amount by previous operation we discussed.

Absolute method :
public static int abs(int first){
return (first^((~((first>>31)&1))+1)) + ((first>>31)&1);
}

Minimum number:

XOR first and second number and with - of the left shifted of first with second times and XOR with the first number to get minimum number.

Minimum function ::

public static int small(int first,int secon){
int r= first ^ ((first ^ secon) & -(first << secon));
return r;
}

Iseven number :
Negative number stores in 2's complement in memory and 'AND' with 1 get compared with right most bit and return the result 1 for odd and 0 for even.

Note:- Always odd number has 1 in right most bit.

Iseven method:
public static boolean isEven(int no){
return ((no&1)==0); //Anding the right most bit in the given number with 1
}


Friday, April 12, 2013

How can we write a program for this problem

Can any one help me ,how to write a program for this problem.

How to find the url name for the given IP address using java?

Example: 
Input IP : 173.194.38.180
Expected output : www.google.com

I have code the fallowing ways to find the url name of the given IP Address.

Code :-

import java.io.*;
import java.net.*;
public class IptoHost {
public static void main(String args[]) throws UnknownHostException{
InetAddress addr = InetAddress.getByName("173.194.38.180");
 String host = addr.getHostName();
 System.out.println(host);
}
}

This program output:
sin04s02-in-f20.1e100.net

Expected:
www.google.com

Let's help me how to map IP address to URL name.

post your program, comments and tips below.

Sunday, April 07, 2013

Read site or blog offline


1) Purchase Internet download Manager(IDM) or download a trial from Internet Download Manager
2) Install the IDM in your machine.
3) Open the IDM and fallow the steps given below.
4) Click Grabber button.

1. Grabber button.

5) Select Project Name and link you want to make offline readable.

1. Enter Project Name. 2. Link you want to make offline readable.

6) Select the location where you want to save the grabbed site and enable or select "convert the links in download html file to the local file for offline browsing"

1. Select Location. 

7) To make whole site offline readable then select "Explore the whole site" or mention depth of the link by clicking "Explore the specified number of link levels". 

1. Mention depth of the link to grab. 
or
1. To make whole site explore. 

8) Final steps of grabbing filter the file you want to grab select download fallowing files or select All file in filter option. and then click start downloading all matched files at once. And finally click finish to start grabbing.

1. Click the button "start downloading all matched files at once"

9) This is a final window for grabbing. once you finish close the window and open "index.html" in the location you saved to make offline readable.


Friday, March 29, 2013

Displaying the symbolic character in HTML

The following tables include symbolic character references for use in web pages. The content is taken from the official HTML Character entity references in HTML 4.

Example code :

HTML Code :
This page is &COPY; OR &#169; by http://velshare.blogspot.in

Output for the above code : 
This page is © OR © by http://velshare.blogspot.in.

this kind of symbols are can be refereed in your page using the fallowing symbol table.

Code reference :


nbsp &#160; no-break space, non-breaking space
iexcl &#161; ¡ inverted exclamation mark
cent &#162; ¢ cent sign
pound &#163; £ pound sign
curren &#164; ¤ currency sign
yen &#165; ¥ yen sign = yuan sign
brvbar &#166; ¦ broken bar = broken vertical bar
sect &#167; § section sign
uml &#168; ¨ diaeresis = spacing diaeresis
copy &#169; © copyright sign
ordf &#170; ª feminine ordinal indicator
laquo &#171; « left-pointing double angle quotation mark
not &#172; ¬ not sign
shy &#173; ­ soft hyphen = discretionary hyphen
reg &#174; ® registered sign = registered trade mark sign
macr &#175; ¯ macron = spacing macron = overline
deg &#176; ° degree sign
plusmn &#177; ± plus-minus sign = plus-or-minus sign
sup2 &#178; ² superscript two = superscript digit two
sup3 &#179; ³ superscript three = superscript digit three
acute &#180; ´ acute accent = spacing acute
micro &#181; µ micro sign
para &#182; pilcrow sign = paragraph sign
middot &#183; · middle dot = Georgian comma
cedil &#184; ¸ cedilla = spacing cedilla
sup1 &#185; ¹ superscript one = superscript digit one
ordm &#186; º masculine ordinal indicator
raquo &#187; » right-pointing double angle quotation mark
frac14 &#188; ¼ vulgar fraction one quarter
frac12 &#189; ½ vulgar fraction one half
frac34 &#190; ¾ vulgar fraction three quarters
iquest &#191; ¿ inverted question mark
Agrave &#192; À Latin capital letter A with grave
Aacute &#193; Á Latin capital letter A with acute
Acirc &#194; Â Latin capital letter A with circumflex
Atilde &#195; Ã Latin capital letter A with tilde
Auml &#196; Ä Latin capital letter A with diaeresis
Aring &#197; Å Latin capital letter A with ring above
AElig &#198; Æ Latin capital letter AE
Ccedil &#199; Ç Latin capital letter C with cedilla
Egrave &#200; È Latin capital letter E with grave
Eacute &#201; É Latin capital letter E with acute
Ecirc &#202; Ê Latin capital letter E with circumflex
Euml &#203; Ë Latin capital letter E with diaeresis
Igrave &#204; Ì Latin capital letter I with grave
Iacute &#205; Í Latin capital letter I with acute
Icirc &#206; Î Latin capital letter I with circumflex
Iuml &#207; Ï Latin capital letter I with diaeresis
ETH &#208; Ð Latin capital letter ETH
Ntilde &#209; Ñ Latin capital letter N with tilde
Ograve &#210; Ò Latin capital letter O with grave
Oacute &#211; Ó Latin capital letter O with acute
Ocirc &#212; Ô Latin capital letter O with circumflex
Otilde &#213; Õ Latin capital letter O with tilde
Ouml &#214; Ö Latin capital letter O with diaeresis
times &#215; × multiplication sign
Oslash &#216; Ø Latin capital letter O with stroke
Ugrave &#217; Ù Latin capital letter U with grave
Uacute &#218; Ú Latin capital letter U with acute
Ucirc &#219; Û Latin capital letter U with circumflex
Uuml &#220; Ü Latin capital letter U with diaeresis
Yacute &#221; Ý Latin capital letter Y with acute
THORN &#222; Þ Latin capital letter THORN
szlig &#223; ß Latin small letter sharp s
agrave &#224; à Latin small letter a with grave
aacute &#225; á Latin small letter a with acute
acirc &#226; â Latin small letter a with circumflex
atilde &#227; ã Latin small letter a with tilde
auml &#228; ä Latin small letter a with diaeresis
aring &#229; å Latin small letter a with ring above
aelig &#230; æ Latin small letter ae
ccedil &#231; ç Latin small letter c with cedilla
egrave &#232; è Latin small letter e with grave
eacute &#233; é Latin small letter e with acute
ecirc &#234; ê Latin small letter e with circumflex
euml &#235; ë Latin small letter e with diaeresis
igrave &#236; ì Latin small letter i with grave
iacute &#237; í Latin small letter i with acute
icirc &#238; î Latin small letter i with circumflex
iuml &#239; ï Latin small letter i with diaeresis
eth &#240; ð Latin small letter eth
ntilde &#241; ñ Latin small letter n with tilde
ograve &#242; ò Latin small letter o with grave
oacute &#243; ó Latin small letter o with acute
ocirc &#244; ô Latin small letter o with circumflex
otilde &#245; õ Latin small letter o with tilde
ouml &#246; ö Latin small letter o with diaeresis
divide &#247; ÷ division sign
oslash &#248; ø Latin small letter o with stroke
ugrave &#249; ù Latin small letter u with grave
uacute &#250; ú Latin small letter u with acute
ucirc &#251; û Latin small letter u with circumflex
uuml &#252; ü Latin small letter u with diaeresis
yacute &#253; ý Latin small letter y with acute
thorn &#254; þ Latin small letter thorn
yuml &#255; ÿ Latin small letter y with diaeresis

Mathematical symbols and Greek letters :

fnof &#402; ƒ Latin small f with hook = function
Alpha &#913; Α Greek capital letter alpha
Beta &#914; Β Greek capital letter beta
Gamma &#915; Γ Greek capital letter gamma
Delta &#916; Δ Greek capital letter delta
Epsilon &#917; Ε Greek capital letter epsilon
Zeta &#918; Ζ Greek capital letter zeta
Eta &#919; Η Greek capital letter eta
Theta &#920; Θ Greek capital letter theta
Iota &#921; Ι Greek capital letter iota
Kappa &#922; Κ Greek capital letter kappa
Lambda &#923; Λ Greek capital letter lambda
Mu &#924; Μ Greek capital letter mu
Nu &#925; Ν Greek capital letter nu
Xi &#926; Ξ Greek capital letter xi
Omicron &#927; Ο Greek capital letter omicron
Pi &#928; Π Greek capital letter pi
Rho &#929; Ρ Greek capital letter rho
Sigma &#931; Σ Greek capital letter sigma
Tau &#932; Τ Greek capital letter tau
Upsilon &#933; Υ Greek capital letter upsilon
Phi &#934; Φ Greek capital letter phi
Chi &#935; Χ Greek capital letter chi
Psi &#936; Ψ Greek capital letter psi
Omega &#937; Ω Greek capital letter omega
alpha &#945; α Greek small letter alpha
beta &#946; β Greek small letter beta
gamma &#947; γ Greek small letter gamma
delta &#948; δ Greek small letter delta
epsilon &#949; ε Greek small letter epsilon
zeta &#950; ζ Greek small letter zeta
eta &#951; η Greek small letter eta
theta &#952; θ Greek small letter theta
iota &#953; ι Greek small letter iota
kappa &#954; κ Greek small letter kappa
lambda &#955; λ Greek small letter lambda
mu &#956; μ Greek small letter mu
nu &#957; ν Greek small letter nu
xi &#958; ξ Greek small letter xi
omicron &#959; ο Greek small letter omicron
pi &#960; π Greek small letter pi
rho &#961; ρ Greek small letter rho
sigmaf &#962; ς Greek small letter final sigma
sigma &#963; σ Greek small letter sigma
tau &#964; τ Greek small letter tau
upsilon &#965; υ Greek small letter upsilon
phi &#966; φ Greek small letter phi
chi &#967; χ Greek small letter chi
psi &#968; ψ Greek small letter psi
omega &#969; ω Greek small letter omega
thetasym &#977; ϑ Greek small letter theta symbol
upsih &#978; ϒ Greek upsilon with hook symbol
piv &#982; ϖ Greek pi symbol
bull &#8226; bullet = black small circle
hellip &#8230; horizontal ellipsis = three dot leader
prime &#8242; prime = minutes = feet
Prime &#8243; double prime = seconds = inches
oline &#8254; overline = spacing overscore
frasl &#8260; fraction slash
weierp &#8472; script capital P = power set
image &#8465; Blackletter capital I = imaginary part
real &#8476; Blackletter capital R = real part symbol
trade &#8482; trade mark sign
alefsym &#8501; alef symbol = first transfinite cardinal
larr &#8592; leftwards arrow
uarr &#8593; upwards arrow
rarr &#8594; rightwards arrow
darr &#8595; downwards arrow
harr &#8596; left right arrow
crarr &#8629; downwards arrow with corner leftwards
lArr &#8656; leftwards double arrow
uArr &#8657; upwards double arrow
rArr &#8658; rightwards double arrow
dArr &#8659; downwards double arrow
hArr &#8660; left right double arrow
forall &#8704; for all
part &#8706; partial differential
exist &#8707; there exists
empty &#8709; empty set = null set = diameter
nabla &#8711; nabla = backward difference
isin &#8712; element of
notin &#8713; not an element of
ni &#8715; contains as member
prod &#8719; product = product sign
sum &#8721; summation
minus &#8722; minus sign
lowast &#8727; asterisk operator
radic &#8730; square root = radical sign
prop &#8733; proportional to
infin &#8734; infinity
ang &#8736; angle
and &#8743; logical and = wedge
or &#8744; logical or = vee
cap &#8745; intersection = cap
cup &#8746; union = cup
int &#8747; integral
there4 &#8756; therefore
sim &#8764; tilde operator = varies with = similar to
cong &#8773; approximately equal to
asymp &#8776; almost equal to = asymptotic to
ne &#8800; not equal to
equiv &#8801; identical to
le &#8804; less-than or equal to
ge &#8805; greater-than or equal to
sub &#8834; subset of
sup &#8835; superset of
nsub &#8836; not a subset of
sube &#8838; subset of or equal to
supe &#8839; superset of or equal to
oplus &#8853; circled plus = direct sum
otimes &#8855; circled times = vector product
perp &#8869; up tack = orthogonal to = perpendicular
sdot &#8901; dot operator
lceil &#8968; left ceiling = upstile
rceil &#8969; right ceiling
lfloor &#8970; left floor
rfloor &#8971; right floor
lang &#9001; left-pointing angle bracket
rang &#9002; right-pointing angle bracket
loz &#9674; lozenge
spades &#9824; black spade suit
clubs &#9827; black club suit = shamrock
hearts &#9829; black heart suit = valentine
diams &#9830; black diamond suit


For more reference about Character set Click here for wikipedia and Click here for HTML official Web site

Wednesday, March 27, 2013

Enable javascript

Chrome :

Select setting from chrome


Select custom setting from setting page.
In JavaScript section select allow option.




Internet Explorer:-

Select setting fro IE.

Select Security tab ad then select Custom level.


Select allow enable in active scripting section. 

Data hiding in notepad

1) Open a command prompt.
2) Change the directory where you want to place a text file.
3) echo secret message you want to hide into the text file > filename.txt:password
          echo is used for display the message in command prompt and fallowed by that message you want to display.
          > is used to redirection
          filename.txt is file name you want to save.
          and fallowed by that : and then password
4) After the above step open the file in notepad to view the message that you typed after the echo command.                                      It will not show any data in the notepad file.
5) To view the data in command prompt type  as more <filename.txt:password
more is used for getting the redirected contented of the file. in place of more you can use any dos command like dir,help etc, but output is not clear because that command produce there own output. but more will not produce any output.
< is used for getting the file content into the command
filename.txt is you message file file and fallowed by that : and password that you entered in created time.

sample output :

Wednesday, March 20, 2013

Get ip for the given host name using C


#include<stdio.h> //printf
#include<string.h> //memset
#include<stdlib.h> //for exit(0);
#include<sys/socket.h>
#include<errno.h> //For errno - the error number
#include<netdb.h> //hostent
#include<arpa/inet.h>

int hostname_to_ip(char *  , char *);

int main(int argc , char *argv[])
{
char *hostname = argv[1];
char ip[100];

if(argc <2)
{
printf("Please provide a hostname to resolve");
exit(1);
}



hostname_to_ip(hostname , ip);
printf("%s resolved to %s" , hostname , ip);

printf("\n");

}

/*
Get ip from domain name
 */

int hostname_to_ip(char * hostname , char* ip)
{
struct hostent *he;
struct in_addr **addr_list;
int i;

if ( (he = gethostbyname( hostname ) ) == NULL)
{
// get the host info
herror("gethostbyname");
return 1;
}

addr_list = (struct in_addr **) he->h_addr_list;

for(i = 0; addr_list[i] != NULL; i++)
{
//Return the first one;
strcpy(ip , inet_ntoa(*addr_list[i]) );
return 0;
}

return 1;
}

Saturday, March 09, 2013

Google Fun Again

Already i have posted one fun activity in Google in this blog.To access that Click here.

Now ,

Just type as zerg rush  in Google search box and hit a enter. The result shows as fallow.
 
To access this page Click here.

How to bind two software using build in windows tool

1) Open a Run window and type iexpress.

2) A IExpress Wizard will appear and in that select Extract files and run an installation command to create a new package.To make a extract-able package select Extract files only and to make ActiveX installation select create compressed file only. Now i am going to create a package.  

3) And then select Self Extracting Directive file for new creation if you have already created then select open existing self Extraction Directive file.



4) Give the package name for your application.

5) Select want to display a prompt before installing a software.If yes then enter a message to display.

6) If you want to display a license agreement then select a agreement license file

7) After that select a file you want to merge.

8) Now select which file you want to run first and after first which file you want to run it second select it. 

9) And final steps are select after completing the process what message would you like to display is just give it and then select save this setup if required in feature and setup creation save location also and  finally click finish now your setup will be ready.

Advantage :-
           We can create a package easily for our application.

Disadvantage :-
            Through the viruses can attach to some good software to make others computer harm.

How to protect from this kind of viruses?

Some Exe files are compressed format of the files. So just rename the exe file into zip and extract and check any viruses file is attached.If not then use a software or else delete it and use it.It's your's safty to protect your computer.
  


Wednesday, March 06, 2013

SQL 2000 Backup and restore

Command:
To back up:


BACKUP DATABASE db1 TO DISK = 'd:\db1.bak'

To restore:-

RESTORE FILELISTONLY FROM DISK = 'D:\db1.bak'


For graphical method video reference tutorial Click Here.

For Graphical method more reference Click here.

Creating database and tables automatically when software is installed

Procedure to create a database automatically when software is installed

1) Check the application is running first time or not.
2) If the application is running the first time then create a database and table.
3) If the application is second time then get the connection string and go to the code.

Implementation using c# code:-

1) To check the application is running first time or not as fallow method :

a) import the namespace to get access the registry value.
using Microsoft.Win32;

b) check the database have the connection string.


static Boolean isFirstLoadDB()
        {
//To access the HKEY_LOCAL_MACHINE/Software folder from the Registry
            RegistryKey key = Registry.LocalMachine.OpenSubKey("Software", RegistryKeyPermissionCheck.ReadWriteSubTree);

//To access the HKEY_LOCAL_MACHINE/Software/MySoftwareName key value from the registry.
            RegistryKey subKey = key.CreateSubKey("MySoftwareName", RegistryKeyPermissionCheck.ReadWriteSubTree);

            try
            {
//count number of keys and then return the value to the user.
                return subKey.ValueCount == 0 ? false : true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                subKey.Close();
                key.Close();
            }

        }


c) using the statement switch the form to set a settings or to run our project :


 if (isFirstLoadDB())
            {
//To access the our project
                Application.Run(new Form2());
            }
            else
            {
//To access setting page. In setting page get the sql server name and there settings from the client.
                Application.Run(new Form1());
            }


2) In step 1 we branch the code, If the application is the first time then code will hand over to the form1

Form1 :

a) Get the sql server name and there sql username and sql password from the user or client and then create a database using the master database in the sql with the user entered settings .

To create a databaseusing the master table from the C# ADO.NET.

SqlConnection tmpConn=new SqlConnection("Data Source=sqlservername;Initial Catalog=master;Integrated Security=True"); //connection string for master table 


  String sqlCreateDBQuery = "CREATE DATABASE " + create_Db_name; //Query for create a our table

 SqlCommand myCommand = new SqlCommand(sqlCreateDBQuery, Conn);

 myCommand.ExecuteNonQuery(); //Execute the query

b) After that create a connection string and store that connection string into the Registry or you can store that into the file.

Here i am going to store it in the Registry :

RegistryKey key = Registry.LocalMachine.OpenSubKey("Software", RegistryKeyPermissionCheck.ReadWriteSubTree);//To access the HKEY_LOCAL_MACHINE/Software
                                
RegistryKey subKey = key.OpenSubKey("MySoftwareName",RegistryKeyPermissionCheck.ReadWriteSubTree);//To access the HKEY_LOCAL_MACHINE/Software/MySoftwareName

subKey.SetValue("Connection String", connectionstring);//Store the connection string into the Registry.
                                subKey.Close(); //Close the open keys
                                key.Close();


Fig: Get settings from the user.


Form2: 

a) In this form get the connection string from the registry or from from File where you are stored.

Get the connection string 

RegistryKey key = Registry.LocalMachine.OpenSubKey("Software", RegistryKeyPermissionCheck.ReadWriteSubTree);//To access the HKEY_LOCAL_MACHINE/Software
            RegistryKey subKey = key.OpenSubKey("MySoftwareName", RegistryKeyPermissionCheck.ReadWriteSubTree);//To access the HKEY_LOCAL_MACHINE/Software/MySoftwareName
            String constr = subKey.GetValue("Connection String").ToString();//To get the connection string from the Registry.

Fig: Our project code.

Note :- To get access the project Click here to send the access request.