Using JsRender to create SOAP Envelopes

I am working on a small query tool that will be used to make AJAX calls against SharePoint’s Enterprise Search Query Web Service. Previously, I created the SOAP messages by appending a gigantic series of strings together.

In this iteration, I wanted to use JsRender (my template engine of choice right now and the successor to jQuery templates). Continue reading

Using slices in Golang

I started helping my brother with some GO projects. One really interesting concept in Go are slices… which make working with arrays easier.

At anytime you can “chop” out interesting portions of a slice to use using [start:finish].

There is the special append keyword to add things onto the end of the slice dynamically (as opposed to using the make keyword to declare it up front).

And there is a range keyword to mimic how foreach works in a higher level language.

package main
 
import (
    "fmt"
)

func PrintSliceRange(slice []string) {
    fmt.Printf("Slice length = %d\r\n", len(slice))
    for _, s := range slice {
        fmt.Printf("%s\r\n", s)
    }
}

func PrintSlice(slice []string) {
    fmt.Printf("Slice length = %d\r\n", len(slice))
    for i := 0; i < len(slice); i++ {
        fmt.Printf("[%d] := %s\r\n", i, slice[i])
    }
}

func main() {
    var slice []string
    slice = append(slice, "alpha")
    slice = append(slice, "bravo")
    slice = append(slice, "charlie")
    slice = append(slice, "delta")
    slice = append(slice, "echo")
    fmt.Println(slice)
    /* prints out:
    [alpha bravo charlie delta echo]
    */

    fmt.Println(slice[1:3])
    /* prints out:
    [bravo charlie]
    */

    fmt.Println(slice[3:])
    /* prints out:
    [delta echo]
    */

    PrintSlice(slice)
    /* prints out:
    Slice length = 5
    [0] := alpha
    [1] := bravo
    [2] := charlie
    [3] := delta
    [4] := echo
    */

    PrintSliceRange(slice)
    /* prints out:
    Slice length = 5
    alpha
    bravo
    charlie
    delta
    echo
    */

}

If you want to learn more, definitely check out the Golang Book’s chapter on slices.

Custom Debug JsRender tag

I’ve been learning a lot about JsRender and Knockout.js after finding Ryan’s answer on StackOverflow. I’ve created a couple of templates and started to use the {{for}}{{/for}} tag.

I was having trouble figuring out how to access the parent object’s data from within the for loop. After reading John Papa’s awesome posts, Using JsRender with JavaScript and HTML and Advanced JsRender Templating Features I came up with a quick custom “Debug” tag to help me understand.

Continue reading

Adding minified javascript/css files to ClearCase

I had an issue trying to add some minified JavaScript files to ClearCase.

Error adding '[file]' to source control.
Created branch "dev" from "[file]" version "\main\0".
Type manager "text_file_delta" failed create_version operation.

It looks like files that have over 8000 characters on a single row are unable to be added to version control using normal methods.

Thankfully, I was able to find a solution here:

cleartool mkelem -eltype compressed_file jquery-1.2.6.min.js
cleartool ci -nc jquery-1.2.6.min.js

Adding the file to clearcase as a “compressed file” means it doesn’t try to do a file delta!