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 / decodeCsv.swift
Created January 9, 2022 05:49
decoding pandas generated csv in swift
import CodableCSV
extension VillaMarket{
static func getOnlineCsv()async throws ->[Item]{
let url = URL(string: "https://url/item.csv")!
let (data, _) = try await URLSession.shared.data(from: url)
let decoder = CSVDecoder{
$0.bufferingStrategy = .sequential
import json
with open('/content/drive/MyDrive/example.json', 'w') as f:
json.dump({'key':'xxx','secret':'xxx'}, f)
s3 = boto3.client('s3', aws_access_key_id='xxx', aws_secret_access_key='xxx')
@thanakijwanavit
thanakijwanavit / updateUbuntu.sh
Created August 24, 2021 18:13
ignore release info header change while updating ubuntu
sudo apt update --allow-releaseinfo-change
@thanakijwanavit
thanakijwanavit / datestampFromIso.py
Created August 24, 2021 01:46
datestamp from Iso
dt = parser.parse('2021-08-07T02:00:00.000Z')
datestamp(dt, timezone(timedelta(hours=7)))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thanakijwanavit
thanakijwanavit / signAws.py
Created July 22, 2021 12:39
sign using aws boto token
from aws_requests_auth.boto_utils import BotoAWSRequestsAuth
auth = BotoAWSRequestsAuth(aws_host='api.example.com',
aws_region='us-east-1',
aws_service='execute-api')
import requests
response = requests.post('https://api.example.com/test', json={"foo": "bar"}, auth=auth)
@thanakijwanavit
thanakijwanavit / table.yaml
Last active July 22, 2021 03:27
general table template for use by sam nested app,
#put in your TABLENAME var and use Supermodel from [nichelper](https://thanakijwanavit.github.io/nicHelper/)
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
general table tample for general use by nested app
Parameters:
TABLENAME:
@thanakijwanavit
thanakijwanavit / runningNumber.py
Created July 20, 2021 02:31
runningNumber with pynamodb
import os
KEYTABLE = os.environ.get('KEYTABLE')
# Cell
from pynamodb.models import Model
from pynamodb.attributes import UnicodeAttribute, NumberAttribute
from awsSchema.apigateway import Event, Response
from datetime import datetime
from nicHelper.schema import validateUrl
from jsonschema import ValidationError
name: Remove old artifacts
on: push
jobs:
remove-old-artifacts:
runs-on: ubuntu-latest
timeout-minutes: 10
steps: