All posts by shannah

Steve Hannah is a 28-year-old software developer currently studying and working at Simon Fraser University in beautiful Vancouver British Columbia. He specializes in web information systems and prefers Java, PHP, and Python as programming languages. He is a Christian and worships at Christ Church of China in Vancouver.

Boxing is about drama

I watched Rocky III for the first time in 1983. I was 4 years old. I watched Rocky III for the one hundredth time in 1983. I was 4 years old.

The Rocky series captured the drama potential that exists in the sport of boxing in a way that even a 4-year-old can appreciate. When you transition from the Hollywood into the real-world sport of boxing, however, the drama becomes much more subtle, and scarce. One has to be selective about the fights that he watches, lest he become engulfed in oceans of boring bouts between mediocre fighters. I generally only watch the fights that are broadcast on HBO. This is a form of personal quality control and it raises the likelihood of a fight being exciting from 1% up to about 35%. Still, it is seldom in real boxing to see the level of drama that the Rocky series conveyed.

Despite these low odds, I am still drawn to boxing for the potential of drama. I enjoy the thrill of seeing two undefeated champions go head to head (e.g. Oscar De La Hoya vs Felix Trinidad). I hope for my aging heroes to be able to turn back the clock, if only for a night, and reclaim their former form to defeat a younger rising star. Muhammad Ali’s defeat of a younger, stronger favorite George Foreman is one example of drama that exceeded the manufactured drama of Hollywood.

On Saturday night, Bernard Hopkins brought some more genuine drama to the Ring. At 43 years old it looked like he didn’t have much left to offer, based on his previous couple of fights in which he made his opponents look awkward but didn’t offer much offense himself. On Saturday, against middleweight champion Kelly Pavlik, however, he looked like a finely tuned and youthful boxing master. He completely schooled and dismantled Pavlik, leaving him in bewilderment of what had happened.

Prior to the fight Pavlik was undefeated, and was (and still is) a rising star in the sport. He had recorded two decisive victories over Jermain Taylor, who had defeated Hopkins twice a couple of years ago to take the middleweight title which Hopkins had held for a record ten years. Pavlik was a 4-to-1 favorite to beat Hopkins. The only question was whether he could knock Hopkins out. What actually happened was very different. Hopkins owned every round and, by about the fourth round, the question became whether Hopkins could knock Pavlik out.

Watching this fight reminded me of why I enjoy the sport of boxing. It can be seen as an allegory for life. You can watch a young prospect come of age, gain skill, face challenges and climb to the top of the proverbial mountain. Within a few short years, however, you are forced to watch this same prospect begin to diminish with age and be overtaken by the shadow of what he once was. But once in a while you get to witness a blazingly beautiful sunset to cap a great career and peel away the shadows that must ultimately prevail. I believe I watched such a sunset on Saturday with Hopkins’ brilliant performance.

I hope the sun never completely sets on Hopkins, but knowing that it must, I hope that it lasts at least a few more years.

Focus on the family spreading Republican Propaganda

Focus on the Family distributes bulletins that are handed out in many Churches across Canada and the United States. It contains small pieces of wisdom on Christian and family living. I was quite angered to find that they are abusing their trusted position in the minds of Christians to spread blatantly republican propaganda. The following story appeared in this week’s bulletin:

Before You Vote by Tom Minnery

You know you should vote, but how can you tell whether you’re voting for the best candidates? Here are some thoughts and questions to consider:

Separate principles from policies. Achieving noble goals like world peace or affordable housing requires how-to policies. Would the candidate’s policies likely increase the size of government? New programs usually mean higher taxes and more waste.

Does the candidate have a Christian world-view? Is he pro-life? Does she firmly support God’s definition of marriage? Does he believe that parents have ultimate say over what a child learns in school? A candidate’s positions on such issues are important.

Political parties matter but may not define a candidate. Sometimes a candidate takes a stand that his party does not. Some conservative Democrats were elected to Congress in 2006 by pledging to stop the wasteful practice of earmarks in the budget. But neither major party had the will to stop this.

It goes on, but I want to focus on these first three points to start.

Their first “thought to consider” (Separate principles from policies) is an underhanded way of scaring people away from the Democratic party.

New programs usually mean higher taxes and more waste

In plain English, this statement says that the Democratic party, if elected, will bankrupt the United States. This is a common form of fear mongering that Republicans have been using for years to scare the public away from Democrats.

