How I reassure users that even us IT Pros are human…

Anyone whose worked in the IT world has encountered situations where a user might feel a bit embarrassed when you fix a problem what seemed kind of obvious.   You know the types of situations where the situation can be resolved by plugging in the device.

Being a fallible human,  I have more than my fair share of these…and have posted some of them here

Whenever I need to reassure someone that I’m not at all put out by the situation I tell them my Snowblower Story….and yes, this is a true story.

A few  years ago I lived in Barrie Ontario which was frequently hit with heavy snowfalls.
Shortly after we got hit with about 3ft of the white stuff I suited up and headed down to my garage to fire up the snow blower.

It wouldn’t start….I tried everything!!!

I happened to have the tear down manual for the snow blower, and having no aptitude for mechanical things, decided that it shouldn’t be an issue to tear down the workings and find the problem.

Some time later I had all the external stuff stripped off, and was about to take apart the motor itself (I don’t know why…while I understand the principles of the internal combustion engine I did not have any experience, knowledge or skill in fixing them),  my friend and neighbour Tim came over with a couple of beers to see why I hadn’t cleared out my drive (and his).

When I told him what I was up to, he chuckled and moved the gas tank so he could sit down.

As he did so he paused…

He then handed the gas tank to me and asked if it was empty when I started…

Yes…yes it was.

Sometimes a zebra is just a donkey!


Javascript: Function that returns status for specified Facebook API permission

I’m working on an application where I want to use Facebook user authorization.

Being someone who is wary of over-granting permission to applications there are permissions I only want to ask for if the user is going to do something where they’re needed.

One of these is the friends list.  As the application will allow the user to invite other people as administrators and managers for their particular group,  I only want access to the friends list if this is something they want to do.

I came up with the following function to do the check for a specific permission.

Its important to remember that the user must grant you permission to access their profile,  and are logged in prior to using this function.

First you must ensure that you do initialize your Facebook connection using your application ID.

window.fbAsyncInit = function() {
appId : 'your app id here',
xfbml : true,
version : 'v2.2'

You can get your Facebook App ID here.

In testing, I called it after getting a connected status response from FB.getLoginStatus.

This is the code that calls the function.

This function is synchronous!  That means the script will NOT wait for it to return a value.

….so call it and store the values on initialization, or page load….or before you need it.

FB.getLoginStatus(function(response) {
if (response.status === 'connected') {

FB.api('/me', function(medata) {

//do stuff here


If you’re wondering what the medata object looks like…here it is:

"name":"David Rothbauer",

Now, the function itself:

function checkfbpermission(perm) {

I loop through the child objects permission and status sequentially, the found boolean will tell me when to return the status value

 var found = false;  
 for (var k in data) {
 console.log(JSON.stringify(data[k])); //this is useful for checking that the permission that you're looking for actually exists!
 for (var i=0;i<data[k].length;i++)
 for (var x in data[k][i]) {
 if (found == true) {
  return data[k][i][x];
 if (x == "permission" &&
 data[k][i][x] == perm) {

 //this will tell the script to return the value of the next object (status)
 found = true;
 else {
 found = false;
 return 'no data';

I’m still working out how to best leverage Facebook user integration into my application. I will post more solutions that I think might be helpful as I develop them.

JQuery Quick Tip: Custom Attributes

For quite some time,  whenever I needed to pass something like a database table row index from a webpage to a PHP script I would do string manipulation to get the data.

Something like this:

<div class="tdiv" id="td_4932">Something interesting</div>



tid = tid.replace('td_','');

//now tid = the index



In an epic /facepalm moment I realized that I’ve been doing it the hard way.   I realized this when I had to pass several bits of information back to the PHP script.  The string manipulation code would be kludgetastic.

It was simple. Put the parameter as a custom attribute!

Like this:

<div class="tdiv" id="tdept" dept="4932">Something interesting</div>  //the dept attribute points to the target department in the database


var tid = $('#tdept').attr('dept');

console.log("The dept index is " + tid);



PHP: Create HTML Table Row from DB Quick and Easy

One of the things that I find myself doing is building tables to display data from a database query.

My preferred method of doing this is using a JQUERY Post call to a PHP script.

I won’t bore you with the PDO connection strings and database query and cut right to the chase:

/* do all your db connection stuff and query here */
/* The presumption here is that your $query will return the fields ID,Name and Some Interesting Data, IN THAT ORDER */

$output = '<table>';
$output .= '<tr><th>ID</th><th>Name</th><th>Some Interesting Data</th></tr>';
foreach($query as $row) {   

    $output .= '<tr><td>'.implode('</td><td>',$row).'</td></tr>';      //pretty slick eh?  No concatenating a bunch of cells


$output .= '</table>';

echo $output;


Hi There!

Welcome to another of the hundreds, upon thousands of programming blogs in the universe!

My intention here is to provide code snippets in various languages and platforms that I find useful.   I have a talent for explaining things in ways that I think are easy to understand.

If you’re brand new to programming and looking to learn from scratch,  this probably isn’t the place for you.   Once you have a basic understanding, you’re welcome to peruse snippets and pick up some tips.

If you’re looking through my stuff and see something that’s wrong, or that there’s a better way,  post it!

I’m a self-taught programmer.  I don’t know everything (don’t tell anyone I said that!),  and there are probably better ways to do some of the things that I demonstrate here.

My posts will hopefully give you the basics of what I’m trying to show you.

One of the things that I find very annoying about some tutorials and sample code,  is that the author gives you a step by step on setting up a working example…often without sufficient explanation for you to take the bits you need to bend them to your purpose.

I will try to avoid that.

Now…I probably won’t post frequently…but hopefully what I post will be helpful to someone.