Category Archives: Programming

They’ve done it again. The team at Automattic have created a great new default theme for this year’s release of WordPress 3.4, Twenty Twelve. It’s an extremely well designed and well-written theme that incorporates great responsive design, an attractive, text-focused approach, and good best practices. I’ve been waiting to use it on my site since it was announced, and now that it is available in the WordPress.org Theme Repository I have been playing with it.

Of course that means that I need to add all of my Schema.org microdata enhancements back in–I can’t go from having all of that embedded, machine readable data to having nothing! So I applied the same techniques as I did for the previously released Twenty Eleven Schema.org child to this year’s theme, and it is ready for public consumption.

What is Schema.org and microdata? In short, it is invisible, enhanced markup that lets search engines and other system agents read about your content, including authorship, dates, tags, content delineation, etc., in a way that they can understand. To quote from my previous post about the T11 child theme:

Adding microdata to your site has several benefits. First and foremost, you contribute to machine readable data everywhere. The Internet is a wonderful place for humans to browse, but we can make it more accessible and more consumable if we let the computer figure as much of it out as it can. Second, search engines can use this data to get a better understanding of each page that it indexes, and hopefully provide more relevant search results. (Notice that I am not saying you are going to get an SEO boost for doing this. You may, you may not, I have no idea. But if everyone included this data on their sites, the results would be better.) There are no downsides really to simply plugging the data in.

So if you are using the new Twenty Twelve theme and would like to add this microdata to your site, then feel free to download and install the T12 Schema.org child theme on your blog. You can find a download, as well as a link to the source on GitHub, on the Twenty Twelve Schema.org Child Theme dedicated page.

Enjoy, and let me know how you are using it!

Share and Enjoy

  • Twitter
  • Google Plus
  • LinkedIn
  • Email
  • RSS
  • HackerNews
  • Instapaper
  • StumbleUpon
  • Facebook

Looks like Google is going to be getting more into the semantic web game, according to this article from the WSJ.

“Over the next few months, Google’s search engine will begin spitting out more than a list of blue Web links. It will also present more facts and direct answers to queries at the top of the search-results page.
“Google isn’t replacing its current keyword-search system, which determines the importance of a website based on the words it contains, how often other sites link to it, and dozens of other measures. Rather, the company is aiming to provide more relevant results by incorporating technology called ‘semantic search,’ which refers to the process of understanding the actual meaning of words.”

My guess is that Google will be using Schema.org markup, since that is what drives its +1 buttons for metadata, as well as potentially doing a bit of scraping/AI on existing content. Now would be a good time for all developers and content creators to evaluate how they are using semantic markup and make sure that they are up to par.

I have implemented Schema.org markup on this site through my Schema.org Twenty Eleven child theme. If you are using Twenty Eleven also, feel free to download it and start using it as well. You can read more about and download it here: Twenty Eleven Schema.org Child Theme. There is much more you can as well, specifically in adding custom and appropriate markup to individual posts/pages, but it provides a good start.

Share and Enjoy

  • Twitter
  • Google Plus
  • LinkedIn
  • Email
  • RSS
  • HackerNews
  • Instapaper
  • StumbleUpon
  • Facebook

I had a bizarre problem that had me banging my head against the wall for the last 24 hours that I was finally able to resolve. I’m putting up the solution I found in hopes that it helps some poor future Googler from repeating my same mistakes.

The situation was that I had a large PHP application developed with the fantastic Yii Framework that was working beautifully on my local machine as well as on my staging server. However, after deploying to the production server, I started getting the following PHP error all over the place:

Indirect modification of overloaded property some property has no effect…

Now for the uninitiated, the PHP engine prior to version 5.4 cannot do what is called “array dereferencing.” What is that? Suppose you have a method that returns an array, and that you want to use a particular element in that array right away. Example code:

function returnMyArray () {
	$myArray = array();
	$myArray['element'] = 'Find me!';
	return $myArray;
}
 
echo returnMyArray()['element']; // This will break.

In PHP 5.4 this will work, but not previous to. On my local dev machine I am running PHP 5.3.5, and the actual code situation was slightly different (magic getters and setters, see this post). After uploading to the production server, everything broke again. I refactored some code, but that still left some very weird errors in place, such as the following line that would not work:

$q->bindParam(':fid', $this->formId); // Where formId is an integer attribute of an object

That should really work, and it did on my local and staging servers. But not on my production, running PHP 5.3.10. AAAARRRGGGHHHH!!!!!

Temporary Solution

I will give you how I solved it, but then add a disclaimer about the solution. In my case, a simple, one line change to the error reporting levels was the solution. On my local and staging servers in php.ini was set to:

error_reporting  =  E_ALL & ~E_NOTICE & ~E_DEPRECATED

