Skip to content

Instantly share code, notes, and snippets.

View VioletVivirand's full-sized avatar
👻
Always searching for the next job 😜

Chung-Ping Huang VioletVivirand

👻
Always searching for the next job 😜
  • Chunghwa Telecom
  • Kaohsiung, Taiwan
  • 04:02 (UTC +08:00)
View GitHub Profile
@VioletVivirand
VioletVivirand / KIRO.md
Last active December 23, 2025 06:02
Video loss measurement (Generate by Kiro (kiro.dev))

I'm rendering a video clip with different presets, one if H.264 and another one is H.265. If I pick a frame from each outputs at the same time code, do you know any algorithm that can calculate the loss of the outputs from source?

Yes, there are several algorithms to measure video quality loss between your source and encoded outputs. Here are the most common ones:

Standard Metrics

PSNR (Peak Signal-to-Noise Ratio)

  • Most widely used
  • Measures pixel-level differences
  • Higher values = better quality
@VioletVivirand
VioletVivirand / aws-events-content-click-show-mode.js
Last active December 8, 2025 04:51
Usage: 1. Open AWS Events Content Page (https://aws.amazon.com/events/events-content/), 2. Open browser's developer tool and switch to console, 3. Paste the code and execute.
(function clickShowMoreUntilDone() {
function findButtonByText() {
// use CSS to grab all buttons, then filter by text (keeps selector usage)
const allButtons = Array.from(document.querySelectorAll('button'));
// prefer buttons inside <main> (if exists)
const main = document.querySelector('main') || document.body;
const candidates = allButtons.filter(b => main.contains(b));
const list = candidates.length ? candidates : allButtons;
return list.find(b => /\bshow\s+\d+\s+more\b/i.test(b.textContent.trim())) || null;
}
@VioletVivirand
VioletVivirand / mount-s3-on-startup-with-mountpoint-s3.md
Last active June 10, 2025 15:41
Mount S3 Bucket on Startup with Mountpoint for Amazon S3
@VioletVivirand
VioletVivirand / extract_exif_from_image.py
Last active August 26, 2025 08:57
Extract EXIF from image in Python
from PIL import Image
with Image.open(image_path) as img:
img.load()
# #1 Read raw info
print(img.info)
print(img.info.keys())
print(img.info['exif'])
@VioletVivirand
VioletVivirand / decode_comfyui_workflow_into_json.py
Last active February 13, 2025 08:11
Decode ComfyUI workflow into JSON (Provided by Claude 3.5 Sonnet v2)
from PIL import Image
import json
def extract_workflow_from_png(image_path):
with Image.open(image_path) as img:
# Get all text chunks
for chunk in img.text.items():
if chunk[0] == "workflow":
# Parse the JSON data
workflow_data = json.loads(chunk[1])
@VioletVivirand
VioletVivirand / main.py
Last active October 8, 2024 11:49
Get multiple files from S3 at a time into a single Pandas DataFrame with AWS SDK for Pandas (awswrangler)
import awswrangler as wr
# Read multiple JSONs
# Paths are: s3://<bucket>/yyyy/mm/dd/filename.json
# Ref: https://aws-sdk-pandas.readthedocs.io/en/stable/tutorials/003%20-%20Amazon%20S3.html#2.3.2-Reading-JSON-by-prefix
df = wr.s3.read_json(f"s3://<bucket>/prefix/", lines=True).reset_index(drop=True)
@VioletVivirand
VioletVivirand / invoke-with-an-image.py
Created July 12, 2024 02:50
Invoke Amazon Bedrock Claude 3 with an image in message block
# Use the native inference API to send a text message to Anthropic Claude.
import boto3
import json
import base64
import httpx
from botocore.exceptions import ClientError
# Create a Bedrock Runtime client in the AWS Region of your choice.
@VioletVivirand
VioletVivirand / index-hlsjs.html
Last active April 1, 2024 02:44
hls.js Demo Page
<html>
<head>
<title>Hls.js demo - basic usage</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.1/dist/hls.min.js"></script>
<center>
<h1>Hls.js demo - basic usage</h1>
<video height="600" id="video" controls="" disableremoteplayback=""><source type="video/mp4"></video>
@VioletVivirand
VioletVivirand / download_gists.sh
Created March 8, 2024 05:46
A Bash script to download files of a Gist answered by Gemini model
gist_id="YOUR_GIST_ID" # Replace with the actual Gist ID
download_path="." # Specify the download directory (optional)
# Get Gist information as JSON
gist_info=$(curl -s "https://api.github.com/gists/$gist_id")
# Extract file URLs using jq
file_urls=$(echo "$gist_info" | jq -r '.files[].raw_url')
I keep losing my keys. How can I keep track of them?