So what does this recommendation have to do with Christianity? In fact it seems to fly in the face of teachings that we take care of the poor. Hence their first “thought to consider” is unrelated to Christianity, at best – at worst it is opposed to Christian doctrine.

The next thought speaks to the issues that should be important to a Christian (Does the candidate have a Christian world-view?). A good question to ask. But then they proceed to outline the important issues:

  1. Gay marriage
  2. Abortion
  3. Teaching religion in school

Hmm… If this list were comprehensive, then it would be clear that a Christian should vote Republican. But it is not. What about issues such as caring for the poor, ending bloodshed abroad, health care, education, etc… . These issues are not mentioned because the Democrats are (at least arguably) stronger on these issues.

The last “thought” (Political parties matter but may not define a candidate) is meant to demonize Democrats who profess to be Christian. In plain English it reads: “Don’t be fooled by Democrats who claim to be Christian. They are just as evil as their Democratic contemporaries.”

At the end of the article, they have the gall to refer you to their website that is purportedly “non-partisan”, to help you make your voting decision.

This article is deceitful (claiming to be non-partisan), and shameful from an organization such as Focus on the Family. If its views truly represent the issues that are important to Christians, then Christianity is in trouble and in danger of becoming irrelevant. The heartfelt concern that a Christian has over the definition of marriage would be a little more credible if he shows the same concern over the horrors of poverty and inequity in society.

Based on this article, I conclude that Focus on the Family is a partisan political organization that caters to upper middle-class white people and uses its trusted position to disseminate its right-wing propaganda.

WordPress CAS plugin adventures

I am building some SFU websites using WordPress and I need to set them up to use the SFU central authentication service (CAS). A quick search on Google found this plugin:
cas-authentication

I downloaded and installed it without trouble, but couldn’t seem to get it working. Likely it has something to do with the fact that it was written for WordPress 2.5.1, and I’m using the latest (2.6.1). The errors I was getting were unhelpful, basically just stating that the CAS authentication failed and that I was not logged in. I tried in vain to debug the script for an hour or so.

Then I came across a thread in a WordPress message forum indicating that I was not the only one having these problems. Through this thread, I was able to find another CAS plugin (written by Casey Bisson) that claimed to work with WordPress 2.6.1 – and the claims were true.

The plugin can be found at http://wordpress.org/extend/plugins/wpcas/

(Note to self: SFU uses CAS 1.0; not 2.0).

The only thing that this new plugin lacked was the ability to automatically create accounts when users log in. I made the following change to the wpcas.php file to add this behavior.


function authenticate() {
		global $wpcas_options, $cas_configured;

		if ( !$cas_configured )
			die( __( 'wpCAS plugin not configured', 'wpcas' ));

		if( phpCAS::isAuthenticated() ){
			// CAS was successful
			if ( $user = get_userdatabylogin( phpCAS::getUser())){ // user already exists
				// the CAS user has a WP account
				wp_set_auth_cookie( $user->ID );
				if( isset( $_REQUEST['redirect_to'] ))
					wp_redirect( function_exists( 'site_url' )  ? site_url( $_REQUEST['redirect_to'] ) : $_REQUEST['redirect_to'] );
				wp_redirect( function_exists( 'site_url' )  ? site_url( '/wp-admin/' ) : '/wp-admin/' );
			}else{
				// the CAS user _does_not_have_ a WP account

/**  BEGIN CHANGES TO ADD AUTO ACCOUNT CREATION **/
				if (function_exists( 'wpcas_nowpuser' ))
					wpcas_nowpuser( phpCAS::getUser() );
				else
					{
					// auto-registration is enabled
					require(dirname(__FILE__).'/../../../wp-includes/registration.php');
				  // User is not in the WordPress database
				  // they passed CAS and so are authorized
				  // add them to the database
				  $username = phpCAS::getUser();
     			  $password = md5('testing');
				  $user_email = '';
				  if ($cas_authentication_opt['email_suffix'] != '')
					$user_email = $username . '@sfu.ca';
				  
				  $user_info = array();
				  $user_info['user_login'] = $username;
				  $user_info['user_pass'] = $password;
				  $user_info['user_email'] = $user_email;
				  $res = wp_insert_user($user_info);
				  
				  $user = get_userdatabylogin( phpCAS::getUser());
				  
				  wp_set_auth_cookie( $user->ID );
				  if( isset( $_REQUEST['redirect_to'] ))
				  	wp_redirect( function_exists( 'site_url' )  ? site_url( $_REQUEST['redirect_to'] ) : $_REQUEST['redirect_to'] );
				  wp_redirect( function_exists( 'site_url' )  ? site_url( '/wp-admin/' ) : '/wp-admin/' );
				}			//	die( __( 'you do not have permission here', 'wpcas' ));
			}
/** END CHANGES TO ADD AUTO ACCOUNT CREATION **/		
			
		}else{
			// hey, authenticate
			phpCAS::forceAuthentication();
			die();
		}
	}

