Skip to content

Instantly share code, notes, and snippets.

@chilang
chilang / static-asset-caching-plan.md
Created February 6, 2026 22:45
Static Asset Caching Plan for Deployed Apps (Issue #2459)

Static Asset Caching for Deployed Apps (FastAPI + HTML Template)

Problem Statement

User-deployed apps using the data-app-html-python template serve all static assets (CSS, JS, images, fonts) through the FastAPI/Uvicorn process running on Modal. Every request -- including repeat visits for the same unchanged styles.css -- travels from browser to Cloudflare edge to Modal container to Python to filesystem and back. This creates:

  1. Unnecessary latency: Static files go through the full Python middleware stack (~10x slower than native file serving)
  2. Cold start exposure: After 15 min idle, Modal scales to zero. The next visitor waits 1-3+ seconds for container boot, even for a CSS file
  3. Wasted compute cost: Modal bills per-second for container time. Serving static files through Python wastes expensive compute on file I/O
  4. Poor repeat-visit performance: No browser-side Cache-Control headers means browsers revalidate every request
@chilang
chilang / README.md
Created December 5, 2024 09:13
MLX Flux Image Generator - Mac Installation Script (Final)

MLX Flux Image Generator Installation

A simple installer for the MLX Flux Image Generator, optimized for Apple Silicon Macs.

One-Line Installation

curl -fsSL https://gist.githubusercontent.com/chilang/02482073c949f4f8e3125364a1c93073/raw/install.sh | bash
@chilang
chilang / README.md
Created December 5, 2024 09:13
MLX Flux Image Generator - Mac Installation Script (Final)

MLX Flux Image Generator Installation

A simple installer for the MLX Flux Image Generator, optimized for Apple Silicon Macs.

One-Line Installation

curl -fsSL https://gist.githubusercontent.com/chilang/02482073c949f4f8e3125364a1c93073/raw/install.sh | bash
@chilang
chilang / README.md
Created December 5, 2024 09:13
MLX Flux Image Generator - Mac Installation Script

MLX Flux Image Generator Installation

A simple installer for the MLX Flux Image Generator, optimized for Apple Silicon Macs.

One-Line Installation

curl -fsSL https://gist.githubusercontent.com/chilang/02482073c949f4f8e3125364a1c93073/raw/install.sh | bash
@chilang
chilang / README.md
Created December 5, 2024 09:12
MLX Flux Image Generator Installation Script

MLX Flux Image Generator Installation

A simple installer for the MLX Flux Image Generator, optimized for Apple Silicon Macs.

One-Line Installation

curl -fsSL https://gist.githubusercontent.com/chilang/c9f6b7db9596282d5149a5611279da2f/raw/install.sh | bash
@chilang
chilang / README.md
Created December 5, 2024 09:11
MLX Flux Image Generator Installation Script

MLX Flux Image Generator Installation

A simple installer for the MLX Flux Image Generator, optimized for Apple Silicon Macs.

One-Line Installation

curl -fsSL https://gist.githubusercontent.com/chilang/058369df8ddf6ec11e94b49cd685b9cd/raw/install.sh | bash
@chilang
chilang / caption.js
Created November 16, 2023 15:54
hyperaudio-static
/*! (C) The Hyperaudio Project. MIT @license: en.wikipedia.org/wiki/MIT_License. */
/*! Version 2.1.4 */
'use strict';
var caption = function () {
var cap = {};
function formatSeconds(seconds) {
if (typeof seconds == 'number') {
//console.log("seconds = "+seconds);
ttest, pval = ttest_ind(local_mean_f1_scores, fed_avg_f1_scores)
print("statistically significant:", pval < 0.05)
print("p =", pval)
hyperparams = {
'n_runners': 10,
'sample_size': 5,
'rounds': 100,
'combine': 'weighted', # or 'mean'
'partition_params': {
'scheme': 'uniform' # stratified, non-iidness, noise injection etc.
},
'runner_hyperparams': {
'epochs': 1,
skews = {0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99}
scores = {}
for skew in skews:
print("eval", skew)
hyperparams = {
'n_runners': 10,
'sample_size': 10,
'rounds': 1,
'combine': 'weighted', # or 'mean'
'partition_params': {