WEB DESIGNING

PHP,JAVASCRIPT,HTML5,CSS,AJAX AND MORE.........

ARTIFICIAL INTELLIGENCE

ROBOTICS,LISP,GENETIC ALGORITHMS AND MORE.....

APPLICATION DEVELOPMENT

WEB APPLICATIONS,CHROME APPS,SWING APPLICATIONS ANDROID APPLICATIONS AND MORE......

PROJECT IDEAS

COME UP WITH NEW PROJECT IDEAS,PROJECT DISCUSSIONS AND MUCH MORE.....

TWEAKS,TIPS AND HACKS

TIPS,TRICKS,HACKS,TWEAKS,SOFTWARE REVIEW AND MORE......

Tuesday, June 11, 2013

Mozilla Application Development: Hello World

I have already taught you how to develop Chrome Application in my previous posts. We had used a manifest.json and a set of files to develop our first chrome application. Developing for Mozilla does not vary much when compared to the Chrome application. So if you had not developed for chrome before, developing for Mozilla will help you to quickly or rather parallely develop for Chrome.So let us start from scratch.
        Every application needs a manifest. Manifest is just a file that contains several details about the app that is required in order for the device to understand.For Chrome manifest files comes with the extension json. JSON (or Javascript Object Notation ) is a lightweight text-data interchange format. It is a collection of name/value pairs that describe the various properties of the application. In Mozilla the manifest is written in JSON but the extension is of the format webapp. So the manifest file is named as manifest.webapp. Here is a sample manifest of the Hello world app that you are about to develop.
{
  "name": "My App", // Name of the Application
  "description": "Hello World",  //Description of the Application
  "launch_path": "/index.html",  //first file that you want the application to launch
  "developer": {   //Developer details
    "name": "Abhijit",
    "url": "http://ltslab.blogspot.com"
  },
  "installs_allowed_from": ["*"], //Mozilla supported devices
  "locales": {   //Languages
    "en-US": {
      "name": "Hello World",
      "description": "App"
    },
    "it": {
      "name": "Hello World",
      "description": "App"
    }  
  },
  "default_locale": "en-US",
  "icons": {  //Icons(Important)
    "120": "/icons/chrono-120.png",
    "60": "/icons/chrono-60.png"
  },
  "orientation": "portrait-primary" //Orientation of the Application
}
I have not tried any hacks or tricks with this manifest and it is for you to try.
Once the manifest is completed, add the required icons with respective sizes.
Now open notepad type hello world and save it as index.html.
Now your app is almost complete.
Just Zip all these files together and make sure the manifest is corresponding updated.
Now validate your app here.
If you find any difficulty please feel free to use this.

So You have completed developing your first Mozilla App. Now think of some innovative idea and start working. Please refer Mozilla developer site for more details.

If you need any help at any point of time. Please drop your comments.

Stay tuned for more.

Thursday, May 30, 2013

HTML 5 Web Storage basics

Earlier, when you want to store something in the client browser you can make use of cookies.Cookie is a small piece of data sent from a website and stored in a user's web browser while a user is browsing a website. But now using web storage and javascript it is possible to store arbitrary values in the browser. Web Storage is different from cookies in the sense that it is not shared with the server and is more like a local storage. 

Web storage is of two types namely local and session storage. local storage is something like your database and used for persistent storage of data while session storage is storing data temporarily till your session is over. For example you can store location of a user once he opens the browser. The session is cleared once the windows is closed.This opens a new dimension where the power of server side scripting is brought into client side. This can make browsing more faster as well as increase the security. But as you know there can never be complete security when it comes to the internet.

The API for localstorage and session storage does not vary much and it usually includes setItem(key, value), getItem(key), removeItem(key), clear(), key(index), length.

Now  let us try it out,
  • Open your favourite browser.
  • Open http://www.google.com or simply google :P
  • Open your Javascript Console (for eg: in Chrome  press ctrl+shift+J)
  • Type this: localStorage.name = 'your_name'
  • Note: Javascript is case sensitive
  • Close the browser and open google again
  • Open Javascript console
  • Type console.log(localStorage.name); and your name appears
  • Note: console.log() is just used for printing
  • Now type: delete localStorage.name;
  • and try closing and doing the same process
  • but this time it will be not found since you have deleted the name property
The above functions using the underlying methods as listed above. In the given example setItem is used to set the name property under localstorage.

Powerful isn't it!!!

Stay tuned for more.




Saturday, April 20, 2013

Sending mail from XAMPP using PHPMailer

In reference to my earlier post "Sending mail from localhost using PEAR and WAMP",  i received few feedback that the same procedure was not working in XAMPP as they faced difficulty in installing PEAR package. So to send mail from localhost without any installation you can make use of PHPMailer library. I helped my friend and was successful in resolving the issue.

