Skip to content

Instantly share code, notes, and snippets.

View thanakijwanavit's full-sized avatar

Nic Wanavit thanakijwanavit

View GitHub Profile
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
villaData
Sample SAM Template for villaData
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
inventory functions
Metadata:
AWS::ServerlessRepo::Application:
Name: inv-app
Description: for managing inventory
Author: nicWanavit
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
villa-wallet-sam
Sample SAM Template for villa-wallet-sam
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
villa-wallet-sam
Sample SAM Template for villa-wallet-sam
Metadata:
AWS::ServerlessRepo::Application:
Name: wallet-database-app
cd ./wallet-database\
&&sam build --profile villaaws\
&&sam package --profile villaaws --s3-bucket wallet-database-app --force-upload --output-template-file packaged.yaml\
&&sam publish --profile villaaws --template packaged.yaml --region ap-southeast-1
echo building wallet encryptor function
def make_negative( number ):
#return -abs(number)
#return -number if number > 0 else number
if number > 0:
return -number
else:
return number
def uploadImage(event, params):
''' create a signedurl for client to upload image to s3'''
# extract path (object key) from requester
path = event['path']
# mock key (please remove when used in lambda)
KEY = ''
PW = ''
s3 = boto3.client('s3',
aws_access_key_id = KEY,
def generate_RSA(bits=2048):
new_key = RSA.generate(bits, e=65537)
public_key = new_key.publickey().exportKey("PEM").decode()
private_key = new_key.exportKey("PEM").decode()
return private_key, public_key
@thanakijwanavit
thanakijwanavit / newKey.py
Created July 4, 2020 23:26
create a new rsa key and save it to aws secretstore
from Crypto.PublicKey import RSA
def newKey(phoneHash:str):
'''generat new rsa key and store in database'''
if len(list(PynamoSecret.query(phoneHash))) > 0 :
print('hash key exists, throwing error')
raise ValueError('secret key exists')
else:
print('there is no secret key, generating one')
class B:
def random_func(self, i, j, test=None):
print(2)
class A:
def random_func(self, i, j, test=None):
print(1)
class ModA(A):
def random_funcA(self, i, j, test=None):
super().random_func(i, j, test=test)