Wednesday, July 6, 2011
Google translate api version 2 curl problem fix
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-HTTP-Method-Override: PUT') );
Monday, June 13, 2011
File upload download from windows to linux or linux to windows
Local server windows to linux server file upload or linux server to window through PSCP steps are follow,
Requriement.
1. pscp.exe (288 kb this size file working)
2. putty.exe (may needed)
1. open DOS prompt
2. set environment variable path
eg: c:>set PATH=%PATH%;"D:\pscp-path\" and enter
3. d:>pscp-path>pscp enter you can see the option of pscp
4. upload/downlod to server
eg:
pscp yourfile root@yourhost:/serverfolder
pscp root@yourhost:/fromserverfolder d:\your path
Requriement.
1. pscp.exe (288 kb this size file working)
2. putty.exe (may needed)
1. open DOS prompt
2. set environment variable path
eg: c:>set PATH=%PATH%;"D:\pscp-path\" and enter
3. d:>pscp-path>pscp enter you can see the option of pscp
4. upload/downlod to server
eg:
pscp yourfile root@yourhost:/serverfolder
pscp root@yourhost:/fromserverfolder d:\your path
Monday, May 16, 2011
copy folder sub folder with symbolic links in dos
XCOPY xampp\htdocs\lifein\eflifein\*.* d:\rajendram_aptana_workspace\lifein\eflifein\*.* /e /s /B
Sunday, May 15, 2011
Javascript Regular expression example for lifein
var cname ="Visit hellow big Ben Test";
var search_txt = "Big ben RamRaj";
var searchOpt = "Big ben RamRaj";
searchOpt = searchOpt.replace(/ /gi, "|");
cname = cname.toLowerCase();
search_txt = search_txt.toLowerCase();
searchOpt = searchOpt.toLowerCase();
console.log(searchOpt);
var rg = new RegExp(search_txt,'i');
var rgOpt = new RegExp(searchOpt,'i');
if (cname.search(rg)>=0) {
console.log('exists option 1');
} else if (cname.search(rgOpt)>=0) {
console.log('exists option 2');
} else {
console.log('not exists '+search_txt);
}
var search_txt = "Big ben RamRaj";
var searchOpt = "Big ben RamRaj";
searchOpt = searchOpt.replace(/ /gi, "|");
cname = cname.toLowerCase();
search_txt = search_txt.toLowerCase();
searchOpt = searchOpt.toLowerCase();
console.log(searchOpt);
var rg = new RegExp(search_txt,'i');
var rgOpt = new RegExp(searchOpt,'i');
if (cname.search(rg)>=0) {
console.log('exists option 1');
} else if (cname.search(rgOpt)>=0) {
console.log('exists option 2');
} else {
console.log('not exists '+search_txt);
}
Monday, May 9, 2011
MySQL prepare statement
mysql> PREPARE stmt_name FROM "SELECT name FROM Country WHERE code = ?";
Query OK, 0 rows affected (0.09 sec)
Statement prepared
mysql> SET @test_parm = "FIN";
Query OK, 0 rows affected (0.00 sec)
mysql> EXECUTE stmt_name USING @test_parm;
+---------+
| name |
+---------+
| Finland |
+---------+
1 row in set (0.03 sec)
mysql> DEALLOCATE PREPARE stmt_name;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.09 sec)
Statement prepared
mysql> SET @test_parm = "FIN";
Query OK, 0 rows affected (0.00 sec)
mysql> EXECUTE stmt_name USING @test_parm;
+---------+
| name |
+---------+
| Finland |
+---------+
1 row in set (0.03 sec)
mysql> DEALLOCATE PREPARE stmt_name;
Query OK, 0 rows affected (0.00 sec)
What is an abstract class, and when should it be used?
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods. Let's look at an example of an abstract class, and an abstract method.
Suppose we were modeling the behavior of animals, by creating a class hierachy that started with a base class called Animal. Animals are capable of doing different things like flying, digging and walking, but there are some common operations as well like eating and sleeping. Some common operations are performed by all animals, but in a different way as well. When an operation is performed in a different way, it is a good candidate for an abstract method (forcing subclasses to provide a custom implementation). Let's look at a very primitive Animal base class, which defines an abstract method for making a sound (such as a dog barking, a cow mooing, or a pig oinking).
public abstract Animal
{
public void eat(Food food)
{
// do something with food....
}
public void sleep(int hours)
{
try
{
// 1000 milliseconds * 60 seconds * 60 minutes * hours
Thread.sleep ( 1000 * 60 * 60 * hours);
}
catch (InterruptedException ie) { /* ignore */ }
}
public abstract void makeNoise();
}
Note that the abstract keyword is used to denote both an abstract method, and an abstract class. Now, any animal that wants to be instantiated (like a dog or cow) must implement the makeNoise method - otherwise it is impossible to create an instance of that class. Let's look at a Dog and Cow subclass that extends the Animal class.
public Dog extends Animal
{
public void makeNoise() { System.out.println ("Bark! Bark!"); }
}
public Cow extends Animal
{
public void makeNoise() { System.out.println ("Moo! Moo!"); }
}
Now you may be wondering why not declare an abstract class as an interface, and have the Dog and Cow implement the interface. Sure you could - but you'd also need to implement the eat and sleep methods. By using abstract classes, you can inherit the implementation of other (non-abstract) methods. You can't do that with interfaces - an interface cannot provide any method implementations.
Suppose we were modeling the behavior of animals, by creating a class hierachy that started with a base class called Animal. Animals are capable of doing different things like flying, digging and walking, but there are some common operations as well like eating and sleeping. Some common operations are performed by all animals, but in a different way as well. When an operation is performed in a different way, it is a good candidate for an abstract method (forcing subclasses to provide a custom implementation). Let's look at a very primitive Animal base class, which defines an abstract method for making a sound (such as a dog barking, a cow mooing, or a pig oinking).
public abstract Animal
{
public void eat(Food food)
{
// do something with food....
}
public void sleep(int hours)
{
try
{
// 1000 milliseconds * 60 seconds * 60 minutes * hours
Thread.sleep ( 1000 * 60 * 60 * hours);
}
catch (InterruptedException ie) { /* ignore */ }
}
public abstract void makeNoise();
}
Note that the abstract keyword is used to denote both an abstract method, and an abstract class. Now, any animal that wants to be instantiated (like a dog or cow) must implement the makeNoise method - otherwise it is impossible to create an instance of that class. Let's look at a Dog and Cow subclass that extends the Animal class.
public Dog extends Animal
{
public void makeNoise() { System.out.println ("Bark! Bark!"); }
}
public Cow extends Animal
{
public void makeNoise() { System.out.println ("Moo! Moo!"); }
}
Now you may be wondering why not declare an abstract class as an interface, and have the Dog and Cow implement the interface. Sure you could - but you'd also need to implement the eat and sleep methods. By using abstract classes, you can inherit the implementation of other (non-abstract) methods. You can't do that with interfaces - an interface cannot provide any method implementations.
Saturday, January 15, 2011
PHP code refactoring - is my understading
1. If existing code has redundant code, I will create common method or class for that & I will call wherever I want.
2.Code Indentation: So that any user can easily understand the hierarchy of the codes.
3.Include comments for each functionality, in order to clearly explain what the particular code is all about.
4.Code simplicity like avoiding generation of unnecessary loops to fetch a single value.
5.While fetching records from the database, its best to avoid select * and instead add particular field names like "select username", "select password".
6. It is very helpful to use "Extract" keyword for parse the array-based outputs using Ajax. For example there would be no need to get connected to the database every time.
Ref: http://www.macronimous.com/resources/the_need_for_PHP_code_refactoring.asp
2.Code Indentation: So that any user can easily understand the hierarchy of the codes.
3.Include comments for each functionality, in order to clearly explain what the particular code is all about.
4.Code simplicity like avoiding generation of unnecessary loops to fetch a single value.
5.While fetching records from the database, its best to avoid select * and instead add particular field names like "select username", "select password".
6. It is very helpful to use "Extract" keyword for parse the array-based outputs using Ajax. For example there would be no need to get connected to the database every time.
Ref: http://www.macronimous.com/resources/the_need_for_PHP_code_refactoring.asp
Subscribe to:
Comments (Atom)