odbc (windows) groovy

i tried machine dsn on Server 2008 (database is Synergy, xfODBC driver) and user dsn on XP (sql server 2008 express), both worked the same for me. In this case default catalog/default database is specified in DSN. MSSQL is the name I gave my DSN.

Note that if a jdbc driver is available for your db you should use it (says sun). Example pages at Codehaus have a specific recommendation for Microsoft SQL server. On my sql server, groovy couldn't read the unicode columns.

import sun.jdbc.odbc.JdbcOdbcDriver;
import groovy.sql.Sql;

inject

A few years ago some one asked in the groovy users mailing list: "I got two equal length lists, how do I turn it into a map where one map is the keys and the other is the values". Guillaume Laforge offered a one-liner. It transposes the pair of lists into a list of pairs, and builds a map using the pairs of elements as keys and values. Here's the one liner (not the same variable names as M. Laforge or the OP used). Say the lists are called "Stars" and "stripes":

[stars,stripes].transpose().inject([:]){accretion,addition->accretion[addition[0]]=addition[1];accretion}

Posting to blogger with groovy

I want to put together something for my wife to post with blogger more conveniently. First step is to check whether I can get Groovy to submit it... then the matter of hooking some customizable editor... all has to run on puppy linux... a bit of glue here and there... So I got the first groovy->blogger part working with httpBuilder, but I've hit a stumbling block I haven't resolved yet. When httpBuilder sends the post, the body I want to send has to be a closure, and in this case I'd be better of with some string type thing. (Anyway, I don't know how to make the closure on the fly.

Finding dupe lines and alternatives

So I want to compare some files from easton and gloucester, see if they have any common lines

def e =  new File("H:/tmp/easton.txt")
def g = new File("H:/tmp/gloucester.txt") 
assert e.exists() && g.exists()

i = 0 ; 
e.eachLine { eline -> 
    g.eachLine { gline ->
        if (gline == eline) { 
            i++ ;printf("%4d %s\n", i, gline )
            }
        }
        }

Gracious me, they're almost all matches, how can I get only the ones where they don't match?

SSRS - notation for refering to fields when you don't know the name of the field til runtime

in

note on this post, I submitted from outlook, not plain text, and it wound up with all sorts of horrible html in the post - I just cleaned it out by hand but there might be a typo - once I am back at work and test it I'll remove this comment.

I had to format a bunch of different phone numbers (home, cell, business) in one report. I wanted to format them all with the same function, but in SSRS you can't just say "code.FormatPhone(Fields!whatever.value)", because if it's missing you get an error. You can test for whether it's missing, but it turns out that doesn't buy you anything, as anyone reading this is probably familiar with. So to keep from having a dumb switch/select thing - The notation below worked:

groovy -use MarkupBuilder, elements found at runtime, namespaces

Writing an xml document in groovy - there is a "MarkupBuilder" class. Syntax is weird (to me) - you make an instance of a Markupbuiler, Send it a writer in the constructor, then just stick some classes on it.

import groovy.xml.MarkupBuilder
def w = new FileWriter('report.xml')
def xmlDocument = new MarkupBuilder(w)

fileops

// unfinished draft - to catenate a bunch of files with same basename into a single file with
// imagemagik

def f = new File('.\\tifs') ;   // f now contains the files in the folder "tifs"
def theKey =""
def relatedFiles = [:]

f.list().each {
    filename ->
    def matchit = filename=~/(.*)\.[0-9][0-9][0-9]\.tif$/ ;

    if (matchit )

    {

        theKey = matchit[0][1]

        printf("adding key %s val %s\n", theKey,filename)
        if (! relatedFiles.containsKey(theKey)) {
            println("Adding key $theKey");

Emacs lisp bulletin board

Andreas Röhler announced Lisp Bill Board in emacs help user list.

Emacs Lisp Bill Board still isn't in the shape qualifying for Βeta, principle should be visible nonetheless.

I think his intent is to capture goodies/examples off the list.

Syndicate content