Skip to content

Instantly share code, notes, and snippets.

View thanakijwanavit's full-sized avatar
🎯
Focusing

Nic Wanavit thanakijwanavit

🎯
Focusing
View GitHub Profile
@thanakijwanavit
thanakijwanavit / dfToGzipJson.py
Created March 25, 2021 00:28
save df to gzip json
onlineDf.to_json(path ,orient='split',compression='gzip')
@thanakijwanavit
thanakijwanavit / saveS3PublicRead.py
Last active March 25, 2021 06:12
save to s3 with public read and gzip
from s3bz.s3bz import S3, ExtraArgs
S3.saveFile(key=key,path=path,bucket=bucket,
ExtraArgs = {**ExtraArgs.jpeg, **ExtraArgs.publicRead })
@thanakijwanavit
thanakijwanavit / buildAllLayers.sh
Created March 23, 2021 16:25
build all layers in the repo
# list all folders
layerList=$(find -name 'layer')
curDir=$(pwd)
echo executing $layerList
echo curdir is $curDir
# loop though each path
for path in $layerList
do
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thanakijwanavit
thanakijwanavit / asyncAwait.py
Created March 21, 2021 15:30
async await example in python
import requests, time, random
import asyncio
from asgiref.sync import sync_to_async
from datetime import datetime
async def post(url, body):
t0 = datetime.now()
r = await sync_to_async(requests.post)(url,json=body)
return r.json()
async def main():
@thanakijwanavit
thanakijwanavit / requests.yaml
Created March 20, 2021 11:24
api gateway schemas
body: A JSON string of the request payload.
headers: '{String containing incoming request headers}'
httpMethod: Incoming request's method name
isBase64Encoded: A boolean flag to indicate if the applicable request payload is Base64-encoded
multiValueHeaders: '{List of strings containing incoming request headers}'
multiValueQueryStringParameters: '{List of query string parameters}'
path: Path parameter
pathParameters: '{path parameters}'
queryStringParameters: '{query string parameters }'
requestContext: '{Request context, including authorizer-returned key-value pairs}'
@thanakijwanavit
thanakijwanavit / uploadS3.js
Created March 19, 2021 09:56
update to s3 using signedurl
func uploadfileAWSS3(fileuploadurl, contenttype, file): Observable<any>{
//this will be used to upload all csv files to AWS S3
const headers = new HttpHeaders({‘Content-Type’: contenttype});
const req = new HttpRequest(
‘PUT’,
fileuploadurl,
file,
{
headers: headers,
reportProgress: true, //This is required for track upload process
@thanakijwanavit
thanakijwanavit / type-checking-example.ipynb
Last active March 17, 2021 15:53
type checking example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thanakijwanavit
thanakijwanavit / 7z.sh
Created March 16, 2021 03:42
compress with 7z
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on /tmp/archive.7z $dir
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"PublicRead",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject","s3:GetObjectVersion"],
"Resource":["arn:aws:s3:::DOC-EXAMPLE-BUCKET/*"]
}