Skip to content

Instantly share code, notes, and snippets.

View thanakijwanavit's full-sized avatar
🎯
Focusing

Nic Wanavit thanakijwanavit

🎯
Focusing
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thanakijwanavit
thanakijwanavit / sentryAddBreadcrumb.py
Last active August 15, 2022 04:12
add breadcrumb to sentry
import sentry_sdk
sentry_sdk.add_breadcrumb(
category='auth',
message='Authenticated user %s' % user.email,
level='info',
data={'data':'data'}
)
@thanakijwanavit
thanakijwanavit / pynamodb_override.py
Created August 7, 2022 03:18
pynamodbOverride override init for pynamodb example
#export
from nicHelper.pynamodb import SuperModel
from pynamodb.attributes import JSONAttribute, NumberAttribute, UnicodeAttribute
class PaymentRecordTable(SuperModel):
data = JSONAttribute(null=True)
timestamp = NumberAttribute(hash_key=True)
userId = UnicodeAttribute()
def __init__(self, hash_key=None, range_key=None, _user_instantiated=True, **kwargs):
@thanakijwanavit
thanakijwanavit / setAwsEnvironmentInBoto3.py
Last active February 15, 2023 06:01
set aws environment in boto3 python
os.environ['AWS_PROFILE'] = 'tenxor'
os.environ['AWS_DEFAULT_PROFILE'] = 'tenxor'
@thanakijwanavit
thanakijwanavit / enumCodableWithDefault.swift
Created March 18, 2022 22:04
swift enum extension for making it comply with codable and default type
extension Type: Codable {
public init(from decoder: Decoder) throws {
self = try Type(rawValue: decoder.singleValueContainer().decode(RawValue.self)) ?? .unknown
}
}
@thanakijwanavit
thanakijwanavit / View+isHidden.swift
Created January 18, 2022 08:17
view hidden extension swiftui
//
// View+Extension.swift
// squirrel2 (iOS)
//
// Created by nic wanavit on 11/3/21.
//
import SwiftUI
extension View {
@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