Tech Archives, page 40

All things technology. Very popular here on Justinsomnia.

style for including URLs in email

usually i write my emails so that any embedded URLs, like this:

http://www.pcwebopedia.com/TERM/U/URL.html

have a blank line above and below to provide easy extraction, especially if the URL wraps or is followed by punctuation. but for a week or so now i have been watching the traffic on www-style [1], and i’ve discovered a different approach that i like.

rather than breaking up the flow of a paragraph as i did above, people include a number in square brackets that refers to a URL with the same number at the bottom of the email.

what’s strange is that i can’t find any real tech savvy online references that mention this style. i’m not sure if this is just a social custom that people on the list have picked up, but in any event i thought i would record it here for posterity and conversation.

–justin

[1] http://www.w3.org/Mail/Lists.html#www-style

encapsulation is wonderful

i just finished building an object in php. well, a “class” really, called HTMLTable HTMLTable (latest version) to help me generate html tables.

my financial web application spits out a lot of information in the form of tables, with headers, column headers, footers, etc. i’ve been using a simple function that surrounds the content in each cell of my tables with TDs. but i still had to make sure all the TRs were in the right places, and i had to get the COLSPANs right for my headers and footers.

now i’ve just got this simple class with functions for adding-in the various parts of the table and then a function that spits out html all nice and formatted, all the right tags in the right place. ahh…

it was just so wonderful to spend time this morning and this evening crafting it, revising it, making it sure it accomodates all my known cases of table usage.

whereas all the other code i’ve written has been motivated by “i need a webpage to do X” or “i need a function that i think i might use in the future” this is the first time i’ve worked on something that seemed to have some objective rightness in the universe. like i wasn’t creating something new, i was discovering something old.

css pseudoclass for negative numbers

let’s say i have an html table of financial data that looks like this:

dogs 500
cats -600
fish 100
aligators 50

i would like to specify that negative numbers have the declaration {color: red} without having to individually specify style for some table cells and not others.

the code for this might look like:

TD:negative-number {color:red}

and the resulting table would look like:

dogs 500
cats -600
fish 100
aligators 50

update 16-July-2004:

the problem is that variations in content are infinite. so it probably wouldn’t make sense to create a “:negative-number” pseudoclass because 100 different people would probably request 100 different selectors for their special cases.

maybe there is a way to take advantage of simple pattern matching based on content, perhaps using regular expressions?

the following would read “make the text inside TDs red if that text begins with a hypen (minus-sign) and ends with one or more other characters.”

TD:content-regex(/^-.+/) {color:red;}

the benefit of this approach being that if negative numbers in your document are surrounded by parentheses, you can modify the regular expression in the stylesheet rather than having to modify your document to play nice with a UA’s implementation of “:negative-number”.

update 17-July-2004:

i discovered thanks to the folks on www-style that you can apply multiple classes to an element using a space separated list:

<TD CLASS="financial negative">-190</TD>

also, there is a :contains pseudoclass in the works for css3 that would definitely accomplish what i was proposing using regular expressions above. also helpful would be an NR tag in XHTML2 for specifying numbers, perhaps with attributes like positive and negative.

mapping the trails off estes

i’ve been playing with terraserver and topozone lately, downloading and splicing together some satellite photos of an area bounded by estes drive (ext), seawell school road, homestead road, and the backs of some neighborhoods northeast of north greensboro street.

map of estes trails area

triangle mtb suggests it might be illegal to post information about those trails if they’re on privately owned land. i guess i should find out who owns that land. any librarians out there have any suggestions about how i might do that?

so far the piece de resistance is a full color satellite photo overlayed with the contours of a topographic map. of course i’m not sure what good it’ll do, but it was very cool trying to get the contour map to match the photo, sans-gis. it’s a little too busy if you ask me.

contour map of estes trail area overlayed on satellite photo

next i’m working on a massive composite image of the highest resolution satellite photos available on terraserver. we’re talking .25 meters per pixel, 800×600 pixels at a time. so far i’ve created a 140MB bitmap image in fireworks that’s 10,000 pixels high and 4000 pixels wide.

this picture is so high res i can actually see some of the trails through the trees. luckily the photo was taken in march of 2002, so the leaves aren’t on the non-pine trees yet.

how to count unique records with sql

question

let’s say i have a table with one column containing the following 6 records:

3
3
4
5
5
6

is there a way with a single standard SQL query to count the unique records in that column? (the query should return “4”)

answer

the following sql works in MySQL, Oracle, and SQL Server:

SELECT COUNT(DISTINCT column_name) 
FROM table_name

the following sql works where ever subqueries are accepted (like Microsoft Access):

SELECT COUNT(*)
FROM (SELECT DISTINCT column_name FROM table_name)
/* or */
SELECT COUNT(*)
FROM (SELECT column_name FROM table_name GROUP BY column_name)

NB: Access’s Query by Example (QBE) UI will transform the first query above into:

SELECT Count(*) AS Expr1 
FROM [SELECT DISTINCT column_name FROM table_name]. AS [%$##@_Alias];

the %$##@_Alias is just some whacked out alias (i’m sure there’s a story behind that), but it could be anything. however the “.” (period) after the bracket closing the subquery, well, apparently that’s required. i’m not sure why.

thanks dad and tim!