Now it works like a charm.

Feed2JS: Incorporate News feeds into static HTML webpages

My Recent goal. Minimize the amount of infrastructure in building a small website (i.e only use static HTML pages), and still incorporate dynamic content such as news and events in the web page.

Feed2JS is an invaluable tool for achieving this (at least the news and events part). You can embed an RSS feed into your web page with a tiny bit of HTML code (a script tag). Likely this RSS feed would go to a blog of sorts (easy to set up on any service).

You now have a web page with updated news and events, but doesn’t require any infrastructure (e.g. database or scripts).

IE Annoyances

There are hundreds of reasons not to use IE (Internet Explorer), but the common folk still seem to use it en masse, so I am forced to deal with its bugs when developing web pages.

A couple that I ran into today in IE 6:

1. No support for onload handler on script tag (makes dynamically loading scripts a pain).
2. No support for transparency or opacity in PNG files. I have a beautiful logo that looks great in all browsers except IE. IE just shows a gray background where it is supposed to be clear.

Haven’t gotten my hands directly on an IE 7 machine to test out, but by all indications, these problems still exist in IE7.

If you are still using IE, I beg you to switch to something else – anything else (e.g. Firefox, Safari (yes it is available for windows now), Opera, Google Chrome (Google’s new shiny browser). Just stop using IE and make the world a better place.

When the statistics show that less than 2% of the users are using IE, I can stop wasting my time on workarounds for it and focus on developing.

P3P: The answer to IE7 Iframe cookies problem

Problem:

I have a website where users log in at http://example.com.
I have an iframe that embeds pages from example.com on http://mysite.com.
IE7 Won’t retain the cookie (i.e. it keeps asking me to log in in the iframe)!

Workarounds:

1. Have your IE7 users set Internet Options >> Privacy >> Advanced >> Check “Override Automatic Cookie Handling” and “Always allow session cookies”

This is not so good because it is inconvenient most times to have all of your users make this change.

2. Use a P3P header. IE7 will allow the cookies as long as your site appears to have a privacy policy (using the W3C standard). Send this header just after session_start(); in PHP:


session_start();	// start the session
header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); 

For more on P3P see:

http://www.sitepoint.com/article/p3p-cookies-ie6/2/

For more on the IE7 Bug (or rather annoyance!!) see:

http://aspnetresources.com/blog/frames_webforms_and_rejected_cookies.aspx

Automatic Website Translation Service

I have just revamped my translation website, shifting the focus to providing machine translations of web sites. The site will allow users to upload their websites as a ZIP file, and have them automatically converted into nearly 30 languages.

I have leveraged quite a bit of open source software to make this happen, including Xataface, and this is only phase one. Xataface already allows developers to easily convert monolingual web applications written in PHP into multilingual applications complete with Google Translate integration, and support for human translation also. I am currently working on some modules to improve interoperability with other translation tools using the XLIFF document standard.

For those people who require a high quality human translation, I have provided a quote form from Translated.Net to get an instant quote. Ultimately translate.weblite.ca will become a portal with all kinds of tools and information about website internationalization. One step at a time ….

Internet Media Manager

I was tired of having to resize my images before uploading them to the web. I also wanted to be able to host more video on my website in a simple way. So I created an application to manage and serve all of my videos and images – Internet Media Manager.

Now I manage all of my media from a central location, and I can easily embed images and video into any of my web pages by copying and pasting a snippet of code.

Here is a brief guided tour: (this video is hosted using the Internet Video Manager):