To Send mail from localhost using PHPMailer and XAMPP

  1. Install XAMPP (skip this step if you have already installed)
  2. Create your Project folder and download PHPMailer
  3. Extract class.phpmailer.php and class.smtp.php
  4. Locate php.ini (located under xampp/php/ folder or can be reached from xampp tray icon
  5. Seach for ;extension=php_openssl.dll and uncomment it.
  6. Open class.smtp.php search for the host and port and set the corresponding values.For Ex: $host="ssl://smtp.gmail.com" $port=465
  7. Now the code for sending mail can be found here.
If you still have any clarifications please comment below.

Stay tuned for more.

Friday, March 15, 2013

Office Professional Plus 2013 (English) Genuine Keys Giveaway Closed

This is my first giveaway. I'm giving out three genuine keys of the latest Office 2013 Professional 2013. It is a known fact that nothing in this world is free and I'm not planning to conduct a competition or first come first served giveaways. To verify the identity of you and for the respect to Microsoft who had given me an Opportunity to learn teach and share all the Microsoft technology (using their latest software).
      So here is the deal. Fill this form and provide the correct details. I will select a random number from the random generator widget from random.org and three lucky Winners will be given the genuine keys and will be announced  in this blog.

Note: A person is  declared a winner only after the form is validated (Winners will be announced next month)
For those people who think that this is a fake giveaway, here is  the snapshot of my msdn account.


Winner 1#  venkataanuragdandamudi@gmail.com

WInner 2# karthik231@gmail.com


Winner 3# chidambaram70@gmail.com>

Stay tuned for more giveaways.

Friday, March 08, 2013

Genetic Programming: Evolution of Mona Lisa

You will wonder what this evolution is all about. In simple words you are given a empty plain canvas and you are asked to program the computer to display the picture of Mona Lisa. But you have to generate the image and not place it or copy it pixel by pixel and you have to do this such that the final image is obtained in short span of time (optimally short).
         Roger Alsing came up with a interesting solution to this challenge by using polygons to generate the picture of Mona Lisa.So this is how it works:

  • Generate a random Polygon and draw it in the canvas
  • Read the canvas pixel be pixel and compare it with the source Image
  • Mutate (i.e evolve or add a new polygon) the current Image and compare the old one with the new Mutated Image.
  • If the Mutated image has better fitness (when comparing with source Image), then draw the image in the canvas.
  • Repeat this till the fitness is constant.
Amazingly it took only 50 Iterations for the Mona Lisa Picture to appear.The code, FAQ can be gathered from Roger Alsing's official website. The source code is available on github and also a working desktop application can be downloaded from here.

Stay tuned for more.

Saturday, February 23, 2013

Reading a Word file in PHP (Windows COM)

If you want to read a .doc and .docx file for your PHP application we need to convert it into plain text for reading. To convert .doc and .docx file into plain text , we can make use of a COM object

The code goes something like this:


$word = new COM("word.application") or die("Unable to instantiate Word"); //Opening word
$word->Documents->Open($filename); //Open the file using word application
//print_r($word);
$new_filename = substr($filename,0,-4).".txt"; //New txt file with .txt extension
$word->Documents[1]->SaveAs($new_filename,2); //saving the word as a text file
$word->Documents[1]->Close(false); //close the file
$word->Quit(); //quit word
$word = NULL; //destroy the variable content
unset($word);
$fh = fopen($new_filename, 'r'); //Open the file
$filedata = fread($fh, filesize($new_filename)); //store the plain text content in a variable
fclose($fh); //close the txt file
unlink($new_filename); //Unlink the file

Save this as index.php and open it in your localhost (Probably WAMP Server)

I'm 99% sure it wont work :P (Since you have not configured your DCOM in your windows machine)

To configure DCOM object:

1. Open command prompt(cmd)(Windows +R)

2. Type dcomcnfg (Distributed Component Object Model Configuration) and press Enter

3.In the left panel go to Component Services -> Computers -> My Computer ->DCOM Config

4.Search for Microsoft word 97-2003 Document and Right click Properties

5.Then go to Identity tab and select The interactive user and then Click Apply

6.Now your are done and good to go. I'm sure 99.99% it will work. If you find any problems please comment or contact me for clarifications.

Stay tuned.


Friday, February 01, 2013

Sending mail from localhost(WAMP) using SMTP Protocol and PHP(PEAR)

Note: In this tutorial im using configuring my wamp server and using Simple Mail Transfer Protocol using port 465.So this is a secure transmission and we wll be using gmail as the smtp host.

  • Pear is a framework and distribution of reusable PHP components.Download and install PEAR in your system.If you do not know how to install there is another alternative.Just downoad this go-pear.php which consists of a good UI for installation.
  • After installation, install mail, net mail and mail mime using your windows command prompt.
    • pear install Mail 
    • pear install Net_SMTP
    • pear install Mail_Mime(used for attachments)
  • Now open your text editor and enter the PHP code for sending the mail.You can View/Download the source code here.
  • Now alter the php.ini file to configure WAMP.To find your php.ini file leftclick wamp icon in the tray =>PHP=>php.ini
    • Search for include_path and uncomment it and give the link of the PEAR directory
    • Search for smtp and uncomment and modify all the values like port, from, host and...(Use the PHP code as reference)
  • Now you are good to go and try running the PHP file.Make sure your internet is on and enable POP in your gmail account.
    • For enabling POP for your gmail account go to Settings=>Forwarding and POP/IMAP and enable POP.
If you have any doubts or clarifications or if i my post is inadequate please feel free to comment.

Stay tuned for more.