Archive for February, 2009

Adding up Rows with JQuery

Simple and sometimes unnecessary function to add table cells together and populate another with the total. Using jQuery because its easy and it works and we all love it.

$(document).ready(function() {
    var x = 0;
    $("td.num").each(function() {
        x += parseInt($(this).html());
    })
    $("td#total").html(x);
});

Where your table cells to add up are <td class=”num”> and the table cell that has the total is <td id=”total”>.

Print Processor Updates for Windows Queues

A while back I wrote about a few little tools from Microsoft that allowed an easy way to create remote print queues. One of the things I didn’t realise then was that another handy tool exists (in the Server 2003 Resource Kit) called setprinter.exe that opens up a few more options.

We use a non-standard print processor at work to insert barcodes on certain output from SAP. So to set all the printers on the print server or just one to use the new print processor, we just run,

setprinter \\myserver 2 pPrintProcessor="SAP Barcode"
setprinter \\myserver\printer01 2 pPrintProcessor="SAP Barcode"

Lots of other properties can also be changed using setprinter.exe, pretty much everything other than security permissions and for that you can use another tool in the RK, subinacl.exe. To view the properties of a queue and what you can change, just cycle through the property groups 0-9 (that’s the 2 in the above commands).

for %i in (0 1 2 3 4 5 6 7 8 9) do setprinter -show \\myserver\printer01 %i

A Closer Look at Wiki Authorship

Jeff Atwood takes an interesting look at the history of changes to wiki pages and the balance between opinion and fact. The larger wikis (e.g. Wikipedia) have a huge amount of data around page edits and Jeff’s article also highlights an IBM study on how the more popular Wikipedia content evolves over time.

There’s also a comment about one of my favourite subjects – reading too much into statistics. Apparently Jimmy Wales (Wikipedia co-founder) looked into who was responsible for most of the articles changes and found that 0.7% of users were responsible for over 50% of all edits. But an “edit” may be a spelling correction rather than adding content or altering the facts or meaning in an article. As it turns out, the data points to these hyper-active users doing just that – cleaning up after everyone else.

Kisimi uses a basic string comparison function called simple_text() to show the relative difference between two versions of a page. We could also use the Levenshtein function which gives the minimum changes to go from string A to sting B, but that doesn’t always make much sense for larger content changes. If someone sees that two versions are 96% the same then it’s obvious they’re much the same.