Skip to content

Instantly share code, notes, and snippets.

View ensean's full-sized avatar
🌎

ensean

🌎
  • Guangzhou, China
View GitHub Profile
@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 / 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):
@ensean
ensean / change-s3-content-type.py
Created August 25, 2023 05:19
change-s3-content-type
import json
import urllib.parse
import boto3
print('Loading function')
s3 = boto3.client('s3')
def lambda_handler(event, context):
@ensean
ensean / cff.js
Created July 10, 2023 07:01
cloudfront function for request auth
var crypto = require('crypto');
//Update with your own key.
var magic_key = "Set_at_your_wish";
// default validation is 12 hours, update it when necessary
var time_delta = 12 * 3600;
//Response when token ts does not match.
var response403 = {
@ensean
ensean / fakelog.py
Last active July 28, 2023 02:28
log generator
import json
import datetime
import random
from datetime import timedelta
import time
i=0
def getlatlon():
a=["-73.98174286,40.71915817", "-73.98508453, 40.74716568", "-73.97333527,40.76407242", "-73.99310303,40.75263214",
"-73.98229218,40.75133133", "-73.96527863,40.80104065", "-73.97010803,40.75979996", "-73.99373627,40.74176025", "-73.98544312,40.73571014",