Not sure why she hasn’t killed me yet….

My wife was just lying in bed with her mum’s cat firmly ensconced on her stomach.

Me: “Looks like you’re in a predicament.”

Donna: “What makes you say that?”

Me: “Oh, just something I had a feline about…”

Posted by Garrett on January 4th, 2009 in Humor, Original | No Comments

Notepad++ syntax coloring

Lately, my external editor of choice has been Notepad++. It’s flexible, highly configurable, and supports user-defined syntax coloring. Of course, it doesn’t ship with a syntax coloring file for VFP, so I came up with my own. After a while, I got tired of typing in commands as I got to them, and wrote a program to generate the whole thing.

Read the rest of this entry »

Posted by Garrett on October 28th, 2008 in Code Sample, Original, VFP | 3 Comments

FLL versus Fox code

The other day, I mentioned the Levenshtein distance FLL I wrote. At the time, I had forgotten to time it. I downloaded Bob Calco’s Fox implementation from Ed Leafe’s download page, and ran it 10K times: it took about 2.2 seconds each time.

Then I tested the C version. It ran in 0.1 seconds each time. I like this. :-)

As soon as I get a chance to replicate the steps I went through, I’ll post it: I don’t want to just toss the FLL up without commentary.

Posted by Garrett on November 22nd, 2007 in Original, VFP | No Comments

GDIPlusX and ReportListeners

A while back, I wrote a short program showing how to use a ReportListener to change a field’s StringTrimming behavior. At the time, I used the GDIPlus foundation class which came out with VFP9. Now that Bo Durban and the VFPX folks have put together the GDIPlusX library, though, the code is a bit cleaner.

Read the rest of this entry »

Posted by Garrett on October 15th, 2007 in Code Sample, Original, VFP | 2 Comments

Instafilk

Thanks-I-think to Ted Roche and Ed Leafe, who triggered this one over on ProFox. :-)

Imagine there’s no spreadsheets,

It’s easy if you try.

No .DOCs or templates.

To edit, just vi.

Imagine presentations

Given manually,

Ooh ooh, ooooh.

You may say I’m a zealot,

but there’s more than one or two.

I hope some day you’ll reformat

And start to run Ubuntu!

Posted by Garrett on September 28th, 2006 in Filk, Humor, Original | No Comments

Teddy bear, or alien facehugger?

You be the judge.

Posted by Garrett on August 28th, 2006 in Family, Original, Photo sharing | 1 Comment

Phone post

Downtown seattle on a friday night. The drummer across the street from the busstop pounds on his tubs. The crowd mills by the Cheesecake Factory.

Mobile Email from a Cingular Wireless Customer http://www.cingular.com

Posted by Garrett on August 25th, 2006 in Original, Phone post, Seattle, Transit | 1 Comment

As I said before…

…I enjoy my own jokes.

Posted by Garrett on August 25th, 2006 in Microsoft, Original, VFP | No Comments

Writing code with _CLIPTEXT

I recently decided to write a program to automate part of a monthly job we have here. We have a tab-delimited file that has really long field names, some of which bear little resemblance to the purpose of the field. Rather than maintain a separate list of which old field went with the new names, I used the inline comment ability that was added to VFP a version or two ago, and put each field on a separate line of a CREATE TABLE statement. However, I got tired of typing in each fieldname, and decided to save myself some work.

lcRefStructure = "longFieldName1" + CHR(9) ;
 + "longFieldName2" + CHR(9) ;
 + "reallyLongFieldName3"

lnFldCount = ALINES(laStru, lcRefStructure, .T., CHR(9))

_cliptext = 'CREATE TABLE NewDBF ( ; ' + CHR(13) + CHR(10)
FOR i = 1 TO lnFldCount
 _cliptext = _cliptext + CHR(9) + " C()" ;
  + IIF(i < lnFldCount, ",", "") + " ;" ;
  + CHR(9) + "&" + "& " + laStru(i) + CHR(13) + CHR(10)
ENDFOR
_cliptext = _cliptext + ")"

This gives the output:

CREATE TABLE NewDBF ( ;
	 C(), ;	&& longFieldName1
	 C(), ;	&& longFieldName2
	 C() ;	&& reallyLongFieldName3
)

Which makes it easy to run down the list and fill in the specifics.

(Making sure that the format is still what you think you're importing is left as an exercise for the reader. :-) )

Update: fixed missing tabs in lcRefStructure

Posted by Garrett on August 24th, 2006 in Code Sample, Original, Programming, VFP | No Comments

Learning Perl

I recently had cause to write my first Perl script. Since I had never written Perl before, I wasn’t sure it was the right thing to do, so I went to the perl.beginners newsgroup for help.

My initial post:

I have an ASCII list of addresses that I need to parse into something
more-friendly to the software I need to use it with. I usually use
Visual FoxPro, and can think of a few ways to do it there: it just
strikes me that perl probably has much easier ways to do it. :-)

The response:

Yes, it is trivial in Perl. Enable paragraph-mode (see: perldoc -q
paragraph), read the file one record at a time. Split the record on
the newline (see: perldoc -f split), print the resulting fields
separated by commas (see: perldoc -f join).

I downloaded ActivePerl and went to work. After reading up on the above functions, I came up with the following:

local $/ = "\n\n";
open(ADDRESSES, "c:\\temp\\testing.txt") or die "Could not open input file: $! !";
open(OUTCSV, "> c:\\temp\\test2.txt") or die "Could not open output file: $!";

while() {
        $NextRec = "\"".join("\",\"", split("\n"))."\"\n";
        print OUTCSV $NextRec;

} 

Good grief, if I had realized it was that easy, I would have picked it
up long ago…

The response came back:

just FYI – it gets easier. if your addresses are stored in addr.txt:

  $ perl -ln00e 'print join ",", map qq["$_"], split /\\n/' addr.txt

I answered:

I think you just broke my brain.

The response from the person who had originally helped me:

Welcome to Perl. :-)

Posted by Garrett on August 22nd, 2006 in Code Sample, Computing, Original, Programming, perl | 2 Comments

« Previous Entries