Skip to content

Instantly share code, notes, and snippets.

View ensean's full-sized avatar
🌎

ensean

🌎
  • Guangzhou, China
View GitHub Profile
@ensean
ensean / nosdk_sendmail_http.sh
Created March 21, 2025 02:16
send email vi ses http v2 api, sigv4 implemented via openssl
#!/bin/bash
set -x
# Script to send email via AWS SES using SigV4 authentication and curl
# Usage: ./send_ses_email.sh [from_email] [to_email] [subject] [message]
# Check if required parameters are provided
if [ "$#" -lt 4 ]; then
echo "Usage: $0 from_email to_email subject message"
echo "Example: $0 [email protected] [email protected] \"Test Subject\" \"This is a test message\""
exit 1
@ensean
ensean / send_ses_mail_smpt.sh
Last active March 21, 2025 02:15
send email via ses smtp endpoint
#!/bin/bash
#
# Script to send emails via AWS SES SMTP endpoint using curl
# Usage: ./send-ses-email.sh -f [email protected] -t [email protected] -s "Subject" -b "Body text" [-a attachment.pdf]
# Default AWS SES SMTP settings
AWS_REGION="us-east-1"
SES_SMTP_HOST="email-smtp.us-east-1.amazonaws.com"
SES_SMTP_PORT="587"
SES_SMTP_USERNAME=""
@ensean
ensean / lambda_handler.py
Created December 30, 2024 05:38
bedrock for comments analysis
import json
import base64
import boto3
import os
tools = [
{
"toolSpec": {
"name": "analysis_product_review",
"description": "Analysis the product reviews, determine its category, sentiment.",
@ensean
ensean / al2023-docker.sh
Last active November 6, 2024 06:29
docker runtime on al2023
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose version
@ensean
ensean / shell.sh
Last active May 18, 2024 06:48
Amazon Linux 2023 pg_repack
# Amazon Linux 2023
# pgsql 15
sudo yum install readline-devel lz4-devel postgresql15-static postgresql15-server-devel -y
sudo yum groupinstall "Development Tools" -y
wget --no-check-certificate 'https://api.pgxn.org/dist/pg_repack/1.4.8/pg_repack-1.4.8.zip'
unzip pg_repack-1.4.8.zip
cd pg_repack-1.4.8
make
@ensean
ensean / stmp-465-ec2.py
Created April 28, 2024 03:38
python-smtp-gmail-from-ec2.py
import smtplib, ssl
port = 465 # For SSL
smtp_server = "smtp.gmail.com"
sender_email = "[email protected]" # Enter your address
receiver_email = "[email protected]" # Enter receiver address
password = input("Type your password and press enter: ")
message = """\
Subject: Hi there
@ensean
ensean / s3-deny-delete.json
Created April 24, 2024 08:53
iam policy for s3
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
},
{
@ensean
ensean / aos_write.py
Created April 23, 2024 14:18
AOS-anomaly-detection
import sys
from opensearchpy import OpenSearch, helpers
host = 'vpc-xxxx-cyz5i7xdfs3dffsdgerwerw.ap-northeast-1.es.amazonaws.com'
port = 443
auth = ('admin', 'password?') # For testing only. Don't store credentials in code.
# Create the client with SSL/TLS enabled, but hostname verification disabled.
client = OpenSearch(
@ensean
ensean / demo-connect.js
Created April 10, 2024 03:36
node connect to memorydb for redis
import { Cluster } from "ioredis";
const host = "clustercfg.test.xxxxxx.memorydb.ap-northeast-1.amazonaws.com";
const port = 6379;
export const redis = new Cluster([{ host, port }], {
dnsLookup: (address, callback) => callback(null, address),
redisOptions: {
tls: {},
},
import json
import sagemaker
import boto3
from sagemaker.huggingface import HuggingFaceModel, get_huggingface_llm_image_uri
try:
role = sagemaker.get_execution_role()
except ValueError:
iam = boto3.client('iam')
role = iam.get_role(RoleName='sagemaker_execution_role')['Role']['Arn']