upload a file to crx via sling and webdav

###############################################################################################
# some variables and aliases
secret="admin:admin"
host="crunky"
port="7402"
path="content/test_2009_12_18"
base="http://${host}:${port}/${path}"
file="x.xml"
alias crx="curl -u ${secret}"

###############################################################################################
# make a directory to put junk in
crx -X MKCOL "${base}"

###############################################################################################
# put/get sling style
crx -F"sling:resourceType=application/xml" -F"content=@${file}" ${base}/sling_test.xml
crx http://crunky:7402/content/test_2009_12_18/sling_test.xml/content

###############################################################################################
# put/get webdav style
crx -T ${file} ${base}/webdav_test.xml
crx http://crunky:7402/content/test_2009_12_18/webdav_test.xml

Leave a Comment

pull analytics “site search terms” with google data api

I’d heard about the google data api, but up until recently hadn’t found much practical use for it.

Suddenly I needed to pull back the top search terms for a site monitored by google analytics. The default view only shows 500 at a time. Granted this accounted for 30% of the “unique searches’, but I wanted to see a bit more.

Though it was sort of hard to find, I used the example script dataFeed.sh to retrieve the top 10k search terms.

The script wants you to set the variables for username/password and “PROFILE_ID” The value for this last is the id=xxxx in the url when you cruise around the analytics site.

Rather than read thru the quirky documentation as to what dimensions and metrics were available, I used the Data Feed Query Explorer to find the values instead:

feedUri="https://www.google.com/analytics/feeds/data\
?start-date=2009-08-01\
&end-date=2009-12-04\
&dimensions=ga:searchKeyword\
&metrics=ga:searchDepth,ga:searchDuration,ga:searchExits,ga:searchRefinements,ga:searchUniques,ga:searchVisits\
&sort=-ga:searchUniques\
&max-results=40000\
&ids=ga:$PROFILE_ID\
&prettyprint=true"

curl $feedUri -s --header "Authorization: GoogleLogin $googleAuth"

Despite the max-results of 40k, it looks like there is a max of 10k, which is fine.

All in all, pretty ez. Digging it all up.. sort of sucked.

Hence the write up… hope it helps some buddy!

Leave a Comment

print all tags in xml with xsl

Here is tags.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <xsl:output omit-xml-declaration="yes"/>
        <xsl:template match="*">
        <xsl:value-of select="name()"/>
        <xsl:value-of select="'
'"/>
        <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="text()"/>
</xsl:stylesheet>

Use it like this: xsltproc tags.xsl individual_files/wikipedia.split.0000* | sort | uniq -c | sort -n

For example…

Leave a Comment

bash: string to integer conversion

Bash arrays are odd, globally scoped critters which can only be indexed by integer values… but the values don’t have to be contiguous so they are sort of like hash maps…

All you need is something to convert strings to integers, for example:

_map_string_to_integer() {
	echo ${*} | od -t u1 | sed 's,[^ ]*,,;s, ,,g;' | tr -d '\n'
	echo
}

And you can use it like this:

% fun[$(_map_string_to_integer this)]="is neat"
% echo ${fun[$(_map_string_to_integer this)]}
is neat

if that is of any use to anyone….

Leave a Comment

some improvement

Heard during the Georg Carlin interview:

The famous cellist Pablo Casals was in his 90s still doing the occasional recital. Someone asked him at that time, ‘SeƱor Casals, why after all you’ve achieved and such longevity do you practice three or four hours a day?’ He said, ‘Well, I’m starting to notice some improvement.’

Leave a Comment

Older Posts »