lolcat

July 8th, 2008

humorous pictures
more cat pictures

External graphics in XSL:FO not sizing correctly

June 4th, 2008

I’m using Apache FOP to generate PDFs from XSL:FO, and an external graphic (think the <img> tag in HTML) kept being resized incorrectly. Another image (different size) was the correct size on the page. Turns out I was using height and width attributes in the fo:external-graphic element, when I should have been using content-height and content-width. Somehow the second image respected the height and width I wanted. Possibly this has something to do with the stored DPI of the images (since XSL:FO is a specification for printed documents), but in any case content-width and content-height is the way to go. Way to go, Ben :P

Added Subscribe to Comments plugin

May 3rd, 2008

Thanks to Jylan, I’ve just added the Subscribe to Comments plugin, so when you leave a comment you can subscribe to recieve new comments for the article via email. Groovy.

I’ve also upgraded to Wordpress 2.5.1. Also groovy.

Also, a big shout-out to the Australian labour movement for the 8 hour workday, and probably a few other things, including this long weekend. Damn the man. Save the Empire.

Upson Downs Photography website launched!

April 9th, 2008

Upson Downs Photography

I’m very pleased to announce the launch of Upson Downs Photography, a project of my father’s to sell prints of his beautiful photography online. It’s fairly basic at the moment, no pricing or good descriptions of the photos are online yet, but new features will be added as we go.

In the meantime, please explore the galleries, drop in a word of encouragement or product enquiry via the contact page, and support a local photographer.

On a technical note, this is my first use of CakePHP in a production website!

ZedGraph - .NET graph control

March 28th, 2008

Today I needed a graphing control, and with a bit of searching found ZedGraph. This has got to be the best open source .NET component I’ve ever used. All you need to do is reference the .DLL, drop a ZedGraph control onto your form or control, and add some code to load in a data range. It’s even easier to make a pie chart and the colours, gradients, etc., are all customisable. Out of the box the control automatically has zooming, scaling, printing and exporting features accessible to the user, and it looks nice and clean. There’s also a ZedGraphWeb control built in which is for use in ASP.NET apps (although I haven’t tried that out).

There are two concurrent versions for both .NET 1.1 and .NET 2 (which is very handy since I’m limited to .NET 1.1 at work). The only difference between the versions is apparently use of templates for collections.

There’s a CodeProject article that gives a pile of simple demo code, and the main site is a Wiki with what looks like plenty of documentation. The library is licensed under the LGPL license, which means that derivative works must be LGPLed, but as long as the library’s DLLs are dynamically linked they can be included in commercial software.

Editing past log comments in Subversion

March 18th, 2008

Subversion is my source version control software of choice, but it’s not immediately obvious how to edit the log comment of a past commit (such as after adding a particularly scathing remark that may not be a wise career move). A caveat is that you need to have administrator access to the Subversion repository.

In the repository directory (wherever you created the repository) is a hooks folder (on my system this is H:\IT\svnrepos\pas\hooks). This folder contains scripts that are called by Subversion when various events occur (hooks). The files that are created in a repository’s hooks folder by default are templates of hooks designed for Linux etc. On a Windows server they need to be created as batch files (*.bat) to be executed.

What you need to do is create a hook that will run prior to changing a revision property (such as a log comment) and let Subversion know that changing the comment is permitted. By default changing the log comment is disabled (obviously, or you wouldn’t be reading this). Make a new file in the hooks folder called pre-revprop-change.bat and write the following into it:

if "%4" == "svn:log" exit 0

echo Property '%4' cannot be changed >&2
exit 1

The %4 argument contains which operation is being performed. If the operation is svn:log we indicate success, which is a return code of 0. Otherwise it prints an error and exits with a non-zero, which indicates an error (and that the operation shouldn’t be allowed). Once that is saved, you should be able to use your to Subversion client to edit the comment. Be careful with what you do, as revision properties aren’t versioned, and you won’t be able to undo your changes. You should also probably rename pre-revprop-change.bat to pre-revprop-change.bat.bak once finished.

Logical XOR operator in C#

March 4th, 2008

For reference the logical XOR operator in C# is the same as the bitwise XOR operator: ^. This always gets me because usually the logical boolean operators are like && and || versus the bitwise operators (& and |). I guess it’s the same thing anyway, just a bitwise XOR operation on two booleans. Fascinating.

zomg! a tux racer arcade game!

February 27th, 2008

At Movieworld there’s a Tux Racer arcade game! Pictures after the fold!

Read the rest of this entry »

Could not find resources exception when modifying a form class in Visual Studio .NET 2003

February 21st, 2008

I changed the name of a form class and added a new class at the top of the class file with the same name of the old form class, descending from the renamed class to avoid breaking old code. Then when I ran the app I got an exception saying that the form’s resources couldn’t be loaded. When I had a look at the resources file for the form (<project folder>\obj\Debug) a resources file was still being created for the old class name instead of the new one. Since this resources file is the one that gets linked into the DLL or exe, this meant that the new form class couldn’t find its resources. According to Microsoft KB318603 this is because other class definitions located before the form class definition will be picked up when naming the resources file. So if this happens, move the other class to after the form class (ie the MyForm.cs file should contain first the MyForm class then any other classes).

Of course the best thing would be to move the other classes into another file but that sounds like work :-)

Cookies not being sent back to the server

January 26th, 2008

I’ve been playing with CakePHP, which is an MVC framework for PHP (the PHP equivalent of Ruby on Rails) and had this annoying bug where the session cookie (which holds a session hash) gets regenerated with every page request. This had the effect that, when I saved my User object in the session after validating the login, the cookie’s value would change to a new hash (losing the auth data), meaning that the logged in status was lost when requesting a new page.

I knew that the session was getting the user data inserted, because I could see the sessions and data being created on each request. I also knew that the browser was receiving the cookie with the last generated session hash. So, since CakePHP generates a new session for each request that isn’t accompanied by a session cookie, I figured that my browser wasn’t sending the session cookie with the request.

Point 1: if you can’t make your session stick, see if you’re getting a different session hash each request, because maybe the server just isn’t receiving the cookie.

Then I tried to figure out why cookies weren’t being sent. It turns out that having a space in the url of a website (which gets converted to %20, as in http://localhost/Internal%20Projects/CakeTest) stops cookies from being sent. This may have something to do with the web server (Apache 2.2.26) or the fact that I’m using a preconfigured WampServer Apache-MySQL-PHP stack, but it is common to both Firefox 2 and IE7. Which brings me to…

Point 2: don’t put spaces in your development server’s folder names when using cookies.