Commit a31b20f8 authored by Austin Yu's avatar Austin Yu

add mysql worknote.

parent 7aae18f8
package main
import (
"time"
"fmt"
)
// TimeIn returns the time in UTC if the name is "" or "UTC".
// It returns the local time if the name is "Local".
// Otherwise, the name is take to be a location name in
// the IANA Time Zone database, suc as "Africa/Lagos".
func TimeIn(tt time.Time, sName string) (time.Time, error) {
loc, err := time.LoadLocation(sName)
if err == nil {
tt = tt.In(loc)
}
return tt, err
}
func main() {
tNow := time.Now()
a150day := tNow.Add(150*24*time.Hour)
fmt.Println(tNow.Format("2006-01-02 3:4:5 pm"), tNow.Unix())
fmt.Println(a150day.Format("2006-01-02 3:4:5 pm"), tNow.Unix())
for _, sName := range []string{
"",
"Local",
"Asia/Pyongyang",
"Asia/Seoul",
"Asia/Tokyo",
"Asia/Shanghai",
"Australia/Brisbane",
"Australia/Sydney",
"Australia/Perth",
"America/Phoenix",
"America/Los_Angeles",
"America/Vancouver",
"America/Sao_Paulo",
} {
tt, err := TimeIn(tNow, sName)
t150, err := TimeIn(a150day, sName)
if err == nil {
// fmt.Println(tt.Location(), tt.Format("15:04"))
// fmt.Println(tt.Location(), tt.Format("2006-01-02 3:4:5 pm"))
fmt.Println(tt.Location(), tt.Format(time.RFC822), tt.Unix())
fmt.Println(tt.Location(), t150.Format(time.RFC822), t150.Unix())
} else {
fmt.Println(sName, "<time location unknown>")
}
}
}
This diff is collapsed.
## s3 url
url = "https://s3.us-east-2.amazonaws.com/ecos.aitmed.com/2rVDLVHTt7oJCdKFqAKNZx/NJzmLQADFqtTeCNbtVDb5z/CXkiLSC2Lkrf1oFpaoGFVW"
## s3 client
s3_connection = boto3.resource(
's3',
region_name = 'us-east-2',
aws_access_key_id = 'AKIA3CESR5P42U22VIIW',
aws_secret_access_key = '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'
)
## retreieve s3 object
s3_object = s3_connection.Object('ecos.aitmed.com', '2rVDLVHTt7oJCdKFqAKNZx/NJzmLQADFqtTeCNbtVDb5z/CXkiLSC2Lkrf1oFpaoGFVW')
s3_response = s3_object.get()
file = s3_response['Body'].read()
## base64 decodes
file_decode = base64.decodebytes(file)
## unzip
file_unzip = gzip.decompress(file_decode)
## show image locally
stream = io.BytesIO(file_unzip)
image=Image.open(stream)
image.show()
## aws textract client
client = boto3.client(
'textract',
region_name = 'us-east-2',
aws_access_key_id = 'AKIA3CESR5P42U22VIIW',
aws_secret_access_key = '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'
)
## send out the request
response = client.analyze_id(
DocumentPages = [
{
'Bytes': file_unzip
}
]
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment