Father’s Day

September 3, 2006 @ 5:17 pm by walter — Filed under: Uncategorized

Today is Father’s Day in New Zealand. Read from this month’s newsletter from somebody:

Daddy (n): a man who has photos in his wallet where his money used to be.

I check my wallet. The princely sum of $5.80 and photos. Yup.

On the upside - a handcrafted “Happy Father’s Day” card (complete with the helpful warning “be careful!”), and handmade daddy wrapping paper enclosing .. my very own set of colouring pens. I mean, what could be more valuable, really?

What Financial Year does a date fall in?

September 1, 2006 @ 9:15 pm by walter — Filed under: .NET

The problem to solve is this: given a date (eg 1st September 2006), what financial year does it belong in?

A January to December financial year would make things simple, but this actually unusual. In New Zealand most common is the year ending 31st March, although many companies follow other conventions especially if they are part of a multinational corporation. See the Wikipedia article for more details.

I was surprised to not find a function for this in our company’s standard libraries, but I needed it, so I dusted off my brain and set out. And it wasn’t entirely obvious! (more…)

Windows essential command-line utilities

@ 12:05 pm by walter — Filed under: Technical

I often find myself wanting a number of command-line utilities for fixing problems, applying patches etc without having to be physically there. I might be on the phone to someone, or accessing a PC remotely, so I can’t copy them on via a CD or USB stick. Small, reliable programs that do the job well, with a minimum of fuss - thinks like editing configuration files, viewing logs, getting patches, zipping or unzipping files.

I’ve collected a few over the years, and some of them I’ve packaged up and put on this website. Mostly for my benefit, but you might have a use for them too. (more…)

What “MinMax persistance type of cookie requires a ModuleId” really means

August 25, 2006 @ 1:36 pm by walter — Filed under: .NET

I got this while working on a DotNetNuke module today:

ASP.NET MinMax persistenace error -screen shot

What this really means is

One of your user controls could not be compiled, and the error message from the compiler is plainly available in the file C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\dnn3\9ed962
a0\9cd87477\zyn7emjq.out , but I’m not written well enough to to tell you that myself

I really must move this project from .NET Framework 1.1 (and DotNetNuke 3.x) to .NET Framework 2.0 (and DNN 4.x). I don’t know if this will improve the error handling in the slightest, but at least I’ll know I’m swearing at the latest version of the software.

Rounding 5 cents DOWN (C# and VFP examples)

August 15, 2006 @ 10:55 pm by walter — Filed under: .NET, Visual FoxPro

In New Zealand small change is changing … we’re getting new 50c, 20c and 10c coins, and the 5c coin is being dropped. To match this the guidelines for rounding cash values are also changing.

Previously, the general guidelines were that values were rounded to the nearest 5c - values ending in 1,2,6,7 rounded down, and those ending in 3,4,8,9 were rounding up.

Now we need to round to 10c. However, the New Zealand Retailers Association guidelines state that values ending in 5c (ie exactly in the middle) are to be rounded DOWN (towards zero). This is not conventional mathematical rounding, that you’d find in a function called round() in most programming languages’ standard libraries. So I had to do some work.
(more…)

Linux answering machine?

August 9, 2006 @ 9:55 pm by walter — Filed under: Linux

Someone came in the other day - well, it was probably a week or two now - asking about a “Linux answering machine”.

Turned out he had a Windows machine with a 56k modem attached, which was operating as an answering machine. I knew those modems were supposed to be “voice capable” but this is the first time I’d ever heard of anyone actually using this (except as a gimmick). He wanted to get rid of Windows entirely since his main machine was running Xandros.

My first thought was of Asterisk, which has got a lot of good press recently and has an active development community. However even Trixbox (formerly Asterisk@home) doesn’t scale down as far as a voice modem! I was also vaguely aware of vgetty, but one look at the documentation and it’s obviously techie territory.

Then I stumbled across VOCP. (more…)

Convert Foxpro RGB value to ARGB for GDI+

May 19, 2006 @ 2:25 pm by walter — Filed under: Visual FoxPro

I can’t remember if there is a method for this buried in _GDIPLUS.VCX or not, but if you don’t want to use a GpColor object just to convert colours, the following tiny function would do:

function FoxRGBToARGB( tnRGB as integer, tnAlpha as integer )
   return  ;
      bitor( bitlshift(bitand(iif(vartype(m.tnAlpha)=='N', m.tnAlpha, 0xFF), 0xFF ),24) ;
	, bitlshift(bitand(m.tnRGB,0xFF),16) ;
	, bitand(m.tnRGB,0x0000FF00) ;
	, bitrshift(bitand(m.tnRGB,0x00FF0000),16) )

Example use:

m.foxrgb = getcolor()
m.argb = FoxRGBToARGB( m.foxrgb, 0xFF )
? transform(argb,'@0')

This technique is basically lifted from the foxrgb_assign method from the GpColor class, plus adding in the alpha value

VFP function to get the first line of a piece of text

March 24, 2006 @ 12:20 pm by walter — Filed under: Visual FoxPro

This is the story of a useful little utility function to extract the “first line” out of a block of multi-line text. If all you want is the function, then you can stop on the first page. If you’re interested in how someone can spend an hour writing a simple function that is less than 25 lines long, and why it ended up how it is, then read to the gory end!

function GetFirstLine( tcText [, tnMaxLen] [, tcEllipses] )
(more…)

« Previous Page