JSLint - Verify your javascript

Not to mention that javascript is one of the most popular scripting language of these days. Almost all websites are using it up to certain extent. Developing in javascript is always a challenge because it is not compiled and executed on runtime only.

This challenge is addressed by some of the tools which help a lot in developing javascript. Some names are Firebug, Web developer toolbar for Firefox and IE developer toolbar for Internet Explorer and many more.

These tools will help you in running your js code and debugging the problem but still you can have bad code sitting in js file because of wrong declaration, unreachable code and confusing + and - etc.

JSLint is a JavaScript syntax checker and validator.

JSLint takes a JavaScript source and scans it. If it finds a problem, it returns a message describing the problem and an approximate location within the source. The problem is not necessarily a syntax error, although it often is. JSLint looks at some style conventions as well as structural problems. It does not prove that your program is correct. It just provides another set of eyes to help spot problems.

JSLint defines a professional subset of JavaScript, a stricter language than that defined by Edition 3 of the ECMAScript Language Specification. The subset is related to recommendations found in Code Conventions for the JavaScript Programming Language.

JavaScript is a sloppy language, but inside it there is an elegant, better language. JSLint helps you to program in that better language and to avoid most of the slop.

JSLint can operate on JavaScript source, HTML source, or JSON text.

Go to http://www.jslint.com/ and paste your program in text area and click JSLint button to verify your javascript.

You can also set options to verify your script according to your preferences. These preferences are provided below on the same page. You can make JSLint less restrict using these options.

For more information go to its Documentation page.

Restaurant Directory with Menus for Delhi Gurgaon Noida (NCR) India - FoodieBay.com

You live in delhi ? then you must be aware of yummy places to eat out specially in Old Delhi. Eating out is always fun in Delhi because of its delicious food. Other than normal eating out plan of families NCR also has different kind of people who go for dining. This second type of people are generally Software Professionals who party a lot (curtsy to their companies).

You can use internet for knowing better about the places to dine near your place or your office.

Go to foodiebay.com to find out Restaurants to dine. You can check Menus online, have more information about the Restaurant like its contact number, cost of meal for 2 people and use reviews.

You can check the prices and dishes, whether they deliver or not, bar or no bar :-) etc.

You can register with this website and work with in according to your preferences. You can set you preferred location and search results will be shown near to that place. You can provide your feedback about restaurants and other people can take benefit of that.

If you have been through a very good or a very bad experience with any place related to food and eating out you can share your comments about that without even registering.

It is my personal experience that people visit same place again and again not because they like it but they do not have options rather do not have enough information.

Use internet and have fun!

Unix Shell Scripting Basics

Unix Shell Scripting Basics
View SlideShare presentation or Upload your own. (tags: basic shall)

Google Maps and Gmail on your mobile

I am not a gadget freak and use my mobile phone for calling and messages only. Few days back, I tried to experiment capabilities of My mobile phone Nokia 6610i for connection to internet and using mobile applications. I guess this phone was released in 2003 and now quite outdated so i did not got much success with my phone.

I managed to borrow phone from my wife for this experimentation which was comparatively new Nokia model,Nokia 6670. I was using Vodafone as my network operator and after 2 days of my request of GPRS activation I was finally ready to check out mobile world.

Things were already lined in my mind and I was excited about testing the Google, here is the list:

1. Google Maps: I find Maps very useful and because Google maps are equipped with local/business information, it makes maps more useful. Google maps can be accessed on mobile in 2 ways

For installing the application visit http://m.google.com/maps or http://www.google.com/gmm

Google Maps works with the following devices:

Other than this you need to have Data plan from your carrier like i had from Vodafone.

You can get your phone specific information by selecting the your phone make at http://www.google.com/mobile/default/

If you do not want to download the application you can still use go to http://m.google.com/ and select Maps in your phone browser. It will take you to another page where you can search local information.


Using Google maps application you can view maps, find directions (not applicable for India yet), traffic information (not applicable for India yet), satellite view of maps, Zoom in and Zoom out map for more details.



2. Gmail: No doubt Gmail in your pocket is very useful. What i loved in Gmail Mobile App is that it is not strip down version of Original Gmail but almost equally powerful. I provide you almost all the functionality mostly useful or frequently used.

It provides you conversation view of email just like Gmail Original. You can multiple actions like Delete mail, Archive mail, Add star to mail, Report spam (by using key shortcuts also).


You can also switch your view to Inbox, sent items, Starred, Spam, Trash, contacts, settings etc.


Obviously you can search your mail :-) , also using key shortcut.

Composing mail is definitely non-trivial on mobile but depends on your handset also. You can send small messages very easily.

3. Search : Search is very useful on mobile when you are not near your computer and you need some information urgently. For using Google search on mobile go to http://m.google.com/ using your mobile browser and Click on Search for using Google search application.

A little information about anything can be very useful when you are not near you PC or in the way to some place.

4. Youtube : This is interesting one, but data exhaustive. So you should check you data plan before using it. This application also prompts you while starting that you should have unlimited data plan for using this application.

Again go to http://m.google.com/ using your mobile browser and Click on YouTube.

I think Flash must be supported on phone for running this. On my phone it runs using Real player installed on phone.

Other than these application there are many other free applications by Google which are very useful and interesting. Visit http://m.google.com/ and try applications on your mobile.

