Skip to content

Instantly share code, notes, and snippets.

@sheep-snow
sheep-snow / upstash_cost_efficieant.md
Last active December 26, 2025 05:54
skyshare-cost-efficient-memos

Upstash Redis読み取り削減の対処案

現状分析

現在の実装では、Cloudflare Workers (workers/src/function.prod.ts) が以下の2つのエンドポイントでUpstash Redisに直接アクセスしています:

  • GET /page/{id} - 個別ページのOGP取得
  • GET /user/{handle} - ユーザーのページID一覧取得(redis.scan()を使用)

利用が増加し、Upstash Redisの無料利用枠では収まらなくなってきました。

@sheep-snow
sheep-snow / ChronicoUserManual-en.md
Last active September 13, 2025 18:41
Chronico Docs

Chronico User Manual

What is Chronico?

Chronico is a service to protect your creative works. By embedding an invisible "digital watermark" into your images and posting them to Bluesky, you can prove the authenticity of your creations.

🚀 Getting Started

Target Audience: Creators

I want to use the trustmark package with AWS Lambda. However, I need the CPU version, not the CUDA version.

Succeeded pattern is below.

$ cp cpu_ubuntu.Dockerfile Dockerfile
$ docker build -t trustmark_lambda_sample .
....
 => [stage-1 8/8] COPY lambda/ /function/lambda/                                                                        0.1s
 => exporting to image                                                                                                 27.2s
@sheep-snow
sheep-snow / result.csv
Last active January 14, 2025 04:20
clipstudio output filesize comparison each formats
name 形式 色深度 サイズ 色数 色サイズ比 最大サイズ比
Bitmap(RGB) Bitmap RGB 5669654 16777216 2.9591 100.0%
PNG(RGB) PNG RGB 699634 16777216 23.9800 12.3%
WebP(RGB) WebP RGB 355712 16777216 47.1652 6.3%
JPG(RGB) JPG RGB 170070 16777216 98.6489 3.0%
Bitmap(グレースケール) Bitmap グレースケール 1892934 256 0.0001 33.4%
PNG(グレースケール) PNG グレースケール 295188 256 0.0009 5.2%
WebP(グレースケール) WebP グレースケール 204898 256 0.0012 3.6%
JPG(グレースケール) JPG グレースケール 134912 256 0.0019 2.4%
BMP(モノクロ) BMP モノクロ 238782 2 0.0000 4.2%
@sheep-snow
sheep-snow / sRGB-TrueColor.sh
Created January 13, 2025 17:41
Image Magick identify execution results
$ magick identify -verbose sample.webp
Image:
Filename: sample.webp
Permissions: rw-rw-rw-
Format: WEBP (WebP Image Format)
Mime type: image/webp
Class: DirectClass
Geometry: 1600x1920+0+0
Units: Undefined
Colorspace: sRGB
@sheep-snow
sheep-snow / Dockerfile
Last active March 6, 2025 05:43
using-uv-with-python-lambda-image-on-ecr-public-repo
# AWS Lambda 関数の公式コンテナイメージ https://gallery.ecr.aws/lambda/python で
# uv https://docs.astral.sh/uv/ を使って python パッケージ管理と実行を可能にする最小限の例
FROM public.ecr.aws/lambda/python:3.12
# uv を公式イメージからCOPYする方法でインストールする
# https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
ENV PATH="/app/.venv/bin:$PATH"
# AWS Lambda は書込可能なディレクトリが `/tmp` 配下だけなので uv の cache も同ディレクトリ配下を使うように変更する
@sheep-snow
sheep-snow / Dockerfile
Last active November 30, 2022 15:50
awslambda-python-docker-baseimage
FROM amazon/aws-lambda-python:3.9
COPY . ${LAMBDA_TASK_ROOT}
ENV PYTHONUTF8=1
ENV APP_NAME=${APP_NAME:-SOME_APP_NAME}
# Install AWS Cli
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
import logging
from logging import StreamHandler
logger = logging.getLogger("sample")
_fmtr = logging.Formatter("%(asctime)s %(levelname)s [%(name)s] %(message)s")
_handler = StreamHandler()
_handler.setFormatter(_fmtr)
logger.addHandler(_handler)
logger.setLevel("DEBUG")