This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for $doc in //Document | |
let $datestr := $doc/@time | |
let $datearr := tokenize($datestr, '/') | |
let $year := $datearr[3] | |
let $month := format-number(xs:int($datearr[2]), '#00') | |
let $day := format-number(xs:int($datearr[1]), '#00') | |
let $dateisostr := concat($year, '-', $month, '-', $day) | |
where $dateisostr > '2010-06-01' and $dateisostr < '2011-01-01' | |
(: | |
let $date := xs:date($dateisostr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Documents> | |
<Document id="1" time="5/2/2010"/> | |
<Document id="2" time="4/8/2011"/> | |
<Document id="3" time="6/9/2010"/> | |
<Document id="4" time="8/10/2010"/> | |
</Documents> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Document id="3" time="6/9/2010"/> | |
<Document id="4" time="8/10/2010"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd d:\var\projects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for $doc in //Document | |
let $datestr := $doc/@time | |
let $datearr := tokenize($datestr, '/') | |
let $year := $datearr[3] | |
let $month := format-number(xs:int($datearr[2]), '#00') | |
let $day := format-number(xs:int($datearr[1]), '#00') | |
let $dateisostr := concat($year, '-', $month, '-', $day) | |
where $dateisostr > '2010-06-01' and $dateisostr < '2011-01-01' | |
(: | |
let $date := xs:date($dateisostr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Documents> | |
<Document id="1" time="5/2/2010"> | |
</Document> | |
<Document id="2" time="4/8/2011"> | |
</Document> | |
<Document id="3" time="6/9/2010"> | |
</Document> | |
<Document id="4" time="8/10/2010"> | |
</Document> | |
</Documents> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def versioned_bucket_lister(bucket, prefix='', delimiter='', | |
key_marker='', version_id_marker='', headers=None): | |
""" | |
A generator function for listing versions in a bucket. | |
""" | |
more_results = True | |
k = None | |
while more_results: | |
rs = bucket.get_all_versions(prefix=prefix, key_marker=key_marker, | |
version_id_marker=version_id_marker, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_age_in_minutes(rec_time, pub_time): | |
""" | |
pub_time .. string with datetime in ISO 8601 format. Time, when is the feed published (mostly current time). | |
rec_time .. string with datetime in ISO 8601 format. Time, when record was created. | |
sample ISO string: 2011-10-25T13:55:42.123Z | |
return .. integer with duration between pub_time and rec_time expressed in minutes | |
""" | |
#parsing pub_time to datetime structure. Ignoring timezone and fractions of seconds | |
pub_t = datetime.datetime.strptime(pub_time[:19],"%Y-%m-%dT%H:%M:%S") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" A study, how to create plac annotated command line script from bare function | |
preserving original function intact. | |
This is sometime needed, when the same function is used for call e.g. by a celery, | |
and for manual testing it is handy to have it in command line version. | |
Usually, the code (producing only annotated command line tool) looks like:: | |
import plac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Usage: | |
csv2sql.py [--table <tablename>] <csvfile> | |
Options: | |
--table <tablename> Name of table in database to import into [default: mytable] | |
Convert csv file with iperf data into sql script for importing | |
those data into MySQL database. | |
""" |
OlderNewer