How to debug Drupal or ... How I fell in love with the debug() function

Let's say you see recurring error messages in your db log file and you want to try and pinpoint the issue to be able to apply a fix.
So, how do you go about debugging your code?

Well, there are many different ways. You could go old-school and use




Or you could go a step further and use


to try and pinpoint the source of the error.

Fix validation 'Byte-Order Mark found in UTF-8 File' in drupal installations

So I stumbled across this issue the other day. I usually make sure I save all my files as Encoded as UTF-8 without BOM. But somehow, somewhere there may be a file that was saved incorrectly and thus it will give you a validation error on w3c.

Now, how do you go about finding which file is causing the error? Is it a theme file, or is it a custom module or is it a drupal file which you may have modified (I know, hacking drupal core is BAD!)

The solution is: run a shell script to find the file causing the issue.

Find the BOM files:

Google Weather API shuts down?

Anyone using the Google Weather API would have noticed some strange behaviour early last week. Namely some 403 errors - then lastly the response code became 'Unsupported API'
Here is an example:

Now one should start using different api's to grab required weather data in widgets or other programs. Some I have had a play around with are: