Javascript OOP like Java

Javascript doesn’t really have the concept of Class and Object like we use in other languages like Java or C#, but we can still achieve such thing.

For example, in Java we could create a simple class like this:

 Java |  copy code |? 
01
02
class ClassName {
03
 
04
	private String privateProperty = 'Im a private property';
05
	public String publicProperty = 'Im a public property';
06
 
07
	public ClassName(constructorParam) { 
08
		// Constructor
09
	}
10
 
11
	private void privateMethod() {
12
		System.out.println("Private method");
13
	}
14
 
15
	public void publicMethod() {
16
		System.out.println("Public method");
17
		// We can call private properties
18
		System.out.println(privateProperty);
19
		// Either private methods
20
		privateMethod();
21
	}
22
 
23
}
24
 
25
ClassName instance = new ClassName("Here goes something to constructor");
26
instance.publicMethod();
27

Now translating to Javascript

 Javascript |  copy code |? 
01
02
var ClassName = function(constructorParam) {
03
 
04
	var privateProperty = 'Im a private property';
05
	this.publicProperty = 'Im a public property';
06
 
07
	function privateMethod() {
08
		console.log('Private method');
09
	}
10
 
11
	this.publicMethod = function() {
12
		console.log('Public method');
13
		// We can call private properties
14
		console.log(privateProperty);
15
		// Either private methods
16
		privateMethod();
17
	}
18
 
19
}
20
 
21
var instance = new ClassName('Here goes something to constructor');
22
instance.publicMethod();
23

This way we can use a similar concept of OOP.

Solving the famous Tomcat 404 error

There are several causes for this problem, but the most common cause is because the project is not correctly configured to point to the server. So, let’s do it!

First of all, make sure the server is stopped, otherwise you won’t be able to do any change. If it is running, just right click the server > Stop.

Eclipse Tomcat Server

 

After that, right click the server > Add and Remove… In the window that will appear, move your project to the RIGHT side.

Tomcat Add and Remove...

 

 

Let’s now clean the Tomcat work directory just to make sure that we don’t have any old file that can conflict. Right click on the server > Clean Tomcat Work Directory

Clean Tomcat Work Directory

 

Now let’s open up the properties window (Alt+Enter) or right click on the server > Properties

Tomcat properties

 

Click Switch Location, it will point the project to the right server location. Sometimes you need to press Switch Location twice.

Tomcat properties window

 

That’s it! Now you hopefully can access your application!

Google can now translate handwritten notes

Google Translator

Say you have some scribbles in an unfamiliar language you want to translate. Better find a native speaker. Or you could just turn to Google Translate, which now supports handwritten translation in 45 different languages.

It’s insanely simple. Go to the Google Translate page, select the language you’re working with, and go to the menu on the bottom left of the input window and select the pencil icon. You can then write out what you’re trying to translate, and Google will interpret. You could definitely see this being useful for translating notes or symbols from character-based languages if you don’t know how to actually type the word on your keyboard. Even if your handwriting is elementary-level chicken scratch.

Read more at GizModo: http://gizmodo.com/google-can-now-translate-handwritten-notes-908595682