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 / dynamodbCloudformationTemplate.yaml
Created November 18, 2020 00:59
dynamodb specifiction in cloudformation or sam
MainDatabase:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: ib_prcode
AttributeType: S
- AttributeName: needUpdate
AttributeType: S
BillingMode: PAY_PER_REQUEST
GlobalSecondaryIndexes:
class Cognito:
'''sdk to interact with cognito as a client'''
def __init__(
self,
identityPoolId,
userPoolId,
accountId,
clientId,
clientSecret,
region = 'ap-southeast-1'
@thanakijwanavit
thanakijwanavit / classWrapper.py
Created November 4, 2020 06:55
wrap function to add method to a class
#export
from functools import wraps # This convenience func preserves name and docstring
def add_method(cls):
def decorator(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
return func(self, *args, **kwargs)
setattr(cls, func.__name__, wrapper)
aws s3api \
--profile villaaws \
put-bucket-accelerate-configuration \
--bucket chatterbot-data \
--accelerate-configuration Status=Enabled
@thanakijwanavit
thanakijwanavit / pynamodbSample.ipynb
Created October 24, 2020 16:11
pynamodbSample.py
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from villaWalletDatabase.database import getMember, setMember, addMember, removeMember, test
@thanakijwanavit
thanakijwanavit / nic-opensourced-libraries.md
Last active October 20, 2020 08:01
opensourced sdk/utility for nic

Opensourced work

summaries

summarypip packages

Chat

linesdk push data for line and slack

Aws

@thanakijwanavit
thanakijwanavit / getExceptionString.py
Last active October 13, 2020 01:09
log with debug information python
import traceback
traceback.format_exc()
@thanakijwanavit
thanakijwanavit / setattr.py
Created October 7, 2020 14:50
set attr to a defined class
setattr(cls, func.__name__, wrapper)
@thanakijwanavit
thanakijwanavit / addEnv.sh
Last active May 2, 2021 16:57
jupyterlab config code config sagemaker
name="my-env"
version="3.7"
# Create a new conda environment for the given Python version
conda create -y -n "$name" python="$version"
# Activate the environment
source /home/ec2-user/anaconda3/bin/activate "$name"
# Create a Jupyter kernel for your new environment