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 / enumAttributes.py
Created March 9, 2021 01:34
Attributes pynamodb enum
from pynamodb_attributes import UnicodeEnumAttribute
from pynamodb.models import Model
from enum import Enum
class ShippingType(Enum):
delivery = 'DELIVERY'
pickUp = 'PICKUP'
class PynamoClass(Model):
shippingType = UnicodeEnumAttribute(ShippingType, null=True) # enum shipping type
@thanakijwanavit
thanakijwanavit / jsonSchemaYaml.py
Created February 23, 2021 16:36
convert json-dataclass to json schema yaml for use in validation
from dataclasses_json import dataclass_json, Undefined, CatchAll
from dataclasses_jsonschema import JsonSchemaMixin
import yaml
@dataclass_json(undefined=Undefined.INCLUDE)
@dataclass
class Product(JsonSchemaMixin):
iprcode: int
cprcode: int
@thanakijwanavit
thanakijwanavit / allowedMethodSettings.yaml
Created February 20, 2021 23:18
methodSettings in api gateway
- /deploymentId,
- /description,
- /cacheClusterEnabled,
- /cacheClusterSize,
- /clientCertificateId,
- /accessLogSettings,
- /accessLogSettings/destinationArn,
- /accessLogSettings/format,
- /{resourcePath}/{httpMethod}/metrics/enabled,
- /{resourcePath}/{httpMethod}/logging/data Trace,
@thanakijwanavit
thanakijwanavit / user.yaml
Last active March 10, 2021 00:40
squirrelSchemas
$schema: http://json-schema.org/schema#
properties:
id:
type: string
description: f42dde0a-8741-48f4-b535-9baeb3bea170
given_name:
type: string
description: Joe
middle_name:
type: string
@thanakijwanavit
thanakijwanavit / dictToYaml.py
Last active February 16, 2021 00:52
convert dict to yaml and vise versa in python
import yaml
print(yaml.dump({'hello':'world',
'stacked': {'hello1':'world1'}}))
@thanakijwanavit
thanakijwanavit / installStandardLibs.sh
Last active April 20, 2021 08:44
standard requirements for development in python 3.8
pip install -r https://gist.github.com/thanakijwanavit/cc1c456b62315823acdfe6352004e0fc/raw/requirements.txt
@thanakijwanavit
thanakijwanavit / on-setup.sh
Last active February 8, 2021 23:06
sagemaker python38
name="python38"
version="3.8"
# 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
####timestamp
datetime.now().timestamp()
### datestamp
dt = datetime.combine(date.today(), datetime.min.time())
dt.timestamp()
@thanakijwanavit
thanakijwanavit / changeMimeType.sh
Created January 29, 2021 06:30
changeMimeType
aws s3 cp s3://villa-remove-bg-small-output/ s3://villa-remove-bg-small-output/ --recursive --content-t
ype="image/png" --no-guess-mime-type --metadata-directive="REPLACE"
@thanakijwanavit
thanakijwanavit / Product.py
Last active January 26, 2021 03:55
productSchemaFor villaMasterSchema
from dataclasses_json import dataclass_json, Undefined, CatchAll
from dataclasses_jsonschema import JsonSchemaMixin
from dataclasses import dataclass
from typing import List
@dataclass_json(undefined=Undefined.INCLUDE)
@dataclass
class Product(JsonSchemaMixin):
iprcode: int