Skip to content

Instantly share code, notes, and snippets.

@vlcinsky
vlcinsky / test_s3_json_bucket.py
Created June 14, 2020 10:45
S3JsonBucket to dump/load data to S3 bucket. Comment to https://stackoverflow.com/a/50101751/346478
import json
import boto3
class S3JsonBucket:
def __init__(self, bucket_name):
self.bucket = boto3.resource("s3").Bucket(bucket_name)
def load(self, key):
@vlcinsky
vlcinsky / pyproject.toml
Created October 18, 2021 12:13
pyproject.toml generated by poetry v1.1.11 under python 3.10. Pytest version is obsolete (5.2 while v6.2.5 exists and works under python 3.10)
[tool.poetry]
name = "pytestver"
version = "0.1.0"
description = ""
authors = ["Jan Vlcinsky <jan.vlcinsky@tamtamresearch.com>"]
[tool.poetry.dependencies]
python = "^3.10"
[tool.poetry.dev-dependencies]
@vlcinsky
vlcinsky / pyproject.toml
Created October 8, 2020 14:29
pyproject.toml for newly created project jinjatest
[tool.poetry]
name = "jinjatest"
version = "0.1.0"
description = ""
authors = ["Jan Vlcinsky <jan.vlcinsky@tamtamresearch.com>"]
[tool.poetry.dependencies]
python = "^3.7"
[tool.poetry.dev-dependencies]
import os
def task_one():
def create_cmd_string(a, b, target):
return "echo a: %s b: %s > %s" % (a, b, target)
with open("list_of_input_filenames.txt") as f:
fnames = [line.strip() for line in f.readlines() if line]
for a in fnames:

Keybase proof

I hereby claim:

  • I am vlcinsky on github.
  • I am vlcinsky (https://keybase.io/vlcinsky) on keybase.
  • I have a public key ASCnbRr-ve9t3Vb2dPBwo8lMftVKos2jXs4Q6PlcgfZw4go

To claim this, I am signing this object:

@vlcinsky
vlcinsky / age_in_minutes.py
Created October 4, 2011 12:21
calculate_age_in_minutes explained
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")
@vlcinsky
vlcinsky / bucketlistresultset.py
Created September 18, 2011 21:13
Modified boto to overcome shortened listing of object versions in AWS S3 problem
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,
@vlcinsky
vlcinsky / my.xml
Created July 20, 2011 14:07
some xml
<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>
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)
cd d:\var\projects