Skip to content

Instantly share code, notes, and snippets.

View cheeyeo's full-sized avatar
💭
Researching on use of transformers in computer vision

Chee Yeo cheeyeo

💭
Researching on use of transformers in computer vision
View GitHub Profile
@cheeyeo
cheeyeo / test.py
Created December 26, 2025 00:26
Calling Cognito Token endpoint
token_url="https://myapp.auth.us-east-1.amazoncognito.com/oauth2/token"
message = bytes(f"{client_id}:{client_secret}",'utf-8')
secret_hash = base64.b64encode(message).decode()
payload = {
"grant_type": 'authorization_code',
"client_id": client_id,
"code": code,
"redirect_uri": redirect_uri
}
headers = {"Content-Type": "application/x-www-form-urlencoded",
@cheeyeo
cheeyeo / conftest.py
Last active December 26, 2025 00:04
Example of pytest and moto for testing FastAPI application
import os
from typing import Any
import pytest
import requests
from fastapi.testclient import TestClient
import boto3
from sqlmodel import Session, SQLModel, create_engine
from sqlalchemy import delete
from moto import mock_aws
from dotenv import dotenv_values
@cheeyeo
cheeyeo / agent_example.py
Created November 26, 2025 20:42
Example of using session and memory for agent in Gemini
import os
import asyncio
from google import genai
from mem0 import Memory
from mcp_client import MCPClient
system_prompt_v2 = """
You are a helpful AI assistant. Answer the question based on the query and memories.
@cheeyeo
cheeyeo / README.md
Last active October 25, 2025 20:12
Updated Step Function definition that uses JSONata variables and functions to perform data validations rather than lambdas
@cheeyeo
cheeyeo / check_age_range_lambda.py
Created October 21, 2025 11:38
Example of a state machine in AWS using step functions
import datetime
import json
def lambda_handler(event, context):
registration_info = event['registration_info']
print(registration_info)
dob = registration_info['child']['dateOfBirth']
today = datetime.date.today()
@cheeyeo
cheeyeo / cloudfront.py
Last active October 19, 2025 11:58
Example of using boto3 CloudFrontSigner
import datetime
import json
import base64
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import padding
from botocore.signers import CloudFrontSigner
@cheeyeo
cheeyeo / test.md
Created August 18, 2025 18:38
Uusing ```diff``` in github markdown
--- board/__init__.py
+++ board/__init__.py
@@ -18,7 +18,7 @@
 
 
 def get_locale():
-    return request.accept_languages.best_match(['en', 'es'])
+    return request.accept_languages.best_match(["en", "es"])
 
@cheeyeo
cheeyeo / 1-pull-request.png
Created August 18, 2025 18:26 — forked from managedkaos/1-pull-request.png
A GitHub Actions workflow that displays the Terraform plan in the workflow summary...
1-pull-request.png
@cheeyeo
cheeyeo / deploy,py
Last active May 1, 2025 15:47
Python script to upload Triton model to Sagemaker
#!/usr/bin/env python
import os
import json
import time
import boto3
import sagemaker
if __name__ == "__main__":
@cheeyeo
cheeyeo / output.sh
Created April 25, 2025 16:18
Example Triton server response in terminal running on localhost
root@8423ac911e05:/opt/tritonserver# tritonserver --model-repository=model_repository
I0425 10:08:43.682014 1236 pinned_memory_manager.cc:241] Pinned memory pool is created at '0x77fa88000000' with size 268435456
I0425 10:08:43.682247 1236 cuda_memory_manager.cc:107] CUDA memory pool is created on device 0 with size 67108864
I0425 10:08:43.684950 1236 model_lifecycle.cc:461] loading: detection_postprocessing:1
W0425 10:08:43.685049 1236 model_lifecycle.cc:108] ignore version directory 'hf_cache' which fails to convert to integral number
I0425 10:08:43.685063 1236 model_lifecycle.cc:461] loading: sam_vit:1
W0425 10:08:43.685125 1236 model_lifecycle.cc:108] ignore version directory 'hf_cache' which fails to convert to integral number
I0425 10:08:43.685138 1236 model_lifecycle.cc:461] loading: grounding_dino_tiny:1
I0425 10:08:45.251843 1236 python_be.cc:2363] TRITONBACKEND_ModelInstanceInitialize: detection_postprocessing_0 (GPU device 0)
I0425 10:08:45.654267 1236 model_lifecycle.cc:818] successfully loaded 'd