Skip to content

Instantly share code, notes, and snippets.

View ensean's full-sized avatar
🏔️

ensean

🏔️
  • Guangzhou, China
View GitHub Profile
@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
Created March 27, 2024 06:56
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
@ensean
ensean / sd.txt
Created November 16, 2023 08:09
logs of sd on eks
base) [ec2-user@ip-172-16-78-199 stable-diffusion-on-eks]$ kubectl logs sdruntime-sd-on-eks-sd-webui-inference-api-6cfbc85c7d-tbsng
Defaulted container "sd-webui-inference-api" out of: sd-webui-inference-api, sd-webui-queue-agent, xray-daemon
The cache for model files in Transformers v4.22.0 has been updated. Migrating your old cache. This is a one-time only operation. You can interrupt this and resume the migration later on by calling `transformers.utils.move_cache()`.
Launching Web UI with arguments: -f --api --skip-prepare-environment --no-hashing --listen --port 8080 --xformers --ckpt v1-5-pruned-emaonly.safetensors --ckpt-dir /tmp/models/stable-diffusion --controlnet-dir /tmp/models/controlnet --lora-dir /tmp/models/lora --vae-dir /tmp/models/vae
Moving 0 files to the new cache system
0it [00:00, ?it/s]
Checkpoint in --ckpt argument not found (Possible it was moved to /opt/ml/code/models/Stable-diffusion: v1-5-pruned-emaonly.safetensors
2023-11-15 23:29:49,101 - ControlNet - INFO - ControlNet v1.1.410
Co
@ensean
ensean / lambda.py
Created August 31, 2023 16:48
lambda_auto_unzip
import logging
import zipfile
import mimetypes
from io import BytesIO
from boto3 import resource
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def upload_files(zipped, zipfile_info, destinationbucket, upload_path):