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 / dynamodbDaxSpeed.ipynb
Last active September 23, 2020 08:03
speed test for dynamodb Dax
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thanakijwanavit
thanakijwanavit / expenseTransactionTest.py
Created September 25, 2020 03:06
expense transaction for hatari-expense-app
def helpme():
print('help')
# unit test function
def testAddTransaction(testData, expectedResponse):
result = addTransaction(testData, '')
# check if status code is the same
assert result['statusCode'] == expectedResponse['statusCode'], f"status code is incorrect, it should be {expectedResponse['statusCode']}, {result}"
# check if transaction id is the same
if result.get('transactionId'):
@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
@thanakijwanavit
thanakijwanavit / setattr.py
Created October 7, 2020 14:50
set attr to a defined class
setattr(cls, func.__name__, wrapper)
@thanakijwanavit
thanakijwanavit / getExceptionString.py
Last active October 13, 2020 01:09
log with debug information python
import traceback
traceback.format_exc()
@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

from villaWalletDatabase.database import getMember, setMember, addMember, removeMember, test
@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.
aws s3api \
--profile villaaws \
put-bucket-accelerate-configuration \
--bucket chatterbot-data \
--accelerate-configuration Status=Enabled
@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)