Converting strings to dates in MySQL

Use the str_to_date function and provide the format you need to it. for example, if you have a field called created_dttm with a date which is in the format “24-07-2015 06:00:00” you can use this to convert into a MySQL date so that you use various MySQL date functions on it.

select str_to_date(created_dttm, '%d-%M-%Y %H:%i%s');

See this list for all the date formats.

Wireless Router & Headset conflict

I have an ASUS AC68U wireless router and lLgitech G930 wireless headset, and I kept finding that my headset with drop out. After some research, I came to the conclusion that I should try changing the wireless control channel on my router.

The control channels range from 1 to 11, so the best options to avoid interference are 1, 6 or 11 (i.e either end or the middle of the spectrum). I tried 11, then 6 and both weren’t much better, however control channel 1 seemed to do the trick. You can tell it works because a restart of the wireless on the router after changing the channel would cause a drop out, and this happened immediately on channels 6 and 11, but not on 1.

Switch Apps in iOS Simulator

Neat shortcut to switch apps in the iOS Simulator:


Note you need to press H+H fairly quickly. Just


will emulate the home button, so the double H is like pressing the home button quickly twice.

Fixing Mac Book Pro – No Internal Speakers

This happens on occassion on the Mac Book Pro – You lose the internal speakers and are only left with digital out. A sign this has occurred is that the red light in the headphone port (where you plug in your headphones) will be on.

There are numerous ways to try to fix this, anything from system preference tweaks all the way to opening up your Mac Book.

Here’s the simplest thing you can try (and it does seem to work with a bit of persistence):

  1. Open System Preferences > Sound
  2. Plug in your headphones as you won’t have control over the volume/mute of the digital output
  3. Once headphones shows up on the list, move the volume slider up and down and check/uncheck the mute button.
  4. Unplug your headphones
  5. Check if digital out has disppeared and been replaced by Internal Speakers.
  6. Rinse and repeat. Note it can take several attempts before this works. For example, after 3 times, I finally had internal speakers appear for a second then disappear back to digital out. On the fifth attempt, internal speakers appeared again and this time stayed. Basically what you are doing is trying to get the Macbook to recheck its sensors and correctly revert to internal speakers.

Good luck.

SublimeLinter (with PHP)

SublimeLinter is a great syntax/error checking plugin for SublimeText.

Here are the steps to get it working (for example with PHP):

Note if you get stuck, use


to open your sublime text console and look for any errors. Also check the very comprehensive documentation:

Leave in your (commented out) debugging code?

Leaving in (commented out) debugging code is topic that will always be up for debate. That’s fine, there are many sides to it. But I have been finding myself quite thankful for cases where other developers have left in debugging code (commented out of course).

It just makes the debugging process a bit easier if you are unfamiliar with the code. it can be a really quick way to get the information you are after when troubleshooting. Most times, when you have such code in place it is precisely because it was difficult to troubleshoot that piece of code without it (sometimes a sign of bad code, but usually just a sign of complexity). Often what happens is that developers will create that debugging code if it isn’t there and essentially reinvent the wheel to troubleshoot anyway.

Just something to think about. One important stipulation is that the debugging code shouldn’t confuse you, and should be easily identifiable as debugging code. Also the value of such code will vary widely depending on your development platform and available debugging tools.

Moodle Unexpected Output while processing AJAX request

I had this one come up when expanding the Site Administration menu:

Coding error detected, it must be fixed by a programmer:  
Unexpected output whilst processing AJAX request.  

This could be caused by trailing whitespace. Output received: ' '

What causes it is there is a new function in later versions of Moodle in lib/ajax/ajaxlib.php called “ajax_check_captured_output”. This is a useful check for developers, and therefore when the site is in DEVELOPER debug mode it throws an exception. You can change the debug mode to something less than DEVELOPER and you shouldn’t get an exception (but note that there is still an underlying problem).

One catch is that if the site administration navigation is failing, you can’t actually get to Site administration > Development > Debugging. Easy work around, visit and adjust your debugging settings there.

Titanium Studio: Can’t Install Updates

If you can’t get past the install updates prompts in Titanium Studio, it could be due to authentication issues with the underlying operating system.

For example, I have NOPASSWD: ALL set in my /etc/sudoers file on my mac (naughty, I know) however, this seems to really stuff up the automatic installer in Titanium Studio. I would click on the install button and get nothing – no response from the UI at all.

The only feedback in the system log was this:

praj : TTY=unknown ; 
PWD=/Applications/Titanium Studio/; USER=root ; 

Once I took out that line in /etc/sudoers (and let it prompt me for a password when using sudo), I received the login dialog box and could continue with the install. Frustrating, but I hope this saves someone else a few hours of troubleshooting.