Arrow

Posts on this site are never sponsored.

Vancouver SkyTrain routes superimposed onto Google Maps!

I take the SkyTrain every day. But do I actually know where any of the stops are located? No. So if I want to pick someone up by car from a SkyTrain station other than the one near my house, that is quite the arduous task. Where the heck is Nanaimo SkyTrain station? Look on Google Maps and you can see the London and Paris metro maps superimposed over all the streets, but there’s no love for Vancouver.

Luckily I found a Vancouver SkyTrain Google Map made by some guy named David. It even has the SeaBus and the West Coast Express. This is beautiful.

Show nicer, reverse titles on your WordPress blog

By default, WordPress titles (in the title bar of the browser) look something like this:

Title of your blog » Post title

To help people find your blog better (ew, is this a post about SEO?), the order should be reversed, so that your post title comes first. For example, if someone searches for “make your own family feud game” on Google, one of my posts shows up quite high in the rankings. But with the default title, the Google result shows “Peter’s Useful Crap” and then the post title “Make your own Family Feud Flash game”. I’m willing to bet that people care less about the title of the site offering the information than about the specific post.

There are plugins that let you customize optimal titles, but that’s not really necessary. To have a title such as:

Post title | Title of your blog

Use this code in your template’s Header page (header.php):

<title><?php wp_title('', TRUE); if (!is_home()) print ' &#124; '; ?><?php bloginfo('name'); ?></title>

(To edit your template files, visit “Template… Theme Editor” in your WordPress admin panel.)

Show crop marks when exporting a business card PDF with bleed in InDesign

Whenever it’s time to print new business cards at work, I forget which settings to use for exporting the PDF in InDesign to send to the printing shop. Trial and error is a waste when you know you’ve done something before.

We have 3.5″ x 2″ business cards with some bleed (“bleed” means that the ink goes directly to the edge of the paper, so the printer must print a slightly larger page and then cut it). Here is a screenshot of the settings so that I don’t forget next time:

Screenshot of my InDesign crop mark settings for business cards

To add some more value to this post, here’s a short list of (two) things I’ve learned the hard way about printing business cards:

  • Always get a print proof from the printing shop. An electronic proof is rather useless, because you can check that yourself on your computer.
  • Either provide the printing shop with the fonts used or create outlines of all text boxes in InDesign before exporting to PDF (select the text and choose “Type… Create Outlines” or press CTRL + Shift + O (or Apple + Shift + O) on your keyboard). The “embed fonts” option does not always work well.

Bypass website blocks with proxies

At some workplaces (not mine, thankfully), their firewall prevents you from accessing certain websites. I understand (but don’t agree with) the reasoning behind reducing workplace web distractions such as Facebook, but sometimes you actually have a legitimate need to access one of those sites. Or, using Facebook as an example, if you need to take two minutes to RSVP to a non-work event on there, I say go ahead. Do it on your lunch break if you’re really concerned.

So how are you going to access a blocked website? (Hey this would come in handy in countries where they filter what you can access on the Internet…) Visit a website that offers up the use of a proxy. A proxy in this case is a “middleman” browser. You specify which destination website you want to access to the proxy website and it will visit that website for you. To your workplace, you are visiting the proxy website. To the destination website, it is the proxy website that is accessing it. You still get to browse the information on the destination website.

This also comes in handy if you’re paranoid about broadcasting information such as your IP address to the destination website. You can surf semi-anonymously this way.

A good web proxy is my-proxy.com and anonymouse.org. You can also search for “web proxy” on Google.

How to calculate games behind in PHP and MySQL

I’m working on a custom implementation of my sports league standings script for a baseball league (this could also come in handy for a basketball league) and one of the standings columns is games behind (GB). I’d found a great tutorial for this, but couldn’t find it the second time around! So I guess I’ll post my code instead of a link!

Let’s assume your database table looks like this:

teamid teamname teamwins teamlosses
1 Stallions 42 43
2 The Fridays 43 44
3 Frames 53 34
4 Pandas 38 50
5 Alligators 52 33
6 Lightning 34 53

Games behind deals with win-loss differentials. The top team has the biggest difference between wins and losses:

// open a table and typically create other columns (the other columns have been omitted for this example)
  print '<table border=1 cellpadding=5><tr><th>Team</th><th>W</th><th>L</th>';
  print '<th>GB</th></tr>' . "\n";

// put your database connection stuff here

// run the query to select the top team and use something like games played (ideally following by other stats) to sort out a tie at the top
$query = "SELECT teamid, teamname, teamwins, teamlosses, (teamwins +  teamlosses) AS gamesplayed, (teamwins - teamlosses) AS gbvalue FROM sportsdb_teams ORDER BY gbvalue DESC, gamesplayed DESC LIMIT 1";
$result = mysql_query($query);

// grab the results of the query

  while ($topteam = mysql_fetch_array($result, MYSQL_ASSOC)) {

$gbvalue = $topteam['gbvalue'];
$teamid = $topteam['teamid'];

// Print the team stats and use "---" to indicate that it is the top team
print "<tr><td>{$topteam['teamname']}</td>";
print "<td>{$topteam['teamwins']}</td><td>{$topteam['teamlosses']}</td>";
print "<td>---</td></tr>\n";
}

———————————-

The order of the other teams is determined by the leader’s win-loss differential minus each team’s win-loss differential, divided by two ((($topteam['gbvalue']) – (teamwins – teamlosses)) / 2):

// Select the other teams
$query="SELECT teamid, teamname, teamwins, teamlosses, (teamwins  + teamlosses) AS gamesplayed, (($gbvalue - (teamwins - teamlosses)) / 2) AS gamesbehind FROM sportsdb_teams WHERE teamid != $teamid ORDER BY gamesbehind, gamesplayed";

$result=mysql_query($query);

// loop to print all the teams
while ($otherteams = mysql_fetch_array($result, MYSQL_ASSOC)) {

// Show if a team is tied for the lead
$gamesbehind = number_format($otherteams['gamesbehind'],1);
if ($gamesbehind == "0.0") $gamesbehind = "---";

// print the results
print "<tr><td>{$otherteams['teamname']}</td>";
print "<td>{$otherteams['teamwins']}</td><td>{$otherteams['teamlosses']}</td>";
print "<td>$gamesbehind</td></tr>\n";
}

// close the table
print "</table>\n";

———————————-

And here’s the result:

Team W L GB
Frames 53 34
Alligators 52 33
The Fridays 43 44 10.0
Stallions 42 43 10.0
Pandas 38 50 15.5
Lightning 34 53 19.0