Search My Blog

Wednesday, September 4, 2013

HTTPS and why is it needed?

I never quite paid attention to why we need HTTPS connections. I knew it is a secure connection, but that's about it. I never thought why we need a secure connection, or why the normal HTTP connection was a problem in the first place.

Well, when someone has access to data you send over the network, he can read raw data and re-assemble the data which could be sensitive. Suppose you are on a wifi network, and someone on the same network uses a packet capturing software, he can easily see your data sent over the network. Same is the case with wired connections, but it is far more difficult to capture packets on a wired connection.

Now, suppose you are using a traditional HTTP connection, all your data is raw data. If you encrypt it using HTTPS, the eavesdropper can still capture your data, but it wont be of much use to him, since it is encrypted.

Hence, public wifi networks warn you before logging in to their networks, saying "this network does not use a secure connection, your data may be visible to others". These public networks do no generally have passwords, and hence, the warning.

Most websites today have HTTPS connections, like banking websites, and social networking sites. Check FB and BOA.

Other options include VPN, etc which I am not totally familiar with.

Saturday, August 17, 2013

static and final fields in an abstract class and an interface

The fields in an interface can be static and final only.
Static because, the interface cannot be instantiated, hence no point having non static fields.
Final because, the interface logic should be non mutable.

However, fields in an abstract class can be non static and non final.
Why?
Abstract class cannot be instantiated, so why we need non static fields?
Final?

Saturday, July 20, 2013

Serialization in Java

From StackOverflow,
The process to convert an object instance, into a sequence of bytes ( which may be binary or not depends on the implementation ) . It is very useful when you want to transmit one object data across the network, for instance from one JVM to another.
How else is data stored otherwise, if not in bytes?

Some detailed implementation here : http://www.javacodegeeks.com/2013/03/serialization-in-java.html

Wednesday, February 20, 2013

What I learnt today

How to connect to MySQL database from PHP using XAMPP

The use of mysqli_ function in php - all calls to the mysqli must be uniform throughout the script. there should not be calls to mysql instead of mysqli

How to use session variables to manage logged in user in PHP.

How to encrypt passwords using md5 and sha1 in PHP. sha1 works only on newer versions of PHP, md5 is more general

some useful PHP functions

- addslashes(string) - adds escape slashes to all special characters

for example,
$title = "Shantanu's Page";
$title = addslashes($title) // $title will be assigned "Shantanu\'s Page"

XAMPP configuration parameters

MySQL - my.conf
max_connections -max connections allowed to the SQL server(used in connection with MaxClients parameter in Apache)

Apache - httpd.conf
MaxClients - max connections allowed(used in connection with max_connections in MySQL server)

Tuesday, February 19, 2013

PHP Tips

- Single and double quotes

Everything within single quotes is considered a literal.
Double quotes replaces variable names with literal values.

So,

echo "print $variablename"; // OUTPUT : print 20 (assuming $variablename contains value 20)
echo 'print $variablename'; // OUTPUT : print $variablename

- Data types in PHP
integer, float, string, boolean, array, object

- Constants

define('CONSTNAME', value);  //uppercase convention

Usage
echo 'value of constant is ' . CONSTNAME; //$ is not used

- Execution Operator

`command` within the ` ` characters executes the command and returns the output as it would to the system.

for example,
$out = `ls -a` would return the directory listing to $out
The <pre></pre> tag in html preserves formatting, so each directory is listed on a new line(try it)
echo "<pre>" .$out. "</pre>";

- if elseif else alternate syntax

if condition :
//
elseif condition :
//
else :
//
endif;










Saturday, February 16, 2013

facebook apps development options

https://developers.facebook.com/docs/guides/web/ describes adding Facebook capabilities to websites. See the Getting Started with Apps on Facebook.com guide if you instead want to integrate your app directly into the core Facebook experience.

Friday, February 15, 2013

creating a web application with google app engine

I am trying to build an app on the google app engine, using Eclpise

Important Points
---> Any external libraries you add must be added in two places
1) The build path of your project - this is for the compiler on your local machine
2) war directory under war->lib - this is for the application when it is deployed on the webserver. It does not have access to your local library files after it is deployed.

Step by Step Process

1) Create a new Web Application Project
2) Create an application on the google app engine page https://appengine.google.com/ after you sign-in
3) Note the application identifier, and enter it in your Eclipse project properties under Google->AppEngine->Deployment tab

Now you can deploy the application to the app engine by selecting the project and deploying it to the app engine.

NOTE : You need to sign in to your google account in Eclpise. You will get an error during deployment if you created an app using a different google id. So make sure the id you created the app with and the id you sign in to Eclipse with are the same.

What if i wanted to host the app on my own server instead of GAE?
Since my app is in Java, I would need a servlet container that supports JSP. Apache Tomcat is a servlet container that supports JSP. For the datastore I would need a database server like Oracle or MSSql. And I would need scripting language support on my server, but this particular project doesnt use any scripting yet, just basic calls to JSPs. XAMP - Apache, MySQL, PHP would be a good cross platform choice.

Thursday, February 14, 2013

creating a web application with google app engine

I am trying to build an app on the google app engine, using Eclpise

Important Points
---> Any external libraries you add must be added in two places
1) The build path of your project - this is for the compiler on your local machine
2) war directory under war->lib - this is for the application when it is deployed on the webserver. It does not have access to your local library files after it is deployed.

Step by Step Process

1) Create a new Web Application Project
2) Create an application on the google app engine page https://appengine.google.com/ after you sign-in
3) Note the application identifier, and enter it in your Eclipse project properties under Google->AppEngine->Deployment tab

Now you can deploy the application to the app engine by selecting the project and deploying it to the app engine.

NOTE : You need to sign in to your google account in Eclpise. You will get an error during deployment if you created an app using a different google id. So make sure the id you created the app with and the id you sign in to Eclipse with are the same.

Static/dynamic typed languages, strong/weak typed languages

Static typed - check at compile time eg. C, Java, C++
Dynamic typed - check at runtime eg. PHP, JavaScript

Strongly typed - operands in an expressions must be the same type eg. C, Java
c = a + b; //all are integers
c = a + (char)b  //not allowed in strongly typed languages

Weakly typed - operands can be different eg. JavaScript, VisualBasic
c = a + (char)b // all are integers, but the result is determined during runtime. different languages have           /                         // different rules for assigning the type of the result

Wednesday, February 13, 2013

difference between GWT and Google App Engine(GAE)

Source : StackOverflow
http://stackoverflow.com/questions/4119695/what-is-the-difference-between-google-web-toolkit-and-google-apps-engine


GWT is a Java library. You write Java code using the GWT API. That java code gets compiled into javascript that can be run in a web browser. The compilation step is provided by software in the GWT. GAE is completely different. GAE is a server platform for deploying web applications to Google's server infrastructure. You can use GWT in a GAE app; you do not have to do this. You can create a GAE app that does not use GWT. The only thing these two technologies have in common is the 'G'.

MVC

Trying to understand MVC(Model View Controller). As far as I read, MVC is a technique for organizing web application development into 3 distinct components - Model, View and Controller.

Model contains the data and business logic
View contains the front end logic
Controller is an action class, it decides what action to take for what events

Developing Web applications with Tomcat and Eclipse

Guide to start using Eclipse and Tomcat for developing web applications

http://www.ibm.com/developerworks/library/os-eclipse-tomcat/index.html