Saturday, 22 June 2013

How to get list of countries using firebug, jQuerify and Firefox

While working on a project I wanted a list of all possible countries for my web application. Of course I wanted to put it into database. The query was as shown below:

INSERT INTO Country VALUES(‘CountryName’,1,NOW(),1,NOW());

I found countries from Yahoo directories from this link.

Now imagine how long it would have taken If I would have copied each country name from that page to write insert queries. Instead I used firebug console. Once you open firebug console click on jQuerify (you have to install this add-on separately.)

In firebug console I typed following command

$('ul li a b').each(function(){
document.write("INSERT INTO Country VALUES('" + $(this).text() + "',1,NOW(),1,NOW());<br>");
});


And it generated following output


INSERT INTO Country VALUES(‘Afghanistan’,1,NOW(),1,NOW());
INSERT INTO Country VALUES(‘Albania’,1,NOW(),1,NOW());
INSERT INTO Country VALUES(‘Algeria’,1,NOW(),1,NOW());
INSERT INTO Country VALUES(‘Andorra’,1,NOW(),1,NOW());
INSERT INTO Country VALUES(‘Angola’,1,NOW(),1,NOW());
INSERT INTO Country VALUES(‘Antigua and Barbuda’,1,NOW(),1,NOW());
INSERT INTO Country VALUES(‘Argentina’,1,NOW(),1,NOW());


So to end, someone said, "Work Smarter, Not Harder…!!!"

Here you can see the video demo.

No comments:

Post a Comment