And on the production server? Missing that critical ~E_NOTICE. Adding ~E_NOTICE back in to my php.ini on the production server prevented the errors from being output. Due to a unique configuration of the production box which was out of my control, the NOTICE that was being generated by those types of lines was enough to stop the whole process. The application still works with those errors ignored, and I am back in happy land.

But what does that line do? The configuration signals to PHP to turn on and report ALL errors, except for NOTICEs and DEPRECATED warnings. By default, PHP ships with ALL errors on but NOTICE errors off. NOTICE errors are very handy to have on during development and debugging, because they can catch silly mistakes like uninitialized variables or ambiguous array indexes (slightly different than the problem I was facing). See this great StackOverflow post for some examples and suggestions. Now, in my case, I had verified that the code as written was actually conformant and functioning properly (in fact, the specific error was extremely related to this specific issue mentioned on SO). In this one case it was determined by the team to be safe to not have that particular error reported, because it was effecting the flow of the application.

However, do realize that turning off NOTICE errors may reduce your visibility into problems in your code. On a production box, it may be good to have the errors off as PHP ships by default, so that your users do not see them even if they should exist. But running all the time with NOTICE off during development may cause you to miss issues. Be aware when you modify the error reporting levels, and understand what you are doing.

Now I am just waiting for PHP 5.4 to get into the CentOS yum repository…

Share and Enjoy

  • Twitter
  • Google Plus
  • LinkedIn
  • Email
  • RSS
  • HackerNews
  • Instapaper
  • StumbleUpon
  • Facebook

Since the announcement of the Schema.org standards for microdata back in the summer of 2011, I have wanted to incorporate the new conventions into WordPress. At first I considered writing a plugin that would add information dynamically, but this didn’t seem to be a very efficient route. Instead, I have decided to extend the default Twenty Eleven theme that is already gorgeous and well-defined, and create a child theme that builds the microdata standard directly into the template.

Adding microdata to your site has several benefits. First and foremost, you contribute to machine readable data everywhere. The Internet is a wonderful place for humans to browse, but we can make it more accessible and more consumable if we let the computer figure as much of it out as it can. Second, search engines can use this data to get a better understanding of each page that it indexes, and hopefully provide more relevant search results. (Notice that I am not saying you are going to get an SEO boost for doing this. You may, you may not, I have no idea. But if everyone included this data on their sites, the results would be better.) There are no downsides really to simply plugging the data in.

If you are using Twenty Eleven as your theme and would like to add Schema.org microdata to your site without any effort on your part, give this child theme a try. You can download it for now from my Twenty Eleven Schema.org Child Theme page. Eventually I hope to add it to the WordPress Theme repository, but it needs some testing before it’s ready to head over there.

Hope it helps!

Share and Enjoy

  • Twitter
  • Google Plus
  • LinkedIn
  • Email
  • RSS
  • HackerNews
  • Instapaper
  • StumbleUpon
  • Facebook

Update: I recently reworked this tool and added some more options, and moved it to its own domain: http://www.linkedinbirthdays.com/ Enjoy!

Presenting a little tool to the world that others may find handy: my LinkedIn Birthday Reminders web app. It hooks into the LinkedIn API, grabs a list of your contacts, and generates an iCal file that you can import into your calendaring program and receive reminders throughout the year. (Can be imported into Outlook, Google Calendar, OS X’s iCal, etc.)

Screenshot of LinkedIn Birthday Reminders

The motivation behind creating this? First, LinkedIn gives you no easy way of exporting the data yourself. Second, I needed an excuse to learn Node.js. A few hours and an entire RFC later, I had a nice working prototype.

How does it work? It begins with the official LinkedIn API, and the ability to do an OAuth sign-in from any site. When you click on the sign in button (and don’t worry, I never gain access to your credentials), LinkedIn authorizes the request, and then some Javascript extracts a list of your contacts’ names and birthdays. This is then sent to my Node server and script via AJAX, and for everyone that has a usable birth date, the Node script cycles through them and generates a .ics file to download. The link to the file is passed back to the browser and presented as a download button, and after the download is complete, the file is then scrubbed from the server. Fairly simple stuff, and when I get around to it, I’ll put the source on GitHub. If you spot any bugs, be sure to let me know!

I invite you to try it out and grab the downloadable .ics for your contacts, and then make everyone’s birthday a little bit brighter by sending them some special day wishes!

Resources used:

Small Aside

Want a reason why I think the OS X operating system is fantastic? Check out the icon for this .ics file that I downloaded using my app:

iCal Parsed icon on OS X showing the date and title of the first event

The fact that the date shown is Oct 7 and the text says “Christian’s Birthday” is no coincidence—that is the first event in the .ics file! Now how cool is that? :)

Share and Enjoy

  • Twitter
  • Google Plus
  • LinkedIn
  • Email
  • RSS
  • HackerNews
  • Instapaper
  • StumbleUpon
  • Facebook