Skip to content

Instantly share code, notes, and snippets.

View thanakijwanavit's full-sized avatar
🎯
Focusing

Nic Wanavit thanakijwanavit

🎯
Focusing
View GitHub Profile
git ls-files | xargs wc -l
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
villa-remove-bg
Sample SAM Template for villa-remove-bg
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
current qr database
What is the database?
column list?
access control?
information security?
link to customer/ owner?
hash algorithm?
running algorithm?

HatariExpense

Goals

To create a system to store reciepts with the ablility to control user accounts, store files, store summary data

Programming language

  • Python (backend)
  • Swift (app)
  • JS (web)
@thanakijwanavit
thanakijwanavit / changeCursorVim.vim
Created August 23, 2020 10:57
change cursor shape in vi mode in fish
" Change cursor shape between insert and normal mode in iTerm2.app
if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
endif
@thanakijwanavit
thanakijwanavit / uploads3.swift
Created September 2, 2020 13:11
upload to s3 with accelerated endpoint swift
// initiation in appdelegate
let east1Configuration = AWSServiceConfiguration(
region: AWSRegionType.USEast1,
credentialsProvider: credentialsProvider
)!
let largeImageConfiguration = AWSS3TransferUtilityConfiguration()
largeImageConfiguration.isAccelerateModeEnabled = true
AWSS3TransferUtility.register(with: east1Configuration,
transferUtilityConfiguration: inputImageConfiguration,
@thanakijwanavit
thanakijwanavit / removeNone.py
Created September 4, 2020 09:12
remove none from a dict
def removeNone(data):
return { k:v for k, v in data.items() if v is not None }
@thanakijwanavit
thanakijwanavit / createLambdaLayerPython38.sh
Last active September 10, 2020 16:07
creating a lambda layer package for python 3.8
#!/bin/bash
export PKG_DIR="python"
rm -rf ${PKG_DIR} && mkdir -p ${PKG_DIR}
docker run --rm -v $(pwd):/foo -w /foo lambci/lambda:build-python3.8 \
pip install -r requirements.txt --no-deps -t ${PKG_DIR}
zip -r package.zip python
@thanakijwanavit
thanakijwanavit / validateUrlOrString.py
Created September 12, 2020 10:36
validate a string url, dict or anything else
import validators
valid=validators.url('https://codespeedy.com/')
if valid==True:
print("Url is valid")
else:
print("Invalid url")
@thanakijwanavit
thanakijwanavit / pynamoGlobalSecondaryIndex.py
Last active September 15, 2020 02:05
Global secondary index for pynamodb
from pynamodb.indexes import GlobalSecondaryIndex, AllProjection
from pynamodb.attributes import NumberAttribute, BooleanAttribute
class Database(Model):
class Meta:
aws_access_key_id = ACCESS_KEY_ID
aws_secret_access_key = SECRET_ACCESS_KEY
table_name = DATABASE_TABLE_NAME
region = REGION
ib_prcode = UnicodeAttribute(hash_key=True, default = '')