Snow!

Last year I was in Loveland, Colorado during a freakish week of cold and snow. When I left Montreal, we hadn’t had *any* snow yet - and this was January - very unusual. It wasn’t until when I got back in mid-January that we actually had snow.

Well, this year, we’ve had 2 snow storms already, and something else I’ve never seen before. In the middle of the snowstorm, we had thunder and lightening. Yup, never in my 36 years have I ever seen that. In fact, most people I’ve spoken to today started off the conversation with ‘Did you see the lightening and hear the thunder?!?’. Surreal.

Here are photos taken from my front door about 20 minutes before the thunder and lightening:

Snow storm Snow storm

There has easily been another foot of snow that has fallen since that time, and 14 hours later, it’s still falling.

Update: So, the next morning I was out to visit the osteopath (good thing too, since I had to shovel out the front door). I took these photos post storm:

Snow storm Snow storm Snow storm

Snow storm Snow storm Snow storm

Potter the pumpkin

A couple of years ago, I did the Tux pattern (from The Pumpkin Lady). The photos of it are here:

Tux Pumpkin closeup
Front door 2003

This year, I decided that Potter (the ‘Yellow Dog’) would be the subject:

Potter the Pumpkin - Light
Potter Pumpkin with light

Potter the Pumpkin - Darker
Potter Pumpkin a bit darker

Potter and friends
Potter Pumpkin at the front door

Happy Halloween!

I had a problem that I needed to solve recently, and the most elegant way to do this was with a stored procedure. However, the procedure needed to return 2 columns - an index id and a sort order. One way to tackle this is to have the plperl function called by a wrapping plpgsql function, but that’s ugly. I wanted to do it all in plperl, but couldn’t find any documentation on it with custom rowtypes. So, off to IRC for some info.

xzilla on #postgresql (irc.freenode.net) pointed me out to a recent blog posting of his that seemed to do what I wanted using Out parameters. This was really great, and I knew I had something I could work with there. Thanks xzilla!

So, I took it a bit further and modified his example slightly to see if I could also do it without the out parameters and just use the rowtype. Here’s the result:

CREATE TYPE footype AS (number int, oddoreven text);

CREATE OR REPLACE FUNCTION odd_or_even(int) RETURNS SETOF footype
AS $$
my @Return;
my $Count = 1;
my $Input = $_[0];

while ($Count <= 10) {
  if ($Input%2 == 0) {
     push @Return, { number => $Input, oddoreven => 'even' }
  } else {
     push @Return, { number => $Input, oddoreven => 'odd' }
  }
 $Count++;
 $Input++;
}

 foreach my $Row (@Return) {
     return_next $Row;
 }
 return;

$$ LANGUAGE plperl;

test=# SELECT * FROM odd_or_even(23)
test=# ORDER BY odd_or_even.oddoreven;
 number | oddoreven
--------+-----------
     24 | even
     26 | even
     28 | even
     30 | even
     32 | even
     23 | odd
     25 | odd
     27 | odd
     29 | odd
     31 | odd
(10 rows)

« Older entries

 

September 2008
S M T W T F S
« Dec    
 123456
78910111213
14151617181920
21222324252627
282930