How did advertisements get on my site?

I should probably pay more attention to my own site.

While I was working on my blog last week, I noticed that there were advertisements showing up in the Related Content links at the bottom of all my posts.  I was quite shocked as I never added them intentionally.  I feared that my blog was hacked.

Digging just a little deeper, I quickly found the culprit: the Shareaholic plugin.  I used it for related content and the social sharing buttons for the posts.  It turns out a few months ago they sneakily added in monetization options in their plugin update without having blog owners explicitly opt-in.  That means once you updated the plugin (if you’re using the WordPress panel to do this, there’s pretty much no changelog or notice), ad links would spontaneously spawn on your site.  I guess if you’re a better blog owner you would have caught it sooner than I did.  I understand developers need to make money too, and I’d understand forcing advertisements on the admin panel, but having advertisements enabled by default on the public site is a very sneaky process.

Needless to say, Shareaholic has since been removed from my site.  If you’re still using Shareaholic, you should really review its settings to make sure it’s doing what you want it to do.  For me, I’ve found other plugins to replace the functionality including Floating Social Bar and Contextual Related Posts.

Checking for a Null value in SQL

Yesterday I fell into a very simple but dangerous SQL trap.  Can you identify it?

SELECT first_column, another_column
FROM my_table
WHERE first_column = 1
    AND (another_column >= 100 OR 
         another_column = null)

Found it?  It’s the comparison to null.  My intention was to get rows where another_column was null, however the query did not do so.  It didn’t give me any results where another_column was null, but didn’t give me any error either.  Why?

Null in SQL is not a real value.  Null means “lack of a value” or “unknown”. Anything compared to null leads to an “unknown” result. Therefore, in SQL there are actually three values conditions can evaluate to: true, false, and unknown/null. This is called three-valued logic. SQL WHERE clauses only return rows that evaluate to true, not rows that evaluate to false or “unknown”.

The proper way of checking for null is by using the IS NULL or IS NOT NULL predicates. The correct SQL query would have been as follows:

SELECT first_column, another_column
FROM my_table
WHERE first_column = 1
    AND (another_column >= 100 OR 
         another_column IS null)

So if you’re used to languages where you check for null with equal signs, remember that in SQL, you must use the special IS NULL or IS NOT NULL predicates instead of the equals sign or other comparison operators. Don’t get tripped up like I did.

If you want to read more about, Wikipedia has a detailed article on null in SQL.

Wi-Fi everywhere!

Over the past year, more and more ShawOpen Wi-Fi hotspots have been popping up everywhere around Metro Vancouver.

This is incredibly useful for Shaw customers (like me) because it’s so easy to find reliable Wi-Fi access anywhere we go.  If you’re a Shaw internet customer, you get to save several devices so that they can automatically connect to the network without having to login through the portal.

Telus is starting to form their own network as well, under the names #TELUS and #TELUSDirect.  The one advantage they have is that for Telus customers, #TELUSDirect is a secured Wi-Fi network, whereas ShawOpen is an open unsecured network.

I’m hoping that Shaw will consider providing a secure network for customers, but until then we’ll have to use our own VPN services to secure the Wi-Fi connection.

“Error: Boot loader didn’t return any data” when booting up Xen guest

Error: Boot loader didn't return any data

I have come across this error two or three times before, and each time I spend hours trying to figure out how to get my virtual machine to boot.  This blog post is just to document a fix so that I can refer back to it, and hopefully it will help people out if they’re experiencing the issue as well.

Continue reading “Error: Boot loader didn’t return any data” when booting up Xen guest

Software developer (mobile/web). Public transportation enthusiast. Catholic.