5 must have firefox addons for every web developer
Being a web developer there are some tools which I need and use on daily basis. Here are 5 such addons I think every web developer should install on their firefox.
1- Web developer toolbar
Home: http://chrispederick.com/work/web-developer/
Install: https://addons.mozilla.org/en-US/firefox/addon/60

This addon adds a toolbar and a menu to firefox. The toolbar contains several mini tools in it to perform various tasks. It has 11 built in menus for different tasks like cookies, css, forms, html, images and many others. You can read a review of web developer toolbar here.
2- JSONView
Home: http://benhollis.net/blog/2009/02/24/jsonview-view-json-documents-in-firefox/
Install: https://addons.mozilla.org/en-US/firefox/addon/10869

JSON is becoming more popular day by day as a data exchange format. JSONView allows you to view json documents in the browser itself without having to open in any text editor and format it. Local files can also be seen if they have .json extension. It formats the document nicely and also provides options to collapse/expand nodes too (just like XML).
In case of invalid json it reports an error.
3- Fireftp
Home: http://fireftp.mozdev.org/
Install: https://addons.mozilla.org/en-US/firefox/addon/684

You will not have to open a separate ftp client if you use this. To open Fire FTP, go to Tools -> Fire FTP on firefox menu bar. It opens an easy to use interface in a new tab. You can create multiple accounts and you will get all the features that you expect from a ftp client.
From the site: “Along with transferring your files quickly and efficiently, FireFTP also includes more advanced features such as: directory comparison, syncing directories while navigating, SFTP, SSL encryption, search/filtering, integrity checks, remote editing, drag & drop, file hashing, and much more!”
How to dynamically load the Google Maps javascript API (On demand loading)
Normally google maps js api is loaded at the time of page load via a script tag with src set. If map is not so major feature of your application or you want to reduce page download time, you can defer loading the javascript load it when required.
This is a javascript pattern called On demand javascript.
Bottomline is: “JavaScript being pulled from the server after the page has loaded“.
Google maps provide the facility to dynamically load the api when required. So no need to load it at the time of page load. I will present an example here which will load the maps api on click of a button. Here is how to do it.
As said above, DO NOT load any javascript api from Google using script tags. Instead we will use a button.
<input id="loadButton" onclick="loadAPI()" type="button" value="Load maps api" />
To load the api onclick of this button, create a script tag, set its src and append it to document. This will load the Google AJAX API required to load other google APIs.
function loadAPI() { var script = document.createElement("script"); script.src = "http://www.google.com/jsapi?key=YOUR_API_KEY_HERE&callback=loadMaps"; script.type = "text/javascript"; document.getElementsByTagName("head")[0].appendChild(script); }
Do not forget to replace the API key above with your API key. (You can get an API key by signing up here)
Important: Note the callback=loadMaps in script.src. This is the thing doing all the magic. It tells which function to call when AJAX API has loaded. In above case it will call loadMaps function. So, let us define that.
function loadMaps() { //AJAX API is loaded successfully. Now lets load the maps api google.load("maps", "2", {"callback" : mapLoaded}); }
loadMaps function uses load method of google AJAX API to load a specific api. Above we loaded “maps” version “2″. Again callback is the name of function that will be called when maps api is loaded. callback function will be called only when the maps api is loaded successfully.
function mapLoaded() { //here you can be sure that maps api has loaded //and you can now proceed to render the map on page if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map_canvas")); map.setMapType(G_SATELLITE_MAP); map.setCenter(new GLatLng(28.631466106808542, 77.07853317260742), 5); } }
That is all to it. I have created a demo along these lines. View source for code. You can see it here.
Happy New Year!
Hi friends,
I wish you all a very happy and prosperous new year with lots of happiness.
I hope that the posts I publish here are useful for you and your questions are answered. This year I promise that I will try to write better posts and write more regularly.
Best Wishes once again.
How to restore and backup mysql databases?
I forget the commands everytime I backup/restore mysql databases. For this reason I am writing them down for my reference and hopefully others will also find them useful.
Suppose my database credentials are as follow:
db username: vijay db password: somepwd database: catalogue
Taking backup of database
Go to the command line (not mysql command line) and fire the following command:
mysqldump -u username -p password database > dump.sql
After replacing with original values this becomes:
mysqldump -u vijay -p somwpwd catalogue > dump.sql
This command will generate a sql file named dump.sql.
Restore the database
Now you would like to restore the above created dump.sql to some other server. Here is the command
mysql -u username -p password database < dump.sql
This becomes:
mysql -u vijay -p somepwd catalogue < dump.sql
This will restore the data from dump.sql file to catalogue database.
How to create excel files in PHP?
Some time ago I found a class on phpclasses.org by Harish Chauhan which makes it incredibly easy to generate simple excel spreadsheets from PHP. I found it useful so I want to share its usgae with readers too. I also made some changes to the class for styling the rows.
Here is the process:
1- Include the ExcelWriter class file in your code
include("excelwriter.inc.php");
2- Initialize the ExcelWriter class
$fileName = "myNewExcel.xls"; $excel = new ExcelWriter($fileName);
Constructor of ExcelWriter class accepts a file name as parameter. File will be saved by this name.


