Skip to content

Instantly share code, notes, and snippets.

View ensean's full-sized avatar
🏔️

ensean

🏔️
  • Guangzhou, China
View GitHub Profile
@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 = "sender@gmail.com" # Enter your address
receiver_email = "recv@gmail.com" # 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']
@ensean
ensean / getSignInToken.py
Last active May 13, 2024 02:17
getSignInToken
import boto3
import requests
import json
import urllib
BASE_URL = 'https://signin.aws.amazon.com/federation'
TARGET_URL = 'https://console.aws.amazon.com/'
def get_fedration_token():
client = boto3.client('sts')
fid = client.get_federation_token(
@ensean
ensean / acu_master.py
Created March 10, 2024 15:26
lambda modify aurora serverless acu
import json
import boto3
client = boto3.client('rds')
def modify_acu(cluster_id, min_acu, max_acu):
resp = client.modify_db_cluster(
DBClusterIdentifier=cluster_id,
ApplyImmediately=True,
ServerlessV2ScalingConfiguration={
@ensean
ensean / dd_dag.py
Created February 4, 2024 05:46
dingtalk demo for mwaa
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@ensean
ensean / extras.py
Created December 14, 2023 15:48 — forked from harfqaf/extras.py
API Extras example for stable-diffusion-webui
#! /usr/bin/python3
"""
extras.py: Upscale PNG images in DIR_IN into DIR_OUT.
Usage: Set API_URL, DIR_IN, and DIR_OUT. Then run ./extras.py
For API documentation see: http://localhost:7860/docs#/
"""
import sys
import io
import os