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 / zipFile.sh
Created March 15, 2021 06:02
zip file with bash
zip -9r CP0069.zip CP0069
@thanakijwanavit
thanakijwanavit / beartypeSample.py
Last active March 17, 2021 15:44
sample type checking python and enum bear
from beartype import beartype
from typing import Optional, List
from enum import Enum
class Animal(Enum):
fish=1
cat=2
@beartype
def testBeartype(i:int, s:str, a:Optional[Animal]=None):
@thanakijwanavit
thanakijwanavit / enumSample.py
Created March 14, 2021 15:53
enum example python
from enum import Enum
class Animal(Enum):
cat=1
dog=2
def testEnum(te:Animal):
animal:Animal = Animal[te]
print(animal.name)
print(animal.value)
testEnum('cat')
openapi: '3.0.0'
info:
title: SquirrelVL API
description: >
SquirrelVL API is a collection of endpoints that support the Squirrel
VanLife application.
version: '0.0.1'
servers:
- url: https://api.nicesquirrel.com
description: Production API server
<escape>:%!python -mjson.tool
@thanakijwanavit
thanakijwanavit / pynamoDbSavingOverride.py
Last active March 10, 2021 09:24
pynamo saving override
class Order2(Model):
class Meta:
table_name = ORDER_TABLE
region = 'ap-southeast-1'
dax_read_endpoints = ['longtermcluster.vuu7lr.clustercfg.dax.apse1.cache.amazonaws.com:8111']
dax_write_endpoints = ['longtermcluster.vuu7lr.clustercfg.dax.apse1.cache.amazonaws.com:8111']
## keys
ownerId=UnicodeAttribute()
basketId=UnicodeAttribute()
@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