How can i populate database tables from excel spreadsheet

Recently i got a excel spreadsheet document with a couple of thousand records which needed to be put into the database, I use MySQL so i had to prepare equal number of insert queries for the number of records in the excel spreadsheet, but instead of doing it the manual way i did it the easy way and this is how it was done. I hope it helps you too. Do let me know your thoughts.

14. April 2013 by Anand
Categories: Databases, Languages, MySQL, SQL | Tags: , , , , , | Leave a comment

How do i use joins in sql ?

For those who think SQL joins are tough. Just go through this once and i bet you cannot forget it again.

Courtesy:  C.L.Moffett, 2008

sql join explained

20. September 2012 by Anand
Categories: Databases, Languages, MySQL, SQL | Tags: , , , , , | Leave a comment

How do i detect if a browser window is closed or refreshed ?

This was the question I was asking myself when I  had to write a piece of code which needed to respond differently on browser close and on browser refresh. To my worst nightmare i found this issue seemed to trouble a lot a people, i went through lots of forums and blogs which gave multiple solutions some even advising to forget the requirement, as it seemed near impossible to detect the difference between a browser close and refresh.

I think i have stumbled on a snippet of code which will detect if the page was refreshed or closed. I had tested this code on windows (IE 7,8,9 – Chrome – Firefox – Safari – Opera) and mac (Safari 4,5 – Firefox – Chrome).

This is a experimental code which i would like you to use and review it. Do let me know your comments.

On request i am including the 2 sample test files which i used to test on my machine. Run the file test.html from the zip file. Which on close / on refresh of the window will open a popup and once the new popup comes check your browser’s console log.

You will find the parent window close / refresh status message on the console after a 2 second delay. This delay is for the browser to complete the DOM manipulation i.e. close or refresh before we do the check. Please click on the sample code link to download the sample code.   Sample Code

16. August 2012 by Anand
Categories: All Browsers, Browser, Javascript, Languages | Tags: , , , , , | 24 comments

Google Chrome Popup Detection that actually works !

Hi,
When i started looking out for javascript code that can detect Chrome’s (17.0) popup blocker, I tried lots of snippets. But most of them dint really work. So once i got it working, I thought it would be good to share with you so that you can make use of the same in your projects. The following is the code snippet::

What this script does is,

1. Tries to open a popup window and store the window handler in pop variable.
2. Declare an anonymous function  with setTimeout set to 1000 milli sec, i.e.  1 sec.
3. So apparently once the 1 sec is complete and the anonymous function gets executed,
3.1 We check if the popup has been loaded, we can see that the ‘pop.innerWidth’  is being used to detect the chrome’s popup mechanism as the popup window’s innerWidth property would have been set to 0 if the popup blocker is enabled.
4. Once all is done we close the popup we had opened.

Send me your comments/suggestions to further optimize the solution.

 

P.S : as per updates from Anders the script was not working on Chrome 19, now with the inputs from Anders i have modified the script to check for :

This compares the height and width values to the exact height and width values I set on window.open() method i.e.  150X150 , this enables us to correctly find if the popup is enabled or not. I have checked it on Chrome 21.

Please check out the below mentioned updated code and let me know if you face any issues.

Cheers.
Anand

 

 

29. February 2012 by Anand
Categories: Browser, Chrome, Javascript, Languages | Tags: , , , , , | 8 comments

Woocommerce – WordPress Shopping Cart

woocommerce

When i was planning to write another article for my blog, I thought why not write a couple of lines about the latest project I just completed.   Check the url : www.munchmylunch.com.au

This website is completely developed using WordPress and Woo Commerce  (www.woothemes.com/woocommerce). This is one of those shopping cart system that lets you get lot of things done with minimal effort.

Though I have only used roughly 25% of the inbuilt features of this cart, I have extensively played with the core code to give it the look and feel that client wanted.Before i settled in for Woo Commerce i had tried other shopping cart systems for Word Press but some how they all seems to be too outdated and not very design friendly.

The default theme provided by woothemes is good enough for most Woo Commerce installations but if you want to go the extra mile to give your shopping cart a custom look and feel, then Woo Commerce gives you ample options to hook and override their default templates.

You will also find AJAX utilization all at the right places using jQuery. Also it is not fair if i do not mention the payment gateway support it provides by default (yes paypal standard pay is included !!) . The tax and Shipping computation is too super easy.

Along with the rock solid stability of wordpress, this shopping cart is a winner for small and medium e commerce websites. did i say you can combine the SEO plugins to work along with the cart to get top rankings on google ?

More on this brilliant plugin and how to use it for your projects in my future posts.

A short intro to woocommerce:

http://player.vimeo.com/video/29198966?title=0&byline=0&portrait=0

 

08. February 2012 by Anand
Categories: Woocommerce, Wordpress | Tags: , , , , , , | Leave a comment