Some notable features that are included:

  • Amazon Simple Storage Service (S3) integration for hosting video files. I want to host video but I don’t want it bogging down my server. Since Amazon S3 is so cheap and has such amazing capacity, it makes sense to store all of my video files on Amazon. The Internet Video Manager can be set up to automatically move all video files to my S3 account so that I can host video without worry.
  • Embeddable links – Images, videos, and photo galleries in the system can be embedded into any web page by copying and pasting snippets of HTML code.
  • Image resizing and processing – You can select the image size for embedding and the server will automatically resize the image.

Americans a funny bunch when it comes to politics

I have been following the American presidential campaigns of Hillary Clinton and Barack Obama with some interest, partly because I am interested to know what kind of a person will be in charge of our southern neighbour for the next few years. These are my impressions after having watched a debate and followed the campaigns of both candidates:

1. Hillary Clinton is quite happy to play the game of petty politics.
2. Barack Obama is a very strong speaker, and is quite good at avoiding the petty politics game.
3. Americans, by and large, seem to buy into petty politics.
4. Americans are VERY defensive about their country and do not tolerate criticism.

Let me elaborate on my impressions.

1. Hillary Clinton’s petty politics.

During the debate that I watched last week, she focused most of her energy into the following issues:
a. Obama’s connection to Pastor Jeremiah Wright, who made some controversial comments about 9/11.
b. Why doesn’t Obama wear an American flag? Doesn’t he love America?
c. Accusing Obama of being out of touch with the working man.
d. Characterizing herself as being from working stock because her grandfather had been a working man, etc…

Hence she didn’t really speak to any important issues. She focuses entirely on irrelevant little hot-button issues that are meant to get under people’s skin.

2. Barack Obama is a strong speaker:

Every attempt by Hillary Clinton to make Obama look bad on a petty issue was eloquently cast aside by pointing out the pettiness of the issue, while redirecting out attention to more important issues like the war, health care, and the economy.

3. Americans seem to buy into petty politics:

Despite the fact that Hillary is obviously playing petty political games, many in the American public seem to be buying into it. Who gives a damn whether Obama wears an American flag? Well I guess a lot of people do.

4. Americans are VERY defensive about their country

The comments of Rev. Wright have been blown way out of proportion. He suggested that the 9/11 attacks were some how brought on the US because of the US foreign policy. I cited many cases of US aggression that could have been causes of people “hating” America. His statements, in any other part of the world, were not controversial at all. Americans like to think that they have never done anything to the rest of the world and that they are completely innocent victims in the 9/11 attacks. Any talk to the contrary is met with calls of heresy. Get real, America!

I sincerely hope that there are enough intelligent Americans to see through the petty politics that Clinton is playing so that the election can be won or lost based on real issues – and not on petty politics.

Screenflow: Finally Screencasting done right

For the past couple of years I have been dabbling in the art of screencasting. I think that providing video tutorials for my software can be much more helpful to my users than producing standard web page documentation. However, I have struggled to find any good solutions. Prior to my discovery of screenflow, I had experimented with Snapz Pro X, iShowU, VLC, and many other forgettable solutions. The best of this bunch was iShowU, but it is so far behind Screenflow that it almost isn’t even worth comparison. I’m still bitter towards Snapz Pro X because of how difficult it seems to be to uninstall (and the pop-up box every 10 minutes asking me to purchase the software is a real pain).

So why is screenflow so much better?

1. I can’t figure out how it works so well. You can play high definition video on your mac and record it with screenflow without losing any apparent quality. It just works. This enables me to more easily take a clip of two from a DVD or streaming video source to include into my works without jumping through any hoops.

2. No more file size/video quality trade-offs. When recording it doesn’t have a zillion configuration options. You just press “record” and it works. What’s more it doesn’t seem to bog down the computer like all the other solutions did. You can start it recording and not even notice that it is running.

3. Integrated webcam and keynote. I have been longing for good solution in this realm for a long time. Screenflow will automatically record from your web cam while you perform your screencast. In post production it is easy to alternate between the webcam and the screen, and you can even do picture-in-picture. The keynote feature is really cool too, as it is a common requirement to have a sort of running keynote presentation along with the screencast.

4. Effects and post production. It has all the toys I need for polishing the screencast when i’m done. Zooming in on windows, highlighting sections of the screen, dimming out irrelevant portions of the screen, etc…

I give this software a 10 out of 10. It is the very first of its kind to get it all right.