Patch for JWPlayer

I made a website for the Positive Parenting Program of the Manitoba Government while working at Canada’s Web Shop, and it had videos on one of the pages. Because the videos are self-hosted, I used the excellent JWPlayer for WordPress plugin, and it worked great except that when the staging site was brought down the videos stopped working.

It turns out that JWPlayer for WordPress is using WordPress guids instead of using the wp_get_attachment_url() function that makes it safe to move your WordPress website between domains. In short, the guid column in the posts table stores the original URL of the video, and if you change domains, the only way to get the correct URL is to use the aforementioned function.

I wrote a little patch, notified LongTail Video, and it is on its way to being included in the plugin.

My GitHub Resume

Since I’m using GitHub for the ProjectPier work I’m doing, one of my senior colleagues at Tactica mentioned that GitHub has a resume creation app, that nicely showcases the different work a developer does through their service. Here’s my GitHub resume.

I tweeted about that, and the always friendly Web Development Instructor at Red River College, Kyle Geske, replied with a link to his GitHub resume.

A GitHub resume, based on a history of code commits that a developer has made can be a valuable resource to use when looking for a new job, because it shows the ability to develop software.

Create yours and link it here if you please! Oh, and you can fork the code and contribute enhancements.

First Blog Post at Canada’s Web Shop

My new employer, Canada’s Web Shop, encourages its employees to blog and tweet through the company’s blog and twitter accounts. They encourage everyone to tweet twice a week, and we take turns blogging weekly. Some people tweet daily, and blog once each week. There is an opening for another weekly blogger, since an employee who was blogging weekly left recently. Is this a good opportunity for me?

Recently, it was my turn to blog, and I wrote an article about PHP development support tools that I like to use.

Refactoring PHP

Here are some common opportunities for improving the maintainability of code through refactoring that I find when reading code.

  1. Replace Duplicated HTML with Iterating Over an Array

    The purpose of most PHP code is to output HTML that the web server will send back to the browser. If you have a table that has 20 rows, and all those rows have the same structure, but the data in each row is different, you could write it 2 ways:

    1. Duplicated HTML

           <tr>
             <td align="center" valign="middle" class="messageFormTd3">2010-05-04</td>
             <td align="center" valign="middle" class="messageFormTd3">Copenhagen</td>
             <td align="left" valign="top" class="messageFormTd3">City Hall</td>
             <td align="center" class="messageFormTd5">10:15</td>
           </tr>
           <tr>
             <td align="center" valign="middle" class="messageFormTd3">2010-05-02</td>
             <td align="center" valign="middle" class="messageFormTd3">Zagreb</td>
             <td align="left" valign="top" class="messageFormTd3">Main Square</td>
             <td align="center" class="messageFormTd5">12:30</td>
           </tr>
    2. Iterating Over an Array

                 <?php foreach (array(
                   array('date' => '2010-05-04', 'city' => 'Copenhagen', 'venue' => 'City Hall', 'time' => '10:15'),
                   array('date' => '2010-05-02', 'city' => 'Zagreb', 'venue' => 'Main Square', 'time' => '12:30'),
                 ) as $event) { ?>
                 <tr>
                   <td align="center" valign="middle" class="messageFormTd3"><?php echo $event['date'] ?></td>
                   <td align="center" valign="middle" class="messageFormTd3"><?php echo $event['city'] ?></td>
                   <td align="left" valign="top" class="messageFormTd3"><?php echo $event['venue'] ?></td>
                   <td align="center" class="messageFormTd5"><?php echo $event['time'] ?></td>
                 </tr>
                 <?php } ?>

Hello World – First Post

Hello world!

I am really excited to be writing my first blog post as part of setting up my online presence at bernardic.ca.

Since I work as a programmer, and have a Bachelors degree in Computer Scrience, I think it would be good to start with a hello world. Here it is in all the programming languages I use or have used. The constraint is of course that I don’t look it up on the Web or in other people’s source code, but rather either go by memory, or memory plus the help of a compiler/interpreter:

PHP

<?= 'Hello World!'?>

Ruby

puts 'Hello world!'

Python

print 'Hello world!n'

Java

public class Hello {
  public static void main(String[] args){
    System.out.println("Hello world!");
  }
}

LISP

(print "Hello, World!")

Perl

print "Hello World!n"

C

#include <stdio.h>
int main() {
  printf("Hello World!n");
}

bash

echo 'Hello World!'

Javascript

alert("Hello World!");

or

window.onload = function () { document.write("Hello World!"); }

C#

using System;
public class Hello {
 public static void Main() {
    Console.WriteLine("Hello World!");
 }
}

There it is. I also tried C++, but could not figure out the whole stdout << “Hello World!”, or however it would actually go. 🙂 Happy Coding!