Hello

Brad Dominy


Archive for 2008

  1. January
  2. February
  3. March
  4. April
  5. May
  6. June 1 entry
  7. July
  8. August
  9. September
  10. October 2 entries
  11. November
  12. December 1 entry

Showing 2 entries for October, 2008

iChat Stock Ticker

A fun little script that puts a scrolling stock ticker in your iChat status.


Copy and paste into AppleScript Editor if you want to try it out.

set stockList to {"^DJI", "^IXIC", "AAPL", "AKAM", "TIVO", "SIRI", "AIG", "MSFT", "STEC", "F", "ESLR", "GME", "UAUA", "BAC", "WFC"}
set upCh to "▲"
set dnCh to "▼"

repeat
set m to ""
repeat with daSymbol in stockList

    -- fetch quote page
    set q to do shell script "curl \"http://www.google.com/finance/info?client=ig&q=" & daSymbol & "\" -o /tmp/temp.html ; cat /tmp/temp.html"

    set pq to parse_quote(q)

    set m to m & _t of pq & " " & _l_cur of pq & " "
    set c to _c of pq as number

    if c < 0 then
        set m to m & dnCh
    else if c > 0 then
        set m to m & upCh
    else
        set m to m & "-"
    end if
    set m to m & " " & c & " ( " & _cp of pq & "% )       "
end repeat

set i to 0
set l to length of m

tell application "iChat" --to 
    repeat
        set i to i + 1

        set n to text i thru -1 of m

        if i > 1 then set n to n & text 1 thru (i - 1) of m

        if i ≥ l then
            set i to 0
            exit repeat
        end if

        set the status message to n
        delay 0.1
    end repeat
end tell
end repeat

on parse_quote(q)

set r to {} as record

set li to get every paragraph of q
repeat with thisLine in li

    set o1 to offset of ":" in thisLine

    if o1 > 0 then
        --log clean(thisLine)

        set k to clean(text 1 thru (o1 - 1) of thisLine)
        set v to clean(text (o1 + 1) thru -1 of thisLine)

        if k is "id" then
            set r to r & {_id:v}
        else if k is "t" then
            set r to r & {_t:v}
        else if k is "e" then
            set r to r & {_e:v}
        else if k is "l" then
            set r to r & {_l:v}
        else if k is "l_cur" then
            set r to r & {_l_cur:v}
        else if k is "ltt" then
            set r to r & {_ltt:v}
        else if k is "lt" then
            set r to r & {_lt:v}
        else if k is "c" then
            set r to r & {_c:v}
        else if k is "cp" then
            set r to r & {_cp:v}
        else if k is "ccol" then
            set r to r & {_ccol:v}
        end if
    end if

end repeat
return r
end parse_quote

on clean(t)

set out to ""

if length of t > 0 then
    repeat with i from 1 to length of t
        set ch to character i of t
        if ch is "\"" then

        else
            set out to out & ch
        end if
    end repeat
end if

if character 1 of out is "," then set out to text 2 thru -1 of out

return trim(out)
end clean

on trim(someText)

if length of someText > 1 then
    repeat until someText does not start with " "
        set someText to text 2 thru -1 of someText
    end repeat

    repeat until someText does not end with " "
        set someText to text 1 thru -2 of someText
    end repeat
end if
return someText
end trim

Google Onebox Employee Search

Our internal website uses a Google mini for searching. One of the features of the box is the ability to create onebox modules to return specialized results. The technology is based upon XSLT and XML, so the first part was to create a php script that took in a search string and then did a LDAP lookup matching against name, email, phone, and other fields. Any matches are returned as an XML set.


All names and personal info in the above images have been changed to protect the innocent

The second part uses XSLT to transform those results into HTML. We didn't want to clutter up the page with too many results, so I also wrote some javascript code that would hide and show additional results if more than three results were returned. If only one result is returned, we present a full set of information and the employee's image.


About me

Brad Dominy

Years

2011

2010

2009

2008

2007

2006

2005

2003