I will add about more application as and when i will have enough information.

YouTube labs - Test Tube :-)

We all love YouTube for its community videos and its concept of 'Broadcast Yourself'. It actually becomes a platform where we can get & share content for almost every thing. Sharing video of your kid to learning Grid computing, You tube gives you platform to share any type of content (except some inappropriate content). You can go through community guidelines of YouTube to know more.

Just like every other technology company, it also has an innovation wing which is called Test Tube :-).

This is similar to Google Labs where ideas are tested, which are not matured yet.

Welcome to TestTube, our ideas "incubator." This is where YouTube engineers and developers test out recipes and concoctions that aren't quite fully baked and invite you to tell us how they're coming along.

Keep yourself updated about new things related to YouTube!

Manage dependency of beans - Spring Framework

I am assuming that reader is aware of Spring Framework. If you are not aware of it, go through Spring framework website or more specifically the introduction section of documentation or introduction on theserverside.com

In short Spring is a framework which follows IOC (Inversion of Control) and helps in setting the dependency accordingly using the XML descriptor. You can call it a dependency injection framework also. As a whole spring it lot more than this but the main differentiator is IOC. You can read more about it on its website.

Now let me jump directly to the problem which i encountered today.

I had two beans which need to be instantiated on start up of server and bean1 was dependent on bean2. To give you more idea, bean1 was trying to access some property object which is set by bean2 so instantiation of bean2 was precondition of bean1 but it was not happening.

By default there is no order followed by Spring to load different beans which are marked for initialization on start up so you can not predict which bean will be loaded first.

Spring provide mechanism to control loading of order:

 
<bean id="bean2" class="com.abc.xyz.Bean2" init-method="init"/>
<bean id="bean1" class="com.abc.xyz.Bean1" init-method="init" depends-on="bean2" />
 

You can specify depends-on attribute in bean element to declare dependency to Spring. Spring will load bean2 first and then load bean1 so that bean1 does not encounter any error because of dependency of resources set by bean2.

init-method tells Spring about which function to call while loading the bean. All initialization code can go inside init() function of bean.

Web Application Security

A useful presentation about Web Application Security.

errorcode: sec_error_ca_cert_invalid

When I generated and signed the generated certificate for using SSL and tried to test it, Firefox 3 gave me following error:

errorcode: sec_error_ca_cert_invalid

I tried to use IE 7, and similar error. I was little confused. The reason of confusion was that when i tested it earlier it was working fine with old versions of browsers which are not very restrictive about the security. The new browsers are more strict about the security and does not allow self signed certificates in https sessions.

Old versions of brosers used to show the warning that the certificate in https session is not trusted and user can accept the warning and move on with his work if he is sure about the website and its authenticity.

New versions takes non-trusted certificates as security breach and show error.

In case of self signed certificate you may see warning like this:

(site name) uses an invalid security certificate. The certificate is not trusted because it is self signed. (Error code: sec_error_untrusted_issuer)

If you are sure and want to move on, you can by pass this warning by adding a security Exception and browser will allow you to move on.

Read more here
and here

How to setup https/ssl using Apache web server (httpd)

This is not the end to end setup procedure of making your website secure but a short description of an exercise in which i tried to setup a website on https which was already running on http and configures httpd i.e. Apache server using Self signed certificate.

The aim was to run website in secure mode using https. This was done using following software:

1. Apache Web Server - httpd
2. OpenSSL -
3. mod_ssl -
4. Linux operating system - Fedora core 6 (I tested on this environment)

If you want to understand the SSL and https you can refer this page.

We are here trying to setup server configuration for HTTPS. Generally SSL certificates are given by some trusted body like Verisign and browser obey their signed certificates but you can also create a Self Signed certificate to use SSL. Web Browser will prompt user that some non-trusted signed certificate is found for website and you will have to accept that to proceed.

Generate and Self sign the certificate:

1. Find openssl.cnf on system, generally it resides in /usr/share/ssl or /etc/pki/tls/ and copy it in some directory where you want to generate certificate.
2. Run following command

openssl req -config openssl.cnf -new -out server.csr



3. Run following command to generate the key

openssl rsa -in privkey.pem -out server.key



4. Self signing the certificate

openssl x509 -in server.csr -out server.cert -req -signkey server.key -days 365


Setting up apache webserver:

1. You need to copy server.key and server.cert file to some folder( /opt/ssl) which you will configure in Apache.
2. Edit httpd.conf ( /etc/httpd/conf/httpd.conf ), following lines should be edited to point to cert and key file. It is possible that there is ssl.conf separately in /etc/httpd/conf.d directory, then you need to configure that file.

SSLCertificateFile /opt/ssl/server.cert
SSLCertificateKeyFile /opt/ssl/server.key



3. You also need to make sure that mod_ssl module is configured to be loaded , check this line not commented in configuration files

LoadModule ssl_module modules/mod_ssl.so



4. Restart Apache and try to access your website using https://

There can be more settings for only using https for certain application and not use http.

As this is self signed certificate, there are new version of web browsers which do not support this and gives error while accessing the application. As this is non-trusted certificate, you have to manually add this certificate to Browser trusted ones so that you can proceed.

I will cover that in a separate post.

Linux Introduction & Commands

Some basic information and commands about Linux like File system information, File rights, listing and editing commands, controlling processes etc.