Compare commits
2 Commits
a962f13c51
...
doot
| Author | SHA1 | Date | |
|---|---|---|---|
| b1bd11a5c5 | |||
| 252aee0ff0 |
18
.dockerignore
Executable file → Normal file
@@ -1,16 +1,6 @@
|
|||||||
.git
|
react_OLD
|
||||||
.gitignore
|
|
||||||
.env
|
|
||||||
.venv
|
.venv
|
||||||
.vscode
|
.vscode
|
||||||
.claude
|
.git
|
||||||
CLAUDE.md
|
.git*
|
||||||
README.md
|
__pycache__
|
||||||
STATUS_MONITOR_README.md
|
|
||||||
Dockerfile
|
|
||||||
docker-compose.yml
|
|
||||||
notes.txt
|
|
||||||
react_OLD
|
|
||||||
__pycache__
|
|
||||||
*.pyc
|
|
||||||
adhoc
|
|
||||||
0
.gitattributes
vendored
Executable file → Normal file
@@ -1,2 +0,0 @@
|
|||||||
[core]
|
|
||||||
filemode = false
|
|
||||||
8
.gitignore
vendored
Executable file → Normal file
@@ -2,10 +2,4 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
notes.txt
|
notes.txt
|
||||||
react_OLD
|
react_OLD
|
||||||
envs.py
|
envs.py
|
||||||
.env
|
|
||||||
status_history.json
|
|
||||||
|
|
||||||
.claude
|
|
||||||
CLAUDE.md
|
|
||||||
.aider*
|
|
||||||
0
.vscode/launch.json
vendored
Executable file → Normal file
0
.vscode/settings.json
vendored
Executable file → Normal file
50
Dockerfile
Executable file → Normal file
@@ -1,34 +1,34 @@
|
|||||||
# Use a slimmer base image to reduce image size and pull times
|
FROM ubuntu:lunar
|
||||||
FROM python:3.10-slim-bullseye
|
|
||||||
LABEL maintainer="Andrew Simonson <asimonson1125@gmail.com>"
|
LABEL maintainer="Andrew Simonson <asimonson1125@gmail.com>"
|
||||||
|
|
||||||
# Set environment variables for better Python performance in Docker
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
||||||
PYTHONUNBUFFERED=1 \
|
|
||||||
PIP_NO_CACHE_DIR=1
|
|
||||||
|
|
||||||
WORKDIR /app
|
RUN apt-get update
|
||||||
|
RUN apt-get install -y python3-pip nginx gunicorn supervisor
|
||||||
|
|
||||||
# Create a non-root user for security
|
# Setup flask application
|
||||||
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
RUN mkdir -p /deploy/app
|
||||||
|
COPY src /deploy/app
|
||||||
|
RUN pip install -r /deploy/app/requirements.txt --break-system-packages
|
||||||
|
|
||||||
# Copy only the requirements file first to leverage Docker layer caching
|
# Setup nginx
|
||||||
COPY src/requirements.txt .
|
RUN rm /etc/nginx/sites-enabled/default
|
||||||
|
COPY flask.conf /etc/nginx/sites-available/
|
||||||
|
RUN ln -s /etc/nginx/sites-available/flask.conf /etc/nginx/sites-enabled/flask.conf && \
|
||||||
|
echo "daemon off;" >> /etc/nginx/nginx.conf
|
||||||
|
|
||||||
# Install dependencies as root, but then switch to the non-root user
|
# Setup supervisord
|
||||||
RUN pip install -r requirements.txt
|
RUN mkdir -p /var/log/supervisor
|
||||||
|
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
COPY gunicorn.conf /etc/supervisor/conf.d/gunicorn.conf
|
||||||
|
|
||||||
# Copy the rest of the source code
|
# Permissions
|
||||||
COPY src/ .
|
# RUN adduser --disabled-password --gecos '' supervisor && \
|
||||||
|
RUN chmod -R 777 /var/* && \
|
||||||
|
chown -R root /var/*
|
||||||
|
|
||||||
# Ensure the appuser owns the app directory
|
# Entrypoint
|
||||||
RUN chown -R appuser:appuser /app
|
USER root
|
||||||
|
|
||||||
# Switch to the non-root user for better security
|
# Start processes
|
||||||
USER appuser
|
CMD ["/usr/bin/supervisord"]
|
||||||
|
|
||||||
# Expose the port (Gunicorn's default or specified in CMD)
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
# Start Gunicorn
|
|
||||||
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]
|
|
||||||
|
|||||||
97
README.md
Executable file → Normal file
@@ -1,92 +1,9 @@
|
|||||||
# Personal Portfolio & Service Monitor
|
# I made a uhh website
|
||||||
|
So people can see how excellent my coding standards are.
|
||||||
|
|
||||||
A Flask-based website for my personal portfolio and a service monitoring dashboard. This project handles dynamic project showcases, automated service health tracking, and production-ready optimizations.
|
* Style: 5/10
|
||||||
|
* Originality: 3/10
|
||||||
|
* Security: Yes*
|
||||||
|
* Viruses: not included
|
||||||
|
|
||||||
## Features
|
You gotta uhh `pip3 install -r requirements.txt` and `python3 app.py` that thing
|
||||||
|
|
||||||
- **Content Management**: Pages like projects, books, and skills are managed via JSON files in the `static` directory.
|
|
||||||
- **Service Monitoring**: Background health checks for external services with uptime statistics stored in PostgreSQL.
|
|
||||||
- **Optimizations**:
|
|
||||||
- HTML, CSS, and JS minification via `Flask-Minify`.
|
|
||||||
- MD5-based cache busting for static assets.
|
|
||||||
- Configurable cache-control headers.
|
|
||||||
- **Security**: Pre-configured headers for XSS protection and frame security.
|
|
||||||
- **Deployment**: Ready for containerized deployment with Docker and Gunicorn.
|
|
||||||
|
|
||||||
## Tech Stack
|
|
||||||
|
|
||||||
- **Backend**: Python 3.12, Flask
|
|
||||||
- **Frontend**: Vanilla CSS/JS, Jinja2
|
|
||||||
- **Database**: PostgreSQL (optional, for monitoring history)
|
|
||||||
- **Infrastructure**: Docker, docker-compose
|
|
||||||
|
|
||||||
## Project Structure
|
|
||||||
|
|
||||||
```text
|
|
||||||
.
|
|
||||||
├── src/
|
|
||||||
│ ├── app.py # Application entry point
|
|
||||||
│ ├── monitor.py # Service monitoring logic
|
|
||||||
│ ├── config.py # Environment configuration
|
|
||||||
│ ├── templates/ # HTML templates
|
|
||||||
│ ├── static/ # CSS, JS, and JSON data
|
|
||||||
│ └── requirements.txt # Python dependencies
|
|
||||||
├── Dockerfile # Container definition
|
|
||||||
├── docker-compose.yml # Local stack orchestration
|
|
||||||
└── STATUS_MONITOR_README.md # Monitoring system documentation
|
|
||||||
```
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
### Using Docker
|
|
||||||
|
|
||||||
To run the full stack (App + PostgreSQL):
|
|
||||||
|
|
||||||
1. **Clone the repository**:
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/asimonson1125/asimonson1125.github.io.git
|
|
||||||
cd asimonson1125.github.io
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Start services**:
|
|
||||||
```bash
|
|
||||||
docker-compose up --build
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Access the site**:
|
|
||||||
Visit [http://localhost:8080](http://localhost:8080).
|
|
||||||
|
|
||||||
### Local Development
|
|
||||||
|
|
||||||
To run the Flask app without Docker:
|
|
||||||
|
|
||||||
1. **Set up a virtual environment**:
|
|
||||||
```bash
|
|
||||||
python3 -m venv .venv
|
|
||||||
source .venv/bin/activate
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Install dependencies**:
|
|
||||||
```bash
|
|
||||||
pip install -r src/requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Run the application**:
|
|
||||||
```bash
|
|
||||||
cd src
|
|
||||||
python3 app.py
|
|
||||||
```
|
|
||||||
*Note: status monitor is by default disabled outside of its container cluster*
|
|
||||||
|
|
||||||
## Service Monitoring
|
|
||||||
|
|
||||||
The monitoring system in `src/monitor.py` tracks service availability. It:
|
|
||||||
- Runs concurrent health checks every hour.
|
|
||||||
- Calculates uptime for various windows (24h, 7d, 30d).
|
|
||||||
- Provides a status UI at `/status` and a JSON API at `/api/status`.
|
|
||||||
|
|
||||||
See [STATUS_MONITOR_README.md](./STATUS_MONITOR_README.md) for more details.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
This project is personal property. All rights reserved.
|
|
||||||
|
|||||||
@@ -1,141 +0,0 @@
|
|||||||
# Service Status Monitor
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
Server-side monitoring system that checks the availability of asimonson.com services every 60 seconds and provides uptime statistics.
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
### Backend Components
|
|
||||||
|
|
||||||
#### 1. `monitor.py` - Service Monitoring Module
|
|
||||||
- **Purpose**: Performs automated health checks on all services
|
|
||||||
- **Check Interval**: Every 60 seconds
|
|
||||||
- **Services Monitored**:
|
|
||||||
- asimonson.com
|
|
||||||
- files.asimonson.com
|
|
||||||
- git.asimonson.com
|
|
||||||
|
|
||||||
**Features**:
|
|
||||||
- Tracks response times and HTTP status codes
|
|
||||||
- Calculates uptime percentages for multiple time periods (24h, 7d, 30d, all-time)
|
|
||||||
- Persists data to PostgreSQL (`service_checks` table) via `DATABASE_URL` env var
|
|
||||||
- Gracefully degrades when no database is configured (local dev)
|
|
||||||
- Runs in a background thread, with each check cycle guarded so a transient
|
|
||||||
failure (DB hiccup, network blip) logs and retries next interval instead of
|
|
||||||
killing the thread
|
|
||||||
- Flags the cached summary as `stale` if no check has landed in the last 5
|
|
||||||
intervals, so `/api/status` can't silently keep serving old data as fresh
|
|
||||||
|
|
||||||
#### 2. `app.py` - Flask Integration
|
|
||||||
- **New API Endpoint**: `/api/status`
|
|
||||||
- Returns current status for all services
|
|
||||||
- Includes uptime statistics
|
|
||||||
- Provides last check and next check times
|
|
||||||
- **Auto-start**: Monitoring begins when the Flask app starts
|
|
||||||
|
|
||||||
### Frontend Components
|
|
||||||
|
|
||||||
#### 1. `templates/status.html` - Status Page Template
|
|
||||||
- Displays real-time service status
|
|
||||||
- Shows uptime percentages (24h, 7d, 30d, all-time)
|
|
||||||
- Displays response times and status codes
|
|
||||||
- Shows total number of checks performed
|
|
||||||
- Manual refresh button
|
|
||||||
- Auto-refreshes every 60 seconds
|
|
||||||
|
|
||||||
#### 2. `static/js/status.js` - Frontend Logic
|
|
||||||
- Fetches status data from `/api/status` API
|
|
||||||
- Updates UI with service status and uptime
|
|
||||||
- Shows a dismissible-on-refresh notice banner when the response is a fetch
|
|
||||||
error, and a persistent notice when the backend flags the data as `stale`
|
|
||||||
- Auto-refresh every 60 seconds
|
|
||||||
|
|
||||||
#### 3. `static/css/App.css` - Styling
|
|
||||||
- Color-coded status indicators:
|
|
||||||
- Green: Operational
|
|
||||||
- Yellow: Degraded/Timeout
|
|
||||||
- Red: Offline
|
|
||||||
- Responsive grid layout
|
|
||||||
- Dark theme matching existing site design
|
|
||||||
|
|
||||||
## Data Storage
|
|
||||||
|
|
||||||
Check history is stored in a PostgreSQL `service_checks` table. The connection is configured via the `DATABASE_URL` environment variable (e.g. `postgresql://user:pass@host:5432/dbname`).
|
|
||||||
|
|
||||||
```sql
|
|
||||||
CREATE TABLE service_checks (
|
|
||||||
id SERIAL PRIMARY KEY,
|
|
||||||
service_id VARCHAR(50) NOT NULL,
|
|
||||||
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
||||||
status VARCHAR(20) NOT NULL,
|
|
||||||
response_time INTEGER,
|
|
||||||
status_code INTEGER,
|
|
||||||
error TEXT
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
The table and index are created automatically on startup. If `DATABASE_URL` is not set, the monitor runs without persistence (useful for local development).
|
|
||||||
|
|
||||||
## Status Types
|
|
||||||
|
|
||||||
- **online**: HTTP status 2xx-4xx, service responding
|
|
||||||
- **degraded**: HTTP status 5xx or slow response
|
|
||||||
- **timeout**: Request exceeded timeout limit (10 seconds)
|
|
||||||
- **offline**: Unable to reach service
|
|
||||||
- **unknown**: No checks performed yet
|
|
||||||
|
|
||||||
## Uptime Calculation
|
|
||||||
|
|
||||||
Uptime percentage = (number of online checks / total checks) × 100
|
|
||||||
|
|
||||||
Calculated for:
|
|
||||||
- Last 24 hours
|
|
||||||
- Last 7 days
|
|
||||||
- Last 30 days
|
|
||||||
- All-time (since monitoring began)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Starting the Server
|
|
||||||
```bash
|
|
||||||
cd src
|
|
||||||
python3 app.py
|
|
||||||
```
|
|
||||||
|
|
||||||
The monitoring will start automatically and perform an initial check immediately, then every 60 seconds thereafter.
|
|
||||||
|
|
||||||
### Accessing the Status Page
|
|
||||||
Navigate to: `https://asimonson.com/status`
|
|
||||||
|
|
||||||
### API Access
|
|
||||||
Direct API access: `https://asimonson.com/api/status`
|
|
||||||
|
|
||||||
Returns JSON with current status and uptime statistics for all services.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
To modify monitoring behavior, edit `src/monitor.py`:
|
|
||||||
|
|
||||||
```python
|
|
||||||
# Change check interval (in seconds)
|
|
||||||
CHECK_INTERVAL = 60 # 1 minute
|
|
||||||
|
|
||||||
# Modify service list
|
|
||||||
SERVICES = [
|
|
||||||
{
|
|
||||||
'id': 'main',
|
|
||||||
'name': 'asimonson.com',
|
|
||||||
'url': 'https://asimonson.com',
|
|
||||||
'timeout': 10 # seconds
|
|
||||||
},
|
|
||||||
# Add more services here
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
- First deployment will show limited uptime data until enough checks accumulate
|
|
||||||
- Historical data is preserved across server restarts (stored in PostgreSQL)
|
|
||||||
- Page auto-refreshes every 60 seconds to show latest server data
|
|
||||||
- Manual refresh button available for immediate updates
|
|
||||||
- All checks performed server-side (no client-side CORS issues)
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
"""
|
|
||||||
Regenerates the neon star logo SVGs without SVG filters.
|
|
||||||
|
|
||||||
iOS WebKit renders SVG filter output (feGaussianBlur) at a capped, low resolution,
|
|
||||||
which smears the original Inkscape logo's glow into a blocky blob at icon sizes.
|
|
||||||
This script reproduces that design with no filters at all:
|
|
||||||
|
|
||||||
- star + glow: the original blur chain, computed here with scipy on a symmetric
|
|
||||||
rebuild of the star and embedded as a WebP. A glow has no fine detail, so the
|
|
||||||
image scales without visible loss.
|
|
||||||
- tube halo: nested strokes whose opacities reproduce the original stack of blurs
|
|
||||||
around a 3-unit line, stepped finer as the halo fades so its edge never shows.
|
|
||||||
|
|
||||||
Outputs (overwritten in place):
|
|
||||||
src/static/icons/neonfinal3.svg header mark, transparent background
|
|
||||||
src/static/icons/withBackground.svg favicon, same mark on a dark disc
|
|
||||||
|
|
||||||
Usage (from the repo root):
|
|
||||||
pip install -r adhoc/neon-star/requirements.txt
|
|
||||||
python -m playwright install chromium
|
|
||||||
python adhoc/neon-star/build_neon_star.py
|
|
||||||
|
|
||||||
Chromium (via Playwright) is only used to rasterise the star path before blurring.
|
|
||||||
"""
|
|
||||||
import base64
|
|
||||||
import io
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
from PIL import Image
|
|
||||||
from playwright.sync_api import sync_playwright
|
|
||||||
from scipy.ndimage import gaussian_filter
|
|
||||||
from scipy.stats import norm
|
|
||||||
|
|
||||||
ICONS = Path(__file__).resolve().parents[2] / "src" / "static" / "icons"
|
|
||||||
|
|
||||||
# Glow intensity: alpha a becomes 1-(1-a)^K, which brightens without clipping.
|
|
||||||
# 1.0 reproduces the original Inkscape design exactly.
|
|
||||||
K = 1.8
|
|
||||||
|
|
||||||
# --- geometry, all from the original Inkscape file --------------------------------
|
|
||||||
VIEWBOX = "0 0 216.75919 216.7592"
|
|
||||||
LAYER = "translate(-6.8045576,-27.991731)"
|
|
||||||
STAR_SCALE, STAR_TX, STAR_TY = 1.1617659, 37.635304, 39.028635
|
|
||||||
STAR_MATRIX = f"matrix({STAR_SCALE},0,0,{STAR_SCALE},{STAR_TX},{STAR_TY})"
|
|
||||||
STAR_C = (68.084846, 82.277237) # star centre, star-local units
|
|
||||||
TUBES_TRANSFORM = "translate(10.7751035,-33.343613)"
|
|
||||||
TUBE_PATHS = [
|
|
||||||
('translate(-6.0989631,2.1674006)', "M 142.67883,102.44998 H 73.832338 a 10.424106,10.424106 142.5 0 0 -10.068913,7.72615 l -6.688692,24.96254"),
|
|
||||||
('', "M 156.95436,91.412872 H 56.426396 A 10.527561,10.527561 142.5 0 0 46.257553,99.2157 l -11.945382,44.58078"),
|
|
||||||
('rotate(180,105.40367,165.67111)', "M 142.67883,102.44998 H 73.832338 a 10.424106,10.424106 142.5 0 0 -10.068913,7.72615 l -6.688692,24.96254"),
|
|
||||||
('rotate(180,103.61221,167.4007)', "M 156.95436,91.412872 H 56.426396 a 10.496229,10.496229 142.41749 0 0 -10.146361,7.808817 l -13.97988,52.781241"),
|
|
||||||
]
|
|
||||||
BACKGROUND = '<circle cx="115.18415" cy="136.37132" r="108.37959" fill="#1a1a1a"/>'
|
|
||||||
|
|
||||||
# --- star path ----------------------------------------------------------------------
|
|
||||||
# The original star's arms had two different edge curves (handles (9.11, 1.29) and
|
|
||||||
# (7.51, 0.72)), so the points leaned like a pinwheel. Every edge here uses their
|
|
||||||
# average, mirrored, so all four points and shoulders are identical.
|
|
||||||
TIP, ARM_W, SHOULDER = 50.0, 3.0, 15.0
|
|
||||||
HANDLE_ALONG, HANDLE_OUT = (9.1085 + 7.51146) / 2, (1.28778 + 0.71725) / 2
|
|
||||||
|
|
||||||
|
|
||||||
def star_path():
|
|
||||||
def rot(p, n):
|
|
||||||
x, y = p
|
|
||||||
for _ in range(n):
|
|
||||||
x, y = y, -x
|
|
||||||
return x, y
|
|
||||||
|
|
||||||
def pt(p):
|
|
||||||
return f"{p[0] + STAR_C[0]:.4f},{p[1] + STAR_C[1]:.4f}"
|
|
||||||
|
|
||||||
add = lambda p, q: (p[0] + q[0], p[1] + q[1])
|
|
||||||
sub = lambda p, q: (p[0] - q[0], p[1] - q[1])
|
|
||||||
# one quadrant: left tip -> left arm's lower shoulder -> bottom arm's left shoulder
|
|
||||||
tip, lower, bottom = (-TIP, 0), (-SHOULDER, ARM_W), (-ARM_W, SHOULDER)
|
|
||||||
h_lower, h_bottom = (HANDLE_ALONG, HANDLE_OUT), (-HANDLE_OUT, -HANDLE_ALONG)
|
|
||||||
segs = []
|
|
||||||
for n in range(4):
|
|
||||||
r = lambda p: rot(p, n)
|
|
||||||
segs.append(f"C {pt(r(tip))} {pt(r(sub(lower, h_lower)))} {pt(r(lower))}")
|
|
||||||
segs.append(f"C {pt(r(add(lower, h_lower)))} {pt(r(add(bottom, h_bottom)))} {pt(r(bottom))}")
|
|
||||||
segs.append(f"C {pt(r(sub(bottom, h_bottom)))} {pt(r((0, TIP)))} {pt(r((0, TIP)))}")
|
|
||||||
return f"M {pt((-TIP, 0))} " + " ".join(segs) + " Z"
|
|
||||||
|
|
||||||
|
|
||||||
# --- star + glow texture ------------------------------------------------------------
|
|
||||||
HALF = 100.0 # texture covers +-HALF layer units around the star
|
|
||||||
PX_PER_UNIT = 3.2
|
|
||||||
N = int(2 * HALF * PX_PER_UNIT)
|
|
||||||
CX = STAR_SCALE * STAR_C[0] + STAR_TX # star centre, layer units
|
|
||||||
CY = STAR_SCALE * STAR_C[1] + STAR_TY
|
|
||||||
|
|
||||||
|
|
||||||
def render_star(path_d):
|
|
||||||
"""Rasterise the star (original fill gradient + orange edge) as premultiplied RGBA."""
|
|
||||||
svg = f'''<svg xmlns="http://www.w3.org/2000/svg" width="{N}" height="{N}" viewBox="{CX - HALF} {CY - HALF} {2 * HALF} {2 * HALF}">
|
|
||||||
<defs><radialGradient id="f" cx="{STAR_C[0]}" cy="{STAR_C[1]}" r="51.629848" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#ffc919"/><stop offset="1" stop-color="#d2ae2d"/></radialGradient></defs>
|
|
||||||
<path transform="{STAR_MATRIX}" fill="url(#f)" stroke="#ff9c00" stroke-width="0.860759" stroke-linejoin="round" d="{path_d}"/></svg>'''
|
|
||||||
with sync_playwright() as p:
|
|
||||||
browser = p.chromium.launch()
|
|
||||||
page = browser.new_page(viewport={"width": N, "height": N})
|
|
||||||
page.set_content(f'<body style="margin:0">{svg}</body>')
|
|
||||||
png = page.screenshot(omit_background=True)
|
|
||||||
browser.close()
|
|
||||||
img = np.asarray(Image.open(io.BytesIO(png)).convert("RGBA")).astype(float) / 255
|
|
||||||
img[..., :3] *= img[..., 3:]
|
|
||||||
return img
|
|
||||||
|
|
||||||
|
|
||||||
def blur(img, sigma):
|
|
||||||
return np.stack([gaussian_filter(img[..., c], sigma * PX_PER_UNIT) for c in range(4)], -1)
|
|
||||||
|
|
||||||
|
|
||||||
def over(top, bottom):
|
|
||||||
return top + bottom * (1 - top[..., 3:])
|
|
||||||
|
|
||||||
|
|
||||||
def star_texture(path_d):
|
|
||||||
star = render_star(path_d)
|
|
||||||
core = blur(star, 1.368) # original filter10 (0.5) + filter5 (1.07), in layer units
|
|
||||||
mid = 0.7 * blur(core, 9.294) # original use6: opacity 0.7, filter6
|
|
||||||
wide = blur(mid, 10.041) # original use7: filter8 on top of use6
|
|
||||||
glow = over(mid, wide)
|
|
||||||
if K != 1.0:
|
|
||||||
a = glow[..., 3:]
|
|
||||||
glow = glow * np.divide(1 - (1 - a) ** K, a, out=np.zeros_like(a), where=a > 1e-6)
|
|
||||||
out = over(core, glow)
|
|
||||||
rgb = np.divide(out[..., :3], out[..., 3:], out=np.zeros_like(out[..., :3]), where=out[..., 3:] > 1e-6)
|
|
||||||
rgba = (np.concatenate([rgb, out[..., 3:]], -1).clip(0, 1) * 255 + 0.5).astype("uint8")
|
|
||||||
buf = io.BytesIO()
|
|
||||||
Image.fromarray(rgba).save(buf, "WEBP", quality=92, method=6)
|
|
||||||
return base64.b64encode(buf.getvalue()).decode()
|
|
||||||
|
|
||||||
|
|
||||||
# --- tube halo ----------------------------------------------------------------------
|
|
||||||
def tube_halo():
|
|
||||||
sigmas = [13.071903, 4.7058852, 1.1764713] # original filter30, filter29, filter9
|
|
||||||
|
|
||||||
def alpha(d):
|
|
||||||
"""Original halo alpha at distance d from the centre of a 3-unit line."""
|
|
||||||
a = 0.75 * (1 - np.prod([1 - (norm.cdf((d + 1.5) / s) - norm.cdf((d - 1.5) / s)) for s in sigmas]))
|
|
||||||
return 1 - (1 - a) ** K
|
|
||||||
|
|
||||||
def radius_at(v, lo=1.5, hi=100.0):
|
|
||||||
for _ in range(60):
|
|
||||||
m = (lo + hi) / 2
|
|
||||||
lo, hi = (m, hi) if alpha(m) > v else (lo, m)
|
|
||||||
return lo
|
|
||||||
|
|
||||||
# Alpha levels per band: ~0.025 steps where bright, ~0.008 in the tail. Every step
|
|
||||||
# must stay large enough to survive 8-bit compositing, or the halo goes missing.
|
|
||||||
a0 = alpha(1.5)
|
|
||||||
levels = list(np.linspace(a0, 0.08, max(6, int(np.ceil((a0 - 0.08) / 0.025))), endpoint=False))
|
|
||||||
levels += list(np.linspace(0.08, 0.008, 10))
|
|
||||||
bands = [(a + b) / 2 for a, b in zip(levels, levels[1:] + [0.0])] + [0.0]
|
|
||||||
uses = []
|
|
||||||
for k in range(len(bands) - 1):
|
|
||||||
r = radius_at((bands[k] + bands[k + 1]) / 2)
|
|
||||||
o = 1 - (1 - bands[k]) / (1 - bands[k + 1])
|
|
||||||
uses.append(f'<use xlink:href="#tubePaths" stroke-width="{2 * r:.3f}" stroke-opacity="{o:.4f}"/>')
|
|
||||||
return "".join(reversed(uses))
|
|
||||||
|
|
||||||
|
|
||||||
# --- assembly -----------------------------------------------------------------------
|
|
||||||
def build_svg(texture_b64, halo, background=""):
|
|
||||||
tubes = "\n".join(
|
|
||||||
' <path' + (f' transform="{t}"' if t else '') + f' d="{d}"/>' for t, d in TUBE_PATHS)
|
|
||||||
return f'''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="{VIEWBOX}" width="64" height="64">
|
|
||||||
<!--
|
|
||||||
Generated by adhoc/neon-star/build_neon_star.py; edit that, not this file.
|
|
||||||
No SVG filters: iOS WebKit renders filter output at a capped low resolution,
|
|
||||||
which smears the glow at icon sizes. The star and its glow are the original blur
|
|
||||||
chain computed offline and embedded as a WebP; the tube halo is nested strokes.
|
|
||||||
-->
|
|
||||||
<defs>
|
|
||||||
<g id="tubePaths">
|
|
||||||
{tubes}
|
|
||||||
</g>
|
|
||||||
</defs>
|
|
||||||
<g transform="{LAYER}">
|
|
||||||
{background}
|
|
||||||
<image x="{CX - HALF:.3f}" y="{CY - HALF:.3f}" width="{2 * HALF}" height="{2 * HALF}" preserveAspectRatio="none" xlink:href="data:image/webp;base64,{texture_b64}"/>
|
|
||||||
<g transform="{TUBES_TRANSFORM}" fill="none" stroke="#ededed" stroke-linecap="round" stroke-linejoin="round">
|
|
||||||
{halo}
|
|
||||||
<use xlink:href="#tubePaths" stroke-width="3"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
texture = star_texture(star_path())
|
|
||||||
halo = tube_halo()
|
|
||||||
for name, bg in [("neonfinal3.svg", ""), ("withBackground.svg", BACKGROUND)]:
|
|
||||||
out = ICONS / name
|
|
||||||
out.write_text(build_svg(texture, halo, bg), encoding="utf-8")
|
|
||||||
print(f"wrote {out} ({out.stat().st_size} bytes)")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
numpy
|
|
||||||
scipy
|
|
||||||
pillow
|
|
||||||
playwright
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
services:
|
|
||||||
portfolio:
|
|
||||||
image: 'asimonson1125/portfolio'
|
|
||||||
build:
|
|
||||||
context: ./
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
restart: 'no'
|
|
||||||
ports:
|
|
||||||
- 8080:8080
|
|
||||||
environment:
|
|
||||||
DATABASE_URL: postgresql://portfolio:portfolio@db:5432/portfolio
|
|
||||||
depends_on:
|
|
||||||
db:
|
|
||||||
condition: service_healthy
|
|
||||||
|
|
||||||
db:
|
|
||||||
image: postgres:16-alpine
|
|
||||||
restart: 'no'
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: portfolio
|
|
||||||
POSTGRES_PASSWORD: portfolio
|
|
||||||
POSTGRES_DB: portfolio
|
|
||||||
volumes:
|
|
||||||
- pgdata:/var/lib/postgresql/data
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U portfolio"]
|
|
||||||
interval: 5s
|
|
||||||
timeout: 3s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
pgdata:
|
|
||||||
24
flask.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
server {
|
||||||
|
listen 8080;
|
||||||
|
server_name www.asimonson.com;
|
||||||
|
return 301 https://asimonson.com$request_uri;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 8080;
|
||||||
|
server_name asimonson.com;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_types text/plain text/javascript text/css;
|
||||||
|
gunzip on;
|
||||||
|
|
||||||
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||||
|
add_header X-Content-Type-Options 'nosniff';
|
||||||
|
add_header X-Frame-Options 'SAMEORIGIN';
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:5000/;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
3
gunicorn.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[program:gunicorn]
|
||||||
|
command=/usr/bin/gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker app:app -b localhost:5000
|
||||||
|
directory=/deploy/app
|
||||||
227
src/app.py
Executable file → Normal file
@@ -1,171 +1,102 @@
|
|||||||
import hashlib
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
from flask_minify import Minify
|
from flask_minify import Minify
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
import json
|
||||||
import werkzeug.exceptions as HTTPerror
|
import werkzeug.exceptions as HTTPerror
|
||||||
|
import requests
|
||||||
|
from config import *
|
||||||
|
|
||||||
import config # noqa: F401 — side-effect: loads dev env vars
|
proj = json.load(open("./static/json/projects.json", "r"))
|
||||||
from monitor import monitor, SERVICES
|
books = json.load(open("./static/json/books.json", "r"))
|
||||||
|
skillList = json.load(open("./static/json/skills.json", "r"))
|
||||||
|
timeline = json.load(open("./static/json/timeline.json", "r"))
|
||||||
|
pages = json.load(open("./static/json/pages.json", "r"))
|
||||||
|
pages['about']['skillList'] = skillList
|
||||||
|
pages['about']['timeline'] = timeline
|
||||||
|
pages['projects']['projects'] = proj
|
||||||
|
pages['home']['books'] = books
|
||||||
|
pages['books']['books'] = books
|
||||||
|
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
# Trust the scheme/host Cloudflare sets, so redirects Werkzeug builds itself
|
|
||||||
# (e.g. the trailing-slash redirect on /api/goto) use https instead of the
|
|
||||||
# plaintext scheme it sees on its own socket.
|
|
||||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1)
|
|
||||||
|
|
||||||
# ── Static file fingerprinting ────────────────────────────────────────
|
|
||||||
|
|
||||||
static_file_hashes = {}
|
|
||||||
for dirpath, _, filenames in os.walk(app.static_folder):
|
|
||||||
for filename in filenames:
|
|
||||||
filepath = os.path.join(dirpath, filename)
|
|
||||||
relative = os.path.relpath(filepath, app.static_folder).replace(os.sep, '/')
|
|
||||||
with open(filepath, 'rb') as f:
|
|
||||||
static_file_hashes[relative] = hashlib.md5(f.read()).hexdigest()[:8]
|
|
||||||
|
|
||||||
|
|
||||||
@app.context_processor
|
|
||||||
def override_url_for():
|
|
||||||
def versioned_url_for(endpoint, **values):
|
|
||||||
if endpoint == 'static':
|
|
||||||
filename = values.get('filename')
|
|
||||||
if filename and filename in static_file_hashes:
|
|
||||||
values['v'] = static_file_hashes[filename]
|
|
||||||
return flask.url_for(endpoint, **values)
|
|
||||||
return dict(url_for=versioned_url_for)
|
|
||||||
|
|
||||||
|
|
||||||
# ── Security and caching headers ──────────────────────────────────────
|
|
||||||
|
|
||||||
@app.after_request
|
|
||||||
def add_headers(response):
|
|
||||||
response.headers['X-Content-Type-Options'] = 'nosniff'
|
|
||||||
response.headers['X-Frame-Options'] = 'SAMEORIGIN'
|
|
||||||
response.headers['X-XSS-Protection'] = '1; mode=block'
|
|
||||||
response.headers['Referrer-Policy'] = 'strict-origin-when-cross-origin'
|
|
||||||
|
|
||||||
if flask.request.is_secure:
|
|
||||||
response.headers['Strict-Transport-Security'] = 'max-age=31536000'
|
|
||||||
|
|
||||||
if flask.request.path.startswith('/static/'):
|
|
||||||
response.headers['Cache-Control'] = 'public, max-age=31536000, immutable'
|
|
||||||
elif flask.request.path in ['/sitemap.xml', '/robots.txt']:
|
|
||||||
response.headers['Cache-Control'] = 'public, max-age=86400'
|
|
||||||
else:
|
|
||||||
response.headers['Cache-Control'] = 'no-cache, must-revalidate'
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
# ── Load page data ────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
def load_json(path):
|
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
|
||||||
return json.load(f)
|
|
||||||
|
|
||||||
|
|
||||||
projects = load_json("./static/json/projects.json")
|
|
||||||
books = load_json("./static/json/books.json")
|
|
||||||
skills = load_json("./static/json/skills.json")
|
|
||||||
pages = load_json("./static/json/pages.json")
|
|
||||||
features = load_json("./static/json/features.json")
|
|
||||||
|
|
||||||
pages['about']['skillList'] = skills
|
|
||||||
pages['projects']['projects'] = projects
|
|
||||||
pages['projects']['features'] = features
|
|
||||||
pages['home']['features'] = features
|
|
||||||
pages['home']['books'] = books
|
|
||||||
pages['home']['projects'] = projects
|
|
||||||
pages['books']['books'] = books
|
|
||||||
pages['status']['services'] = SERVICES
|
|
||||||
|
|
||||||
for _name, _page in pages.items():
|
|
||||||
_page['id'] = _name
|
|
||||||
|
|
||||||
|
|
||||||
@app.template_filter('slug')
|
|
||||||
def slug(value):
|
|
||||||
value = re.sub(r'[^a-z0-9]+', '-', str(value).lower())
|
|
||||||
return value.strip('-')
|
|
||||||
|
|
||||||
|
|
||||||
# ── Error rendering ──────────────────────────────────────────────────
|
|
||||||
|
|
||||||
def render_error(code, message):
|
|
||||||
pagevars = {
|
|
||||||
"template": "error.html",
|
|
||||||
"title": f"{code} - Simonson",
|
|
||||||
"description": "Error on Andrew Simonson's Digital Portfolio",
|
|
||||||
"canonical": f"/{code}",
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
flask.render_template(
|
|
||||||
"header.html",
|
|
||||||
var=pagevars,
|
|
||||||
error=code,
|
|
||||||
message=message,
|
|
||||||
title=f"{code} - Simonson Portfolio",
|
|
||||||
),
|
|
||||||
code,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(HTTPerror.HTTPException)
|
|
||||||
def handle_http_error(e):
|
|
||||||
return render_error(e.code, e.description)
|
|
||||||
|
|
||||||
|
|
||||||
@app.errorhandler(Exception)
|
|
||||||
def handle_generic_error(e):
|
|
||||||
return render_error(500, "Internal Server Error")
|
|
||||||
|
|
||||||
|
|
||||||
# ── API routes ────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
@app.route('/api/status')
|
|
||||||
def api_status():
|
|
||||||
return flask.jsonify(monitor.get_status_summary())
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/goto/')
|
@app.route('/api/goto/')
|
||||||
@app.route('/api/goto/<location>')
|
@app.route('/api/goto/<location>')
|
||||||
def api_goto(location='home'):
|
def goto(location='home'):
|
||||||
if location not in pages:
|
|
||||||
flask.abort(404)
|
|
||||||
pagevars = pages[location]
|
pagevars = pages[location]
|
||||||
|
page = None
|
||||||
try:
|
try:
|
||||||
page = flask.render_template(pagevars["template"], var=pagevars)
|
page = flask.render_template(pagevars["template"], var=pagevars)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
page = render_error(500, "Internal Server Error")
|
# raise e
|
||||||
|
e = HTTPerror.InternalServerError(None, e)
|
||||||
|
page = page404(e)
|
||||||
return [pagevars, page]
|
return [pagevars, page]
|
||||||
|
|
||||||
|
def funcGen(pagename, pages):
|
||||||
# ── Dynamic page routes ──────────────────────────────────────────────
|
def dynamicRule():
|
||||||
|
|
||||||
def make_page_handler(pagename):
|
|
||||||
def handler():
|
|
||||||
try:
|
try:
|
||||||
return flask.render_template('header.html', var=pages[pagename])
|
return flask.render_template('header.html', var=pages[pagename])
|
||||||
except Exception:
|
except Exception:
|
||||||
return render_error(500, "Internal Server Error")
|
e = HTTPerror.InternalServerError()
|
||||||
return handler
|
return page404(e)
|
||||||
|
return dynamicRule
|
||||||
|
|
||||||
|
for i in pages:
|
||||||
|
func = funcGen(i, pages)
|
||||||
|
app.add_url_rule(pages[i]['canonical'], i, func)
|
||||||
|
|
||||||
|
|
||||||
for name in pages:
|
# for i in pages:
|
||||||
app.add_url_rule(pages[name]['canonical'], name, make_page_handler(name))
|
# exec(f"@app.route(pages['{i}']['canonical'])\ndef {i}(): return flask.render_template('header.html', var=pages['{i}'])")
|
||||||
|
|
||||||
|
@app.route("/huge")
|
||||||
# ── Static file routes ───────────────────────────────────────────────
|
def huge():
|
||||||
|
return flask.render_template('huge.html')
|
||||||
|
|
||||||
@app.route("/resume")
|
@app.route("/resume")
|
||||||
@app.route("/Resume.pdf")
|
@app.route("/Resume.pdf")
|
||||||
@app.route("/Resume_Simonson_Andrew.pdf")
|
|
||||||
def resume():
|
def resume():
|
||||||
return flask.send_file("./static/Resume_Simonson_Andrew.pdf")
|
return flask.send_file("./static/Resume.pdf")
|
||||||
|
|
||||||
|
@app.route("/hotspots")
|
||||||
|
def hotspotsRIT():
|
||||||
|
url = HotspotsURL
|
||||||
|
if flask.request.args.get("legend") == "false":
|
||||||
|
url += "?legend=false"
|
||||||
|
pagevars = {
|
||||||
|
"template": "iframe.html",
|
||||||
|
"title": f"Hotspots @ RIT",
|
||||||
|
"description": "Hotspots @ RIT by Andrew Simonson",
|
||||||
|
"canonical": "/hotspots",
|
||||||
|
}
|
||||||
|
return flask.render_template("iframe.html", url=url, var=pagevars)
|
||||||
|
|
||||||
|
@app.route("/hotspots/<path>")
|
||||||
|
def hotspotsProxy(path):
|
||||||
|
return requests.get(f"{HotspotsURL}/{path}").content
|
||||||
|
|
||||||
|
@app.errorhandler(Exception)
|
||||||
|
def page404(e):
|
||||||
|
eCode = e.code
|
||||||
|
message = e.description
|
||||||
|
try:
|
||||||
|
message = e.length
|
||||||
|
finally:
|
||||||
|
pagevars = {
|
||||||
|
"template": "error.html",
|
||||||
|
"title": f"{eCode} - Simonson",
|
||||||
|
"description": "Error on Andrew Simonson's Digital Portfolio",
|
||||||
|
"canonical": "404",
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
flask.render_template(
|
||||||
|
"header.html",
|
||||||
|
var=pagevars,
|
||||||
|
error=eCode,
|
||||||
|
message=message,
|
||||||
|
title=f"{eCode} - Simonson Portfolio",
|
||||||
|
),
|
||||||
|
eCode,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/sitemap.xml")
|
@app.route("/sitemap.xml")
|
||||||
@@ -174,10 +105,10 @@ def static_from_root():
|
|||||||
return flask.send_from_directory(app.static_folder, flask.request.path[1:])
|
return flask.send_from_directory(app.static_folder, flask.request.path[1:])
|
||||||
|
|
||||||
|
|
||||||
# ── Startup ───────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=False)
|
# import sass
|
||||||
|
|
||||||
|
# sass.compile(dirname=("static/scss", "static/css"), output_style="compressed")
|
||||||
|
app.run()
|
||||||
else:
|
else:
|
||||||
Minify(app=app, html=True, js=True, cssless=True)
|
Minify(app=app, html=True, js=True, cssless=True)
|
||||||
monitor.start_monitoring()
|
|
||||||
|
|||||||
4
src/config.py
Executable file → Normal file
@@ -1,6 +1,8 @@
|
|||||||
from os import environ as env
|
from os import environ as env
|
||||||
# automatically updates some dev envs. need to remove for production.
|
# automatically updates some dev envs. need to remove for production.
|
||||||
try:
|
try:
|
||||||
__import__('envs')
|
__import__('envs.py')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
HotspotsURL = env.get('HotspotsURL', 'https://asimonson.com/hotspots')
|
||||||
406
src/monitor.py
@@ -1,406 +0,0 @@
|
|||||||
"""
|
|
||||||
Service monitoring module.
|
|
||||||
Checks service availability and tracks uptime statistics in PostgreSQL.
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from threading import Thread, Lock
|
|
||||||
|
|
||||||
import psycopg2
|
|
||||||
import requests
|
|
||||||
|
|
||||||
SERVICES = [
|
|
||||||
{'id': 'main', 'name': 'asimonson.com', 'url': 'https://asimonson.com', 'timeout': 10},
|
|
||||||
# {'id': 'EternalRelays', 'name': 'eternalrelays.com', 'url': 'https://eternalrelays.com', 'timeout': 10},
|
|
||||||
{'id': 'files', 'name': 'files.asimonson.com', 'url': 'https://files.asimonson.com', 'timeout': 10},
|
|
||||||
{'id': 'git', 'name': 'git.asimonson.com', 'url': 'https://git.asimonson.com', 'timeout': 10},
|
|
||||||
# {'id': 'cascadalyst', 'name': 'cascadalyst.com', 'url': 'https://cascadalyst.com', 'timeout': 10},
|
|
||||||
]
|
|
||||||
|
|
||||||
CHECK_INTERVAL = 60 # seconds between checks
|
|
||||||
RETENTION_DAYS = 90 # how long to keep records
|
|
||||||
CLEANUP_INTERVAL = 86400 # seconds between purge runs
|
|
||||||
STALE_AFTER = CHECK_INTERVAL * 5 # flag cached data as stale if no check has landed in this long
|
|
||||||
|
|
||||||
DATABASE_URL = os.environ.get('DATABASE_URL')
|
|
||||||
|
|
||||||
# Expected columns (besides id) -- name: SQL type
|
|
||||||
_EXPECTED_COLUMNS = {
|
|
||||||
'service_id': 'VARCHAR(50) NOT NULL',
|
|
||||||
'timestamp': 'TIMESTAMPTZ NOT NULL DEFAULT NOW()',
|
|
||||||
'status': 'VARCHAR(20) NOT NULL',
|
|
||||||
'response_time': 'INTEGER',
|
|
||||||
'status_code': 'INTEGER',
|
|
||||||
'error': 'TEXT',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceMonitor:
|
|
||||||
def __init__(self):
|
|
||||||
self.lock = Lock()
|
|
||||||
self._current = {
|
|
||||||
svc['id']: {
|
|
||||||
'name': svc['name'],
|
|
||||||
'url': svc['url'],
|
|
||||||
'status': 'unknown',
|
|
||||||
'response_time': None,
|
|
||||||
'status_code': None,
|
|
||||||
'last_online': None,
|
|
||||||
}
|
|
||||||
for svc in SERVICES
|
|
||||||
}
|
|
||||||
self._last_check = None
|
|
||||||
# Cheap placeholder (no DB access) until the first check_all_services()
|
|
||||||
# run replaces it with the real, uptime-backed summary.
|
|
||||||
self._cached_summary = {
|
|
||||||
'last_check': None,
|
|
||||||
'next_check': None,
|
|
||||||
'services': [
|
|
||||||
{
|
|
||||||
'id': service_id,
|
|
||||||
'name': cached['name'],
|
|
||||||
'url': cached['url'],
|
|
||||||
'status': cached['status'],
|
|
||||||
'response_time': cached['response_time'],
|
|
||||||
'status_code': cached['status_code'],
|
|
||||||
'last_online': cached['last_online'],
|
|
||||||
'uptime': {'24h': None, '7d': None, '30d': None, 'all_time': None},
|
|
||||||
'total_checks': 0,
|
|
||||||
}
|
|
||||||
for service_id, cached in self._current.items()
|
|
||||||
],
|
|
||||||
}
|
|
||||||
self._ensure_schema()
|
|
||||||
|
|
||||||
# ── Database helpers ──────────────────────────────────────────
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _get_conn():
|
|
||||||
"""Return a new psycopg2 connection, or None if DATABASE_URL is unset."""
|
|
||||||
if not DATABASE_URL:
|
|
||||||
return None
|
|
||||||
return psycopg2.connect(DATABASE_URL)
|
|
||||||
|
|
||||||
def _ensure_schema(self):
|
|
||||||
"""Create or migrate the service_checks table to match _EXPECTED_COLUMNS."""
|
|
||||||
if not DATABASE_URL:
|
|
||||||
print("DATABASE_URL not set -- running without persistence")
|
|
||||||
return
|
|
||||||
|
|
||||||
conn = None
|
|
||||||
for attempt in range(5):
|
|
||||||
try:
|
|
||||||
conn = psycopg2.connect(DATABASE_URL)
|
|
||||||
break
|
|
||||||
except psycopg2.OperationalError:
|
|
||||||
if attempt < 4:
|
|
||||||
print(f"Database not ready, retrying in 2s (attempt {attempt + 1}/5)...")
|
|
||||||
time.sleep(2)
|
|
||||||
else:
|
|
||||||
print("Could not connect to database -- running without persistence")
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
with conn, conn.cursor() as cur:
|
|
||||||
cur.execute("""
|
|
||||||
CREATE TABLE IF NOT EXISTS service_checks (
|
|
||||||
id SERIAL PRIMARY KEY,
|
|
||||||
service_id VARCHAR(50) NOT NULL,
|
|
||||||
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
||||||
status VARCHAR(20) NOT NULL,
|
|
||||||
response_time INTEGER,
|
|
||||||
status_code INTEGER,
|
|
||||||
error TEXT
|
|
||||||
);
|
|
||||||
""")
|
|
||||||
cur.execute("""
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_service_checks_service_timestamp
|
|
||||||
ON service_checks (service_id, timestamp DESC);
|
|
||||||
""")
|
|
||||||
|
|
||||||
# Introspect existing columns
|
|
||||||
cur.execute("""
|
|
||||||
SELECT column_name
|
|
||||||
FROM information_schema.columns
|
|
||||||
WHERE table_name = 'service_checks'
|
|
||||||
""")
|
|
||||||
existing = {row[0] for row in cur.fetchall()}
|
|
||||||
|
|
||||||
for col, col_type in _EXPECTED_COLUMNS.items():
|
|
||||||
if col not in existing:
|
|
||||||
bare_type = col_type.split('NOT NULL')[0].split('DEFAULT')[0].strip()
|
|
||||||
cur.execute(f'ALTER TABLE service_checks ADD COLUMN {col} {bare_type}')
|
|
||||||
print(f"Added column {col} to service_checks")
|
|
||||||
|
|
||||||
expected_names = set(_EXPECTED_COLUMNS) | {'id'}
|
|
||||||
for col in existing - expected_names:
|
|
||||||
cur.execute(f'ALTER TABLE service_checks DROP COLUMN {col}')
|
|
||||||
print(f"Dropped column {col} from service_checks")
|
|
||||||
|
|
||||||
print("Database schema OK")
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def _insert_check(self, service_id, result):
|
|
||||||
"""Persist a single check result to the database."""
|
|
||||||
conn = self._get_conn()
|
|
||||||
if conn is None:
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
with conn, conn.cursor() as cur:
|
|
||||||
cur.execute(
|
|
||||||
"""INSERT INTO service_checks
|
|
||||||
(service_id, timestamp, status, response_time, status_code, error)
|
|
||||||
VALUES (%s, %s, %s, %s, %s, %s)""",
|
|
||||||
(
|
|
||||||
service_id,
|
|
||||||
result['timestamp'],
|
|
||||||
result['status'],
|
|
||||||
result.get('response_time'),
|
|
||||||
result.get('status_code'),
|
|
||||||
result.get('error'),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
# ── Service checks ────────────────────────────────────────────
|
|
||||||
|
|
||||||
def check_service(self, service):
|
|
||||||
"""Perform an HTTP HEAD against a service and return a status dict."""
|
|
||||||
start_time = time.time()
|
|
||||||
result = {
|
|
||||||
'timestamp': datetime.now().isoformat(),
|
|
||||||
'status': 'offline',
|
|
||||||
'response_time': None,
|
|
||||||
'status_code': None,
|
|
||||||
}
|
|
||||||
|
|
||||||
try:
|
|
||||||
response = requests.head(
|
|
||||||
service['url'],
|
|
||||||
timeout=service['timeout'],
|
|
||||||
allow_redirects=True,
|
|
||||||
)
|
|
||||||
result['response_time'] = int((time.time() - start_time) * 1000)
|
|
||||||
result['status_code'] = response.status_code
|
|
||||||
|
|
||||||
if response.status_code < 500:
|
|
||||||
result['status'] = 'online'
|
|
||||||
else:
|
|
||||||
result['status'] = 'degraded'
|
|
||||||
|
|
||||||
except requests.exceptions.Timeout:
|
|
||||||
result['status'] = 'timeout'
|
|
||||||
result['response_time'] = service['timeout'] * 1000
|
|
||||||
except Exception as e:
|
|
||||||
result['status'] = 'offline'
|
|
||||||
result['error'] = str(e)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def check_all_services(self):
|
|
||||||
"""Check every service concurrently, persist results, and update cache."""
|
|
||||||
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Checking all services...")
|
|
||||||
|
|
||||||
results = {}
|
|
||||||
with ThreadPoolExecutor(max_workers=len(SERVICES)) as executor:
|
|
||||||
futures = {executor.submit(self.check_service, s): s for s in SERVICES}
|
|
||||||
for future in futures:
|
|
||||||
service = futures[future]
|
|
||||||
result = future.result()
|
|
||||||
results[service['id']] = result
|
|
||||||
print(f" {service['name']}: {result['status']} ({result['response_time']}ms)")
|
|
||||||
|
|
||||||
for service_id, result in results.items():
|
|
||||||
self._insert_check(service_id, result)
|
|
||||||
|
|
||||||
with self.lock:
|
|
||||||
for service in SERVICES:
|
|
||||||
result = results[service['id']]
|
|
||||||
cached = self._current[service['id']]
|
|
||||||
cached['status'] = result['status']
|
|
||||||
cached['response_time'] = result['response_time']
|
|
||||||
cached['status_code'] = result['status_code']
|
|
||||||
if result['status'] == 'online':
|
|
||||||
cached['last_online'] = result['timestamp']
|
|
||||||
self._last_check = datetime.now().isoformat()
|
|
||||||
self._cached_summary = self._build_summary_locked()
|
|
||||||
|
|
||||||
# ── Uptime calculations ───────────────────────────────────────
|
|
||||||
|
|
||||||
def _calculate_uptime(self, service_id, hours=None):
|
|
||||||
"""Return uptime percentage for a service, or None if insufficient data."""
|
|
||||||
conn = self._get_conn()
|
|
||||||
if conn is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
|
||||||
with conn.cursor() as cur:
|
|
||||||
if hours:
|
|
||||||
cutoff = datetime.now() - timedelta(hours=hours)
|
|
||||||
cur.execute(
|
|
||||||
"""SELECT
|
|
||||||
COUNT(*) FILTER (WHERE status = 'online'),
|
|
||||||
COUNT(*)
|
|
||||||
FROM service_checks
|
|
||||||
WHERE service_id = %s AND timestamp > %s""",
|
|
||||||
(service_id, cutoff),
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
cur.execute(
|
|
||||||
"""SELECT
|
|
||||||
COUNT(*) FILTER (WHERE status = 'online'),
|
|
||||||
COUNT(*)
|
|
||||||
FROM service_checks
|
|
||||||
WHERE service_id = %s""",
|
|
||||||
(service_id,),
|
|
||||||
)
|
|
||||||
|
|
||||||
online_count, total_count = cur.fetchone()
|
|
||||||
if total_count == 0:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Only report a time-windowed uptime if data exists beyond the window
|
|
||||||
if hours:
|
|
||||||
cur.execute(
|
|
||||||
'SELECT EXISTS(SELECT 1 FROM service_checks WHERE service_id = %s AND timestamp <= %s)',
|
|
||||||
(service_id, cutoff),
|
|
||||||
)
|
|
||||||
if not cur.fetchone()[0]:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return round((online_count / total_count) * 100, 3)
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def _get_total_checks(self, service_id):
|
|
||||||
"""Return the total number of recorded checks for a service."""
|
|
||||||
conn = self._get_conn()
|
|
||||||
if conn is None:
|
|
||||||
return 0
|
|
||||||
try:
|
|
||||||
with conn.cursor() as cur:
|
|
||||||
cur.execute(
|
|
||||||
'SELECT COUNT(*) FROM service_checks WHERE service_id = %s',
|
|
||||||
(service_id,),
|
|
||||||
)
|
|
||||||
return cur.fetchone()[0]
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
# ── Status summary ────────────────────────────────────────────
|
|
||||||
|
|
||||||
def _build_summary_locked(self):
|
|
||||||
"""Build a JSON-serializable status summary with uptime statistics.
|
|
||||||
|
|
||||||
Hits the database (multiple queries per service) -- only call this
|
|
||||||
from within check_all_services() while self.lock is held, so it runs
|
|
||||||
once per check cycle rather than once per /api/status request.
|
|
||||||
"""
|
|
||||||
summary = {
|
|
||||||
'last_check': self._last_check,
|
|
||||||
'next_check': None,
|
|
||||||
'services': [],
|
|
||||||
}
|
|
||||||
|
|
||||||
if self._last_check:
|
|
||||||
last_check = datetime.fromisoformat(self._last_check)
|
|
||||||
summary['next_check'] = (last_check + timedelta(seconds=CHECK_INTERVAL)).isoformat()
|
|
||||||
|
|
||||||
for service_id, cached in self._current.items():
|
|
||||||
summary['services'].append({
|
|
||||||
'id': service_id,
|
|
||||||
'name': cached['name'],
|
|
||||||
'url': cached['url'],
|
|
||||||
'status': cached['status'],
|
|
||||||
'response_time': cached['response_time'],
|
|
||||||
'status_code': cached['status_code'],
|
|
||||||
'last_online': cached['last_online'],
|
|
||||||
'uptime': {
|
|
||||||
'24h': self._calculate_uptime(service_id, 24),
|
|
||||||
'7d': self._calculate_uptime(service_id, 24 * 7),
|
|
||||||
'30d': self._calculate_uptime(service_id, 24 * 30),
|
|
||||||
'all_time': self._calculate_uptime(service_id),
|
|
||||||
},
|
|
||||||
'total_checks': self._get_total_checks(service_id),
|
|
||||||
})
|
|
||||||
|
|
||||||
return summary
|
|
||||||
|
|
||||||
def get_status_summary(self):
|
|
||||||
"""Return the cached status summary, refreshed once per check cycle
|
|
||||||
(see check_all_services), so this never itself touches the database.
|
|
||||||
|
|
||||||
Adds a `stale` flag computed against wall-clock time, since a summary
|
|
||||||
that stops updating (e.g. the monitor loop hit a persistent error) would
|
|
||||||
otherwise keep reporting its last-known last_check as if it were fresh.
|
|
||||||
"""
|
|
||||||
with self.lock:
|
|
||||||
summary = dict(self._cached_summary)
|
|
||||||
|
|
||||||
stale = False
|
|
||||||
if summary.get('last_check'):
|
|
||||||
age = (datetime.now() - datetime.fromisoformat(summary['last_check'])).total_seconds()
|
|
||||||
stale = age > STALE_AFTER
|
|
||||||
summary['stale'] = stale
|
|
||||||
return summary
|
|
||||||
|
|
||||||
# ── Background loop ───────────────────────────────────────────
|
|
||||||
|
|
||||||
def _purge_old_records(self):
|
|
||||||
"""Delete check records older than RETENTION_DAYS."""
|
|
||||||
conn = self._get_conn()
|
|
||||||
if conn is None:
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
cutoff = datetime.now() - timedelta(days=RETENTION_DAYS)
|
|
||||||
with conn, conn.cursor() as cur:
|
|
||||||
cur.execute('DELETE FROM service_checks WHERE timestamp < %s', (cutoff,))
|
|
||||||
deleted = cur.rowcount
|
|
||||||
if deleted:
|
|
||||||
print(f"Purged {deleted} records older than {RETENTION_DAYS} days")
|
|
||||||
finally:
|
|
||||||
conn.close()
|
|
||||||
|
|
||||||
def _run_check_cycle(self):
|
|
||||||
"""Run one check_all_services() call, catching any exception so a
|
|
||||||
transient failure (DB hiccup, network blip) can't kill the daemon
|
|
||||||
thread -- without this, the thread dies silently and /api/status
|
|
||||||
keeps serving an ever-staler cached summary with nothing to say so."""
|
|
||||||
try:
|
|
||||||
self.check_all_services()
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[monitor] check cycle failed, will retry next interval: {e}")
|
|
||||||
|
|
||||||
def _run_cleanup(self):
|
|
||||||
try:
|
|
||||||
self._purge_old_records()
|
|
||||||
except Exception as e:
|
|
||||||
print(f"[monitor] cleanup failed, will retry next interval: {e}")
|
|
||||||
|
|
||||||
def start_monitoring(self):
|
|
||||||
"""Start the background daemon thread for periodic checks and cleanup."""
|
|
||||||
def monitor_loop():
|
|
||||||
self._run_check_cycle()
|
|
||||||
self._run_cleanup()
|
|
||||||
|
|
||||||
checks_since_cleanup = 0
|
|
||||||
checks_per_cleanup = CLEANUP_INTERVAL // CHECK_INTERVAL
|
|
||||||
|
|
||||||
while True:
|
|
||||||
time.sleep(CHECK_INTERVAL)
|
|
||||||
self._run_check_cycle()
|
|
||||||
checks_since_cleanup += 1
|
|
||||||
if checks_since_cleanup >= checks_per_cleanup:
|
|
||||||
self._run_cleanup()
|
|
||||||
checks_since_cleanup = 0
|
|
||||||
|
|
||||||
thread = Thread(target=monitor_loop, daemon=True)
|
|
||||||
thread.start()
|
|
||||||
print(f"Service monitoring started (checks every {CHECK_INTERVAL}s)")
|
|
||||||
|
|
||||||
|
|
||||||
monitor = ServiceMonitor()
|
|
||||||
@@ -1,22 +1,43 @@
|
|||||||
blinker==1.9.0
|
bidict==0.22.1
|
||||||
certifi==2026.5.20
|
black==22.12.0
|
||||||
charset-normalizer==3.4.7
|
blinker==1.5
|
||||||
click==8.4.1
|
certifi==2023.7.22
|
||||||
Flask==3.1.3
|
cffi==1.15.1
|
||||||
Flask-Minify==0.50
|
charset-normalizer==3.3.1
|
||||||
gunicorn==26.0.0
|
click==8.1.3
|
||||||
idna==3.16
|
colorama==0.4.6
|
||||||
itsdangerous==2.2.0
|
Flask==2.2.2
|
||||||
Jinja2==3.1.6
|
Flask-Minify==0.41
|
||||||
|
Flask-SocketIO==5.3.2
|
||||||
|
gevent==22.10.2
|
||||||
|
gevent-websocket==0.10.1
|
||||||
|
greenlet==2.0.2
|
||||||
|
gunicorn==20.1.0
|
||||||
|
htmlmin==0.1.12
|
||||||
|
idna==3.4
|
||||||
|
importlib-metadata==6.0.0
|
||||||
|
itsdangerous==2.1.2
|
||||||
|
Jinja2==3.1.2
|
||||||
jsmin==3.0.1
|
jsmin==3.0.1
|
||||||
lesscpy==0.15.1
|
lesscpy==0.15.1
|
||||||
MarkupSafe==3.0.3
|
libsass==0.22.0
|
||||||
packaging==26.2
|
MarkupSafe==2.1.2
|
||||||
|
mypy-extensions==0.4.3
|
||||||
|
pathspec==0.11.0
|
||||||
|
platformdirs==2.6.2
|
||||||
ply==3.11
|
ply==3.11
|
||||||
psycopg2-binary==2.9.12
|
pycparser==2.21
|
||||||
rcssmin==1.2.2
|
pyScss==1.4.0
|
||||||
requests==2.34.2
|
python-engineio==4.3.4
|
||||||
six==1.17.0
|
python-socketio==5.7.2
|
||||||
urllib3==2.7.0
|
rcssmin==1.1.1
|
||||||
Werkzeug==3.1.8
|
requests==2.31.0
|
||||||
xxhash==3.7.0
|
six==1.16.0
|
||||||
|
tomli==2.0.1
|
||||||
|
typing_extensions==4.4.0
|
||||||
|
urllib3==2.0.7
|
||||||
|
Werkzeug==2.2.2
|
||||||
|
xxhash==3.2.0
|
||||||
|
zipp==3.11.0
|
||||||
|
zope.event==4.6
|
||||||
|
zope.interface==5.5.2
|
||||||
|
|||||||
BIN
src/static/Resume.pdf
Normal file
0
src/static/chesscom-embed/default.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
src/static/chesscom-embed/diamonds.png
Executable file → Normal file
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
2209
src/static/css/App.css
Executable file → Normal file
70
src/static/css/checkbox.css
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hiddenup {
|
||||||
|
max-height: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper > div {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper > div:last-child {
|
||||||
|
margin-bottom: 0;;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper .switch {
|
||||||
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper .switch > * {
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper .switch input {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.checkbox-wrapper .slider {
|
||||||
|
background-color: #ccc;
|
||||||
|
transition: 0.4s;
|
||||||
|
height: 34px;
|
||||||
|
width: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper .slider:before {
|
||||||
|
background-color: #fff;
|
||||||
|
bottom: 4px;
|
||||||
|
content: "";
|
||||||
|
height: 26px;
|
||||||
|
left: 4px;
|
||||||
|
position: absolute;
|
||||||
|
transition: 0.4s;
|
||||||
|
width: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper input:checked+.slider {
|
||||||
|
background-color: #66bb6a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper input:checked+.slider:before {
|
||||||
|
transform: translateX(26px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper .slider.round {
|
||||||
|
border-radius: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper .slider.round:before {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-wrapper strong {
|
||||||
|
margin-left: .5em;
|
||||||
|
}
|
||||||
0
src/static/css/head.css
Executable file → Normal file
0
src/static/favicon.ico
Executable file → Normal file
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 97 KiB |
0
src/static/fonts/NeonFuture.ttf
Executable file → Normal file
0
src/static/fonts/RobotoCondensed-Regular.ttf
Executable file → Normal file
0
src/static/fonts/SHUTTLE-X.ttf
Executable file → Normal file
0
src/static/fonts/SunsetClub.otf
Executable file → Normal file
0
src/static/icons/email.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
0
src/static/icons/github.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 759 B After Width: | Height: | Size: 759 B |
0
src/static/icons/globe.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
0
src/static/icons/instagram.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 683 B After Width: | Height: | Size: 683 B |
0
src/static/icons/linkedin.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
0
src/static/icons/log.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 177 KiB |
0
src/static/icons/menu.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 764 B After Width: | Height: | Size: 764 B |
|
Before Width: | Height: | Size: 9.5 KiB |
448
src/static/icons/neonfinal3.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 16 KiB |
0
src/static/icons/rasterLogo.png
Executable file → Normal file
|
Before Width: | Height: | Size: 382 KiB After Width: | Height: | Size: 382 KiB |
0
src/static/icons/rasterLogoCircle.png
Executable file → Normal file
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 213 KiB |
448
src/static/icons/withBackground.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 16 KiB |
41
src/static/js/checkbox.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
function toggleCheckbox(dir) {
|
||||||
|
let toggles = document.querySelectorAll(
|
||||||
|
".checkbox-wrapper input[type=checkbox]"
|
||||||
|
);
|
||||||
|
let allow = [];
|
||||||
|
toggles.forEach(function (x) {
|
||||||
|
if (x.checked) {
|
||||||
|
allow.push(x.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let list = document.querySelectorAll(".checkbox-client > div");
|
||||||
|
if (allow.length === 0) {
|
||||||
|
for (let i = 0; i < list.length; i++) {
|
||||||
|
list[i].classList.remove("hidden" + dir);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < list.length; i++) {
|
||||||
|
list[i].classList.remove("hidden" + dir);
|
||||||
|
for (let x = 0; x < allow.length; x++) {
|
||||||
|
if (!list[i].classList.contains(allow[x])) {
|
||||||
|
list[i].classList.add("hidden" + dir);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function activeSkill(obj) {
|
||||||
|
if (obj.parentElement.classList.contains("activeSkill")) {
|
||||||
|
obj.parentElement.classList.remove("activeSkill");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// document.querySelectorAll(".skill").forEach((x) => {
|
||||||
|
// x.classList.remove("activeSkill");
|
||||||
|
// });
|
||||||
|
while (obj.parentElement.classList.contains("skill")) {
|
||||||
|
obj = obj.parentElement;
|
||||||
|
obj.classList.add("activeSkill");
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/static/js/chessbed.js
Executable file → Normal file
@@ -7,21 +7,17 @@ async function addChessEmbed(username) {
|
|||||||
setChess({ cName: "Chess.com request failed" });
|
setChess({ cName: "Chess.com request failed" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.status === 200) {
|
if (user.status === 200) {
|
||||||
user = await user.json();
|
user = await user.json();
|
||||||
stats = await stats.json();
|
stats = await stats.json();
|
||||||
setChess({
|
ratings = {
|
||||||
cName: user["username"],
|
rapid: stats.chess_rapid.last.rating,
|
||||||
pic: user.avatar,
|
blitz: stats.chess_blitz.last.rating,
|
||||||
ratings: {
|
bullet: stats.chess_bullet.last.rating,
|
||||||
rapid: stats.chess_rapid.last.rating,
|
tactics: stats.tactics.highest.rating,
|
||||||
blitz: stats.chess_blitz.last.rating,
|
};
|
||||||
bullet: stats.chess_bullet.last.rating,
|
setChess({ cName: user["username"], pic: user.avatar, ratings: ratings });
|
||||||
tactics: stats.tactics.highest.rating,
|
} else if (user === null || user.status === 403 || user.status === null) {
|
||||||
},
|
|
||||||
});
|
|
||||||
} else if (user.status === 403) {
|
|
||||||
setChess({ cName: "Chess.com request failed" });
|
setChess({ cName: "Chess.com request failed" });
|
||||||
} else {
|
} else {
|
||||||
setChess({ cName: "User Not Found" });
|
setChess({ cName: "User Not Found" });
|
||||||
@@ -37,12 +33,16 @@ function setChess({ cName = null, pic = null, ratings = null }) {
|
|||||||
document.querySelector(".chessImage").src = pic;
|
document.querySelector(".chessImage").src = pic;
|
||||||
}
|
}
|
||||||
if (ratings) {
|
if (ratings) {
|
||||||
document.querySelector(".chessRapid .chessStat").textContent = ratings.rapid;
|
document.querySelector(".chessRapid .chessStat").textContent =
|
||||||
document.querySelector(".chessBlitz .chessStat").textContent = ratings.blitz;
|
ratings.rapid;
|
||||||
document.querySelector(".chessBullet .chessStat").textContent = ratings.bullet;
|
document.querySelector(".chessBlitz .chessStat").textContent =
|
||||||
document.querySelector(".chessPuzzles .chessStat").textContent = ratings.tactics;
|
ratings.blitz;
|
||||||
|
document.querySelector(".chessBullet .chessStat").textContent =
|
||||||
|
ratings.bullet;
|
||||||
|
document.querySelector(".chessPuzzles .chessStat").textContent =
|
||||||
|
ratings.tactics;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
console.warn("Chess DOM elements not available (navigated away during fetch)");
|
console.log("fucker clicking so fast the internet can't even keep up");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
577
src/static/js/idler.js
Executable file → Normal file
@@ -1,521 +1,92 @@
|
|||||||
/**
|
const balls = [];
|
||||||
* Ambient background: "Contour Field"
|
const density = 0.00003;
|
||||||
*
|
let screenWidth = window.innerWidth + 10;
|
||||||
* Thin nested contour lines trace level curves of one continuous,
|
let screenHeight = window.innerHeight + 10;
|
||||||
* slowly-drifting 2D value-noise surface, marched with a classic
|
|
||||||
* marching-squares pass on a coarse grid. Every line on screen is a
|
|
||||||
* cross-section of the SAME field at a fixed elevation, so neighboring
|
|
||||||
* contours are geometrically correlated (they nest, they never cross,
|
|
||||||
* they bulge and pinch together) -- it reads as one continuous terrain
|
|
||||||
* rather than a scatter of independent strokes. Nods to the site
|
|
||||||
* owner's geospatial / data-surface work (watershed + elevation
|
|
||||||
* surfaces) without being literal about it.
|
|
||||||
*/
|
|
||||||
(function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var container = document.getElementById("bg");
|
class Ball {
|
||||||
if (!container) return;
|
constructor(x, y, size, speed, angle) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.size = size;
|
||||||
|
this.speed = speed;
|
||||||
|
this.angle = angle;
|
||||||
|
this.calcChange();
|
||||||
|
}
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
calcChange() {
|
||||||
canvas.setAttribute("aria-hidden", "true");
|
this.xSpeed = this.speed * Math.sin((this.angle * Math.PI) / 180);
|
||||||
container.appendChild(canvas);
|
this.ySpeed = this.speed * Math.cos((this.angle * Math.PI) / 180);
|
||||||
var ctx = canvas.getContext("2d");
|
}
|
||||||
if (!ctx) return;
|
|
||||||
|
|
||||||
var reduceMotion =
|
update() {
|
||||||
window.matchMedia &&
|
this.x += this.xSpeed;
|
||||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
this.y += this.ySpeed;
|
||||||
|
if (this.x > screenWidth) {
|
||||||
// ---------------------------------------------------------------
|
this.x -= screenWidth;
|
||||||
// Value noise (hash lattice + smooth interpolation), no dependency.
|
} else if (this.x < 0) {
|
||||||
// ---------------------------------------------------------------
|
this.x += screenWidth;
|
||||||
var PERM_SIZE = 256;
|
|
||||||
var PERM_MASK = PERM_SIZE - 1;
|
|
||||||
var perm = new Uint8Array(PERM_SIZE);
|
|
||||||
(function buildPermutation() {
|
|
||||||
var table = new Uint8Array(PERM_SIZE);
|
|
||||||
for (var i = 0; i < PERM_SIZE; i++) table[i] = i;
|
|
||||||
for (var j = PERM_SIZE - 1; j > 0; j--) {
|
|
||||||
var k = (Math.random() * (j + 1)) | 0;
|
|
||||||
var tmp = table[j];
|
|
||||||
table[j] = table[k];
|
|
||||||
table[k] = tmp;
|
|
||||||
}
|
}
|
||||||
perm.set(table);
|
if (this.y > screenHeight) {
|
||||||
})();
|
this.y -= screenHeight;
|
||||||
|
} else if (this.y < 0) {
|
||||||
function lattice(ix, iy) {
|
this.y += screenHeight;
|
||||||
var a = perm[ix & PERM_MASK];
|
}
|
||||||
return perm[(a + iy) & PERM_MASK] / 255;
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
function fade(t) {
|
draw() {
|
||||||
return t * t * t * (t * (t * 6 - 15) + 10);
|
stroke(200, 100);
|
||||||
|
strokeWeight(2);
|
||||||
|
fill(0);
|
||||||
|
ellipse(this.x, this.y, this.size, this.size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function noise2D(x, y) {
|
function setup() {
|
||||||
var xi = Math.floor(x);
|
frameRate(15);
|
||||||
var yi = Math.floor(y);
|
const pix = screenHeight * screenWidth;
|
||||||
var xf = x - xi;
|
createCanvas(screenWidth, screenHeight);
|
||||||
var yf = y - yi;
|
for (let i = 0; i < pix * density; i++) {
|
||||||
var u = fade(xf);
|
let thisBall = new Ball(
|
||||||
var v = fade(yf);
|
random(screenWidth),
|
||||||
var n00 = lattice(xi, yi);
|
random(screenHeight),
|
||||||
var n10 = lattice(xi + 1, yi);
|
random(6) + 3,
|
||||||
var n01 = lattice(xi, yi + 1);
|
Math.exp(random(4) + 3) / 1000 + 1,
|
||||||
var n11 = lattice(xi + 1, yi + 1);
|
random(360)
|
||||||
var nx0 = n00 + (n10 - n00) * u;
|
|
||||||
var nx1 = n01 + (n11 - n01) * u;
|
|
||||||
return nx0 + (nx1 - nx0) * v;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Two-octave fractal sum, warped slightly so the field folds and
|
|
||||||
// breathes rather than just sliding sideways.
|
|
||||||
var FREQ_1 = 1 / 460; // px per full noise cycle, octave 1
|
|
||||||
var FREQ_2 = FREQ_1 * 2.3; // octave 2
|
|
||||||
function fieldValue(x, y, driftX, driftY, warpX, warpY) {
|
|
||||||
var n1 = noise2D((x + driftX) * FREQ_1, (y + driftY) * FREQ_1);
|
|
||||||
var n2 = noise2D(
|
|
||||||
(x + driftX + warpX) * FREQ_2,
|
|
||||||
(y + driftY + warpY) * FREQ_2
|
|
||||||
);
|
);
|
||||||
var fbm = n1 * 0.68 + n2 * 0.32; // ~[0,1]
|
balls.push(thisBall);
|
||||||
return fbm * 2 - 1; // ~[-1,1], centered
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
stroke(255);
|
||||||
// Marching squares
|
}
|
||||||
// Corner bit order: v0=top-left, v1=top-right, v2=bottom-right, v3=bottom-left
|
|
||||||
// Edge order: 0=top, 1=right, 2=bottom, 3=left
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
var CASE_EDGES = [
|
|
||||||
null, // 0
|
|
||||||
[0, 3], // 1
|
|
||||||
[0, 1], // 2
|
|
||||||
[1, 3], // 3
|
|
||||||
[1, 2], // 4
|
|
||||||
[0, 3, 1, 2], // 5 (saddle, two segments)
|
|
||||||
[0, 2], // 6
|
|
||||||
[2, 3], // 7
|
|
||||||
[2, 3], // 8
|
|
||||||
[0, 2], // 9
|
|
||||||
[0, 1, 2, 3], // 10 (saddle, two segments)
|
|
||||||
[1, 2], // 11
|
|
||||||
[1, 3], // 12
|
|
||||||
[0, 1], // 13
|
|
||||||
[0, 3], // 14
|
|
||||||
null, // 15
|
|
||||||
];
|
|
||||||
|
|
||||||
function edgePoint(edge, x, y, cell, v0, v1, v2, v3, threshold) {
|
function windowResized() {
|
||||||
var t;
|
screenWidth = window.innerWidth + 10;
|
||||||
switch (edge) {
|
screenHeight = window.innerHeight + 10;
|
||||||
case 0: // top: v0 -> v1
|
resizeCanvas(screenWidth, screenHeight);
|
||||||
t = (threshold - v0) / (v1 - v0 || 1e-6);
|
}
|
||||||
return [x + cell * t, y];
|
|
||||||
case 1: // right: v1 -> v2
|
function draw() {
|
||||||
t = (threshold - v1) / (v2 - v1 || 1e-6);
|
background(24);
|
||||||
return [x + cell, y + cell * t];
|
|
||||||
case 2: // bottom: v3 -> v2
|
for (let i = 0; i < balls.length; i++) {
|
||||||
t = (threshold - v3) / (v2 - v3 || 1e-6);
|
balls[i].update();
|
||||||
return [x + cell * t, y + cell];
|
|
||||||
case 3: // left: v0 -> v3
|
|
||||||
t = (threshold - v0) / (v3 - v0 || 1e-6);
|
|
||||||
return [x, y + cell * t];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
for (let i = 0; i < balls.length - 1; i++) {
|
||||||
// ---------------------------------------------------------------
|
for (let j = i + 1; j < balls.length; j++) {
|
||||||
// Layout state
|
let distance = dist(balls[i].x, balls[i].y, balls[j].x, balls[j].y);
|
||||||
// ---------------------------------------------------------------
|
if (distance < 100){
|
||||||
var dpr = Math.max(1, Math.min(window.devicePixelRatio || 1, 2));
|
stroke(150);
|
||||||
var width = 0;
|
line(balls[i].x, balls[i].y, balls[j].x, balls[j].y);
|
||||||
var height = 0;
|
|
||||||
var cellSize = 28;
|
|
||||||
var cols = 0;
|
|
||||||
var rows = 0;
|
|
||||||
var grid = null; // Float32Array of (cols+1)*(rows+1)
|
|
||||||
|
|
||||||
var LEVELS = [-0.5, -0.333, -0.167, 0, 0.167, 0.333, 0.5];
|
|
||||||
var LOW_COLOR = [233, 230, 223]; // --ink, lowest elevation band
|
|
||||||
// A punchier red than --accent-bright (217,100,92) -- the .site overlay's
|
|
||||||
// ~90% dilution desaturates whatever reaches it, so the top of the ramp
|
|
||||||
// needs to start more saturated than it should ever look at full opacity.
|
|
||||||
var HIGH_COLOR = [235, 70, 55];
|
|
||||||
|
|
||||||
// Two independent master levers: turn either down to quiet that part of
|
|
||||||
// the effect without touching the per-level tuning below. LINE_INTENSITY
|
|
||||||
// scales the contour strokes; FILL_INTENSITY scales the hypsometric wash
|
|
||||||
// between them (the fill covers far more area, so it wants a much lower
|
|
||||||
// resting value or the whole page tints).
|
|
||||||
var LINE_INTENSITY = 1;
|
|
||||||
var FILL_INTENSITY = 0.35;
|
|
||||||
// Fill is parked off for now (color/palette still being worked out) --
|
|
||||||
// the lines are the finished part. Flip this back on to resume tuning
|
|
||||||
// the fill without re-deriving any of the code below.
|
|
||||||
var FILL_ENABLED = false;
|
|
||||||
|
|
||||||
// Shared ink -> accent ramp, used by both the contour lines and the fill
|
|
||||||
// bands so they read as one coherent palette. `rank` is the band's
|
|
||||||
// position (0 = lowest), `count` the total number of bands on that scale.
|
|
||||||
// sqrt-biases toward color early, since a flat ramp only ever colors the
|
|
||||||
// single highest band.
|
|
||||||
function levelColor(rank, count) {
|
|
||||||
var t = Math.sqrt(rank / (count - 1));
|
|
||||||
return [
|
|
||||||
Math.round(LOW_COLOR[0] + (HIGH_COLOR[0] - LOW_COLOR[0]) * t),
|
|
||||||
Math.round(LOW_COLOR[1] + (HIGH_COLOR[1] - LOW_COLOR[1]) * t),
|
|
||||||
Math.round(LOW_COLOR[2] + (HIGH_COLOR[2] - LOW_COLOR[2]) * t),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// How many of LEVELS a value clears -- 0 (below every threshold) through
|
|
||||||
// LEVELS.length (above all of them). LEVELS is sorted ascending.
|
|
||||||
function bandIndex(v) {
|
|
||||||
var idx = 0;
|
|
||||||
for (var i = 0; i < LEVELS.length; i++) {
|
|
||||||
if (v >= LEVELS[i]) idx = i + 1;
|
|
||||||
}
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
var FILL_BANDS = LEVELS.length + 1;
|
|
||||||
var bandColors = null; // precomputed once, reused every frame
|
|
||||||
function buildBandColors() {
|
|
||||||
bandColors = [];
|
|
||||||
for (var i = 0; i < FILL_BANDS; i++) bandColors.push(levelColor(i, FILL_BANDS));
|
|
||||||
}
|
|
||||||
buildBandColors();
|
|
||||||
|
|
||||||
// Samples per grid cell edge for the fill raster. Higher tracks the
|
|
||||||
// contour lines more precisely (at some per-frame cost); 4 keeps the
|
|
||||||
// boundary error under a few px, invisible once bilinear-upscaled.
|
|
||||||
var FILL_SUBDIV = 3;
|
|
||||||
var fillCanvas = document.createElement("canvas");
|
|
||||||
var fillCtx = fillCanvas.getContext("2d");
|
|
||||||
var fillImage = null;
|
|
||||||
var fillCols = 0;
|
|
||||||
var fillRows = 0;
|
|
||||||
|
|
||||||
function resize() {
|
|
||||||
width = window.innerWidth;
|
|
||||||
height = window.innerHeight;
|
|
||||||
canvas.width = Math.round(width * dpr);
|
|
||||||
canvas.height = Math.round(height * dpr);
|
|
||||||
canvas.style.width = width + "px";
|
|
||||||
canvas.style.height = height + "px";
|
|
||||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
||||||
|
|
||||||
// Denser than the original line-only version needed: chaining +
|
|
||||||
// quadratic smoothing can only curve as finely as the underlying
|
|
||||||
// vertices allow, and at ~22px spacing sharp field bends still showed
|
|
||||||
// as visible facets (the actual cause of the "depth"/faceted look --
|
|
||||||
// confirmed by eye, not just measured).
|
|
||||||
var targetCols = 130;
|
|
||||||
cellSize = Math.max(11, width / targetCols);
|
|
||||||
cols = Math.ceil(width / cellSize) + 1;
|
|
||||||
rows = Math.ceil(height / cellSize) + 1;
|
|
||||||
grid = new Float32Array((cols + 1) * (rows + 1));
|
|
||||||
|
|
||||||
fillCols = cols * FILL_SUBDIV;
|
|
||||||
fillRows = rows * FILL_SUBDIV;
|
|
||||||
fillCanvas.width = fillCols;
|
|
||||||
fillCanvas.height = fillRows;
|
|
||||||
fillImage = fillCtx.createImageData(fillCols, fillRows);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sampleGrid(driftX, driftY, warpX, warpY) {
|
|
||||||
var idx = 0;
|
|
||||||
for (var ry = 0; ry <= rows; ry++) {
|
|
||||||
var y = ry * cellSize;
|
|
||||||
for (var rx = 0; rx <= cols; rx++) {
|
|
||||||
var x = rx * cellSize;
|
|
||||||
grid[idx++] = fieldValue(x, y, driftX, driftY, warpX, warpY);
|
|
||||||
}
|
}
|
||||||
}
|
else if (distance < 150) {
|
||||||
}
|
stroke(100);
|
||||||
|
let chance = 0.3 ** (((random(0.2) + 0.8) * distance) / 150);
|
||||||
// Hypsometric wash: for each fill-raster sample, bilinearly interpolate
|
if (chance < 0.5) {
|
||||||
// the RAW field value from its cell's four corners -- the same linear
|
stroke(50);
|
||||||
// interpolation marching squares uses internally to place a line -- then
|
|
||||||
// band/color that interpolated value. Coloring first and blending colors
|
|
||||||
// second (as an earlier version did) is a different operation and drifts
|
|
||||||
// from the true boundary wherever a cell spans more than one threshold;
|
|
||||||
// interpolating the value first keeps fill and line mathematically tied
|
|
||||||
// to the same crossing.
|
|
||||||
function drawFill() {
|
|
||||||
var stride = cols + 1;
|
|
||||||
var pixels = fillImage.data;
|
|
||||||
var p = 0;
|
|
||||||
for (var ry = 0; ry < fillRows; ry++) {
|
|
||||||
var cy = Math.min(rows - 1, (ry / FILL_SUBDIV) | 0);
|
|
||||||
var fy = (ry - cy * FILL_SUBDIV) / FILL_SUBDIV;
|
|
||||||
var rowOff = cy * stride;
|
|
||||||
var rowOffNext = rowOff + stride;
|
|
||||||
for (var rx = 0; rx < fillCols; rx++) {
|
|
||||||
var cx = Math.min(cols - 1, (rx / FILL_SUBDIV) | 0);
|
|
||||||
var fx = (rx - cx * FILL_SUBDIV) / FILL_SUBDIV;
|
|
||||||
|
|
||||||
var v0 = grid[rowOff + cx];
|
|
||||||
var v1 = grid[rowOff + cx + 1];
|
|
||||||
var v2 = grid[rowOffNext + cx + 1];
|
|
||||||
var v3 = grid[rowOffNext + cx];
|
|
||||||
|
|
||||||
var top = v0 + (v1 - v0) * fx;
|
|
||||||
var bottom = v3 + (v2 - v3) * fx;
|
|
||||||
var value = top + (bottom - top) * fy;
|
|
||||||
|
|
||||||
var c = bandColors[bandIndex(value)];
|
|
||||||
pixels[p++] = c[0];
|
|
||||||
pixels[p++] = c[1];
|
|
||||||
pixels[p++] = c[2];
|
|
||||||
pixels[p++] = 255;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fillCtx.putImageData(fillImage, 0, 0);
|
|
||||||
|
|
||||||
var alpha = Math.max(0, Math.min(1, FILL_INTENSITY));
|
|
||||||
ctx.save();
|
|
||||||
ctx.globalAlpha = alpha;
|
|
||||||
ctx.imageSmoothingEnabled = true;
|
|
||||||
ctx.drawImage(fillCanvas, 0, 0, fillCols, fillRows, 0, 0, width, height);
|
|
||||||
ctx.restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Marching squares gives independent 2-point segments per cell, with no
|
|
||||||
// record of which segments abut. Stroking them as-is (one moveTo/lineTo
|
|
||||||
// subpath per segment) means lineJoin never gets a chance to apply, so
|
|
||||||
// every cell boundary shows as a hard facet. Chain segments that share
|
|
||||||
// an endpoint into continuous polylines/loops first, then stroke each
|
|
||||||
// chain as a quadratic-smoothed curve through its points -- an actually
|
|
||||||
// curved line instead of a connect-the-dots polygon.
|
|
||||||
var CHAIN_EPS = 0.02; // px; two crossings on the same shared edge should
|
|
||||||
// land on (near-)identical floats, see note below
|
|
||||||
function pointKey(p) {
|
|
||||||
return Math.round(p[0] / CHAIN_EPS) + "_" + Math.round(p[1] / CHAIN_EPS);
|
|
||||||
}
|
|
||||||
|
|
||||||
function collectSegments(threshold) {
|
|
||||||
var stride = cols + 1;
|
|
||||||
var segments = [];
|
|
||||||
for (var cy = 0; cy < rows; cy++) {
|
|
||||||
var rowOff = cy * stride;
|
|
||||||
var rowOffNext = rowOff + stride;
|
|
||||||
var y = cy * cellSize;
|
|
||||||
for (var cx = 0; cx < cols; cx++) {
|
|
||||||
var x = cx * cellSize;
|
|
||||||
var v0 = grid[rowOff + cx];
|
|
||||||
var v1 = grid[rowOff + cx + 1];
|
|
||||||
var v2 = grid[rowOffNext + cx + 1];
|
|
||||||
var v3 = grid[rowOffNext + cx];
|
|
||||||
|
|
||||||
var caseIndex =
|
|
||||||
(v0 >= threshold ? 1 : 0) |
|
|
||||||
(v1 >= threshold ? 2 : 0) |
|
|
||||||
(v2 >= threshold ? 4 : 0) |
|
|
||||||
(v3 >= threshold ? 8 : 0);
|
|
||||||
|
|
||||||
var edges = CASE_EDGES[caseIndex];
|
|
||||||
if (!edges) continue;
|
|
||||||
|
|
||||||
for (var s = 0; s < edges.length; s += 2) {
|
|
||||||
var p0 = edgePoint(edges[s], x, y, cellSize, v0, v1, v2, v3, threshold);
|
|
||||||
var p1 = edgePoint(edges[s + 1], x, y, cellSize, v0, v1, v2, v3, threshold);
|
|
||||||
segments.push([p0, p1]);
|
|
||||||
}
|
}
|
||||||
|
line(balls[i].x, balls[i].y, balls[j].x, balls[j].y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return segments;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Two adjacent cells that share a grid edge compute that edge's crossing
|
|
||||||
// point from the same two corner values via the same formula (verified:
|
|
||||||
// cell (cx,cy)'s right edge and cell (cx+1,cy)'s left edge reduce to an
|
|
||||||
// identical t), so their coordinates match to float precision -- rounding
|
|
||||||
// to a shared key reliably links them into one path.
|
|
||||||
function strokeChains(segments) {
|
|
||||||
var edgesForKey = {};
|
|
||||||
var pointsByKey = {};
|
|
||||||
|
|
||||||
function addPoint(p) {
|
|
||||||
var k = pointKey(p);
|
|
||||||
if (!pointsByKey[k]) pointsByKey[k] = p;
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < segments.length; i++) {
|
|
||||||
var ka = addPoint(segments[i][0]);
|
|
||||||
var kb = addPoint(segments[i][1]);
|
|
||||||
(edgesForKey[ka] = edgesForKey[ka] || []).push(kb);
|
|
||||||
(edgesForKey[kb] = edgesForKey[kb] || []).push(ka);
|
|
||||||
}
|
|
||||||
|
|
||||||
var visited = {};
|
|
||||||
function edgeId(k1, k2) {
|
|
||||||
return k1 < k2 ? k1 + "|" + k2 : k2 + "|" + k1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function walk(startKey) {
|
|
||||||
var chain = [pointsByKey[startKey]];
|
|
||||||
var currentKey = startKey;
|
|
||||||
while (true) {
|
|
||||||
var neighbors = edgesForKey[currentKey] || [];
|
|
||||||
var nextKey = null;
|
|
||||||
for (var ni = 0; ni < neighbors.length; ni++) {
|
|
||||||
var eid = edgeId(currentKey, neighbors[ni]);
|
|
||||||
if (!visited[eid]) {
|
|
||||||
nextKey = neighbors[ni];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nextKey === null) break;
|
|
||||||
visited[edgeId(currentKey, nextKey)] = true;
|
|
||||||
chain.push(pointsByKey[nextKey]);
|
|
||||||
currentKey = nextKey;
|
|
||||||
if (currentKey === startKey) break; // closed loop
|
|
||||||
}
|
|
||||||
return chain;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
var k;
|
|
||||||
// Open chains first: any point with exactly one connection is an end.
|
|
||||||
for (k in edgesForKey) {
|
|
||||||
if (edgesForKey[k].length === 1) strokeChain(walk(k));
|
|
||||||
}
|
|
||||||
// Whatever's left over is closed loops with no natural start point.
|
|
||||||
for (k in edgesForKey) {
|
|
||||||
var neighbors = edgesForKey[k];
|
|
||||||
for (var ni = 0; ni < neighbors.length; ni++) {
|
|
||||||
if (!visited[edgeId(k, neighbors[ni])]) strokeChain(walk(k));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctx.stroke();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Quadratic-smoothed polyline: curve through the midpoint of each
|
|
||||||
// consecutive pair, using the shared point as control -- the standard
|
|
||||||
// cheap trick for turning a connect-the-dots path into a soft curve
|
|
||||||
// without full spline math.
|
|
||||||
// Catmull-Rom, not midpoint-quadratic: the earlier version curved *toward*
|
|
||||||
// each crossing point without ever reaching it (except chain endpoints),
|
|
||||||
// which is exactly why the line drifted from the fill after smoothing --
|
|
||||||
// the fill still bands on the true, unsmoothed crossing positions. A
|
|
||||||
// Catmull-Rom segment passes through every real point exactly and only
|
|
||||||
// uses neighbors to shape the tangent between them, so line and fill stay
|
|
||||||
// tied to the same positions with no possible corner-cutting drift.
|
|
||||||
function strokeChain(points) {
|
|
||||||
var n = points.length;
|
|
||||||
if (n < 2) return;
|
|
||||||
ctx.moveTo(points[0][0], points[0][1]);
|
|
||||||
if (n === 2) {
|
|
||||||
ctx.lineTo(points[1][0], points[1][1]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (var i = 0; i < n - 1; i++) {
|
|
||||||
var p0 = points[i - 1] || points[i];
|
|
||||||
var p1 = points[i];
|
|
||||||
var p2 = points[i + 1];
|
|
||||||
var p3 = points[i + 2] || p2;
|
|
||||||
var c1x = p1[0] + (p2[0] - p0[0]) / 6;
|
|
||||||
var c1y = p1[1] + (p2[1] - p0[1]) / 6;
|
|
||||||
var c2x = p2[0] - (p3[0] - p1[0]) / 6;
|
|
||||||
var c2y = p2[1] - (p3[1] - p1[1]) / 6;
|
|
||||||
ctx.bezierCurveTo(c1x, c1y, c2x, c2y, p2[0], p2[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawContours() {
|
|
||||||
ctx.lineJoin = "round";
|
|
||||||
ctx.lineCap = "round";
|
|
||||||
|
|
||||||
for (var li = 0; li < LEVELS.length; li++) {
|
|
||||||
var threshold = LEVELS[li];
|
|
||||||
var isZero = threshold === 0;
|
|
||||||
// Rank-based, not value-based: the noise field's realized range
|
|
||||||
// rarely spans the full [-0.5, 0.5] of LEVELS (it's a weighted sum
|
|
||||||
// of two octaves, which clusters near the middle), so mapping color
|
|
||||||
// to the raw threshold left the reddest bands almost never drawn.
|
|
||||||
// Index position guarantees the full ink -> accent gradient shows
|
|
||||||
// up across whatever levels actually render. Same ramp as the fill.
|
|
||||||
var c = levelColor(li, LEVELS.length);
|
|
||||||
// Flat alpha across all non-zero bands: a depth-based falloff would
|
|
||||||
// dim the outer (most colorful) bands the most, directly undoing
|
|
||||||
// the color ramp. Color carries the elevation cue here, not brightness.
|
|
||||||
var alpha = (isZero ? 0.85 : 0.68) * LINE_INTENSITY;
|
|
||||||
ctx.strokeStyle = "rgba(" + c[0] + "," + c[1] + "," + c[2] + "," + alpha + ")";
|
|
||||||
// the zero level stays a hair bolder, like a coastline on a real
|
|
||||||
// topo map -- a reference line, not just another band.
|
|
||||||
ctx.lineWidth = isZero ? 1.8 : 1.4;
|
|
||||||
|
|
||||||
strokeChains(collectSegments(threshold));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function render(driftX, driftY, warpX, warpY) {
|
|
||||||
ctx.clearRect(0, 0, width, height);
|
|
||||||
sampleGrid(driftX, driftY, warpX, warpY);
|
|
||||||
if (FILL_ENABLED) drawFill();
|
|
||||||
drawContours();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// Animation: slow drift, throttled to a modest frame rate since the
|
|
||||||
// motion itself unfolds over tens of seconds -- no need to sample it
|
|
||||||
// faster than that.
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
var DRIFT_VX = 3.2; // px/sec
|
|
||||||
var DRIFT_VY = -2.1; // px/sec
|
|
||||||
var startTime = null;
|
|
||||||
var lastFrameTime = 0;
|
|
||||||
var FRAME_INTERVAL = 1000 / 15; // ~15fps grid refresh, plenty for slow drift
|
|
||||||
var rafId = null;
|
|
||||||
|
|
||||||
function frame(now) {
|
|
||||||
rafId = requestAnimationFrame(frame);
|
|
||||||
if (now - lastFrameTime < FRAME_INTERVAL) return;
|
|
||||||
lastFrameTime = now;
|
|
||||||
if (startTime === null) startTime = now;
|
|
||||||
var t = (now - startTime) / 1000;
|
|
||||||
|
|
||||||
var driftX = t * DRIFT_VX;
|
|
||||||
var driftY = t * DRIFT_VY;
|
|
||||||
var warpX = Math.sin(t * 0.013) * 60;
|
|
||||||
var warpY = Math.cos(t * 0.009) * 60;
|
|
||||||
render(driftX, driftY, warpX, warpY);
|
|
||||||
}
|
|
||||||
|
|
||||||
function start() {
|
|
||||||
resize();
|
|
||||||
if (reduceMotion) {
|
|
||||||
render(0, 0, 0, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
rafId = requestAnimationFrame(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
var resizeTimer = null;
|
|
||||||
window.addEventListener("resize", function () {
|
|
||||||
if (resizeTimer) clearTimeout(resizeTimer);
|
|
||||||
resizeTimer = setTimeout(function () {
|
|
||||||
resize();
|
|
||||||
if (reduceMotion) render(0, 0, 0, 0);
|
|
||||||
}, 150);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener("visibilitychange", function () {
|
|
||||||
if (reduceMotion) return;
|
|
||||||
if (document.hidden) {
|
|
||||||
if (rafId !== null) {
|
|
||||||
cancelAnimationFrame(rafId);
|
|
||||||
rafId = null;
|
|
||||||
}
|
|
||||||
} else if (rafId === null) {
|
|
||||||
lastFrameTime = 0;
|
|
||||||
rafId = requestAnimationFrame(frame);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
start();
|
|
||||||
})();
|
|
||||||
|
|||||||
235
src/static/js/responsive.js
Executable file → Normal file
@@ -1,186 +1,71 @@
|
|||||||
function toggleMenu(collapse) {
|
window.onload = function () {
|
||||||
const header = document.getElementById("siteHeader");
|
onLoaded();
|
||||||
const btn = document.getElementById("menu");
|
};
|
||||||
if (!header) return;
|
function onLoaded() {
|
||||||
const open = collapse ? false : !header.classList.contains("open");
|
window.onresize = function () {
|
||||||
header.classList.toggle("open", open);
|
resizer();
|
||||||
if (btn) btn.setAttribute("aria-expanded", open ? "true" : "false");
|
};
|
||||||
|
resizer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function markCurrentPage(location) {
|
function resizer() {
|
||||||
document.querySelectorAll(".site-nav a[data-page]").forEach(function (link) {
|
const e = document.querySelector(".navControl");
|
||||||
if (link.dataset.page === location) {
|
if (window.innerWidth > 1400) {
|
||||||
link.setAttribute("aria-current", "page");
|
// desktop view
|
||||||
} else {
|
e.style.maxHeight = `${e.scrollHeight + 10}px`;
|
||||||
link.removeAttribute("aria-current");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showNavNotice(message) {
|
|
||||||
const notice = document.getElementById('nav-notice');
|
|
||||||
if (!notice) return;
|
|
||||||
notice.textContent = message;
|
|
||||||
notice.hidden = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideNavNotice() {
|
|
||||||
const notice = document.getElementById('nav-notice');
|
|
||||||
if (notice) notice.hidden = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function goto(location, { push = true, hash = "" } = {}) {
|
|
||||||
const loadingBar = document.getElementById('loading-bar');
|
|
||||||
|
|
||||||
if (loadingBar) {
|
|
||||||
loadingBar.style.width = ''; // Clear inline style from previous run
|
|
||||||
}
|
|
||||||
|
|
||||||
let loadingTimeout = setTimeout(() => {
|
|
||||||
if (loadingBar) {
|
|
||||||
loadingBar.classList.remove('finish');
|
|
||||||
loadingBar.classList.add('active');
|
|
||||||
loadingBar.classList.add('visible');
|
|
||||||
}
|
|
||||||
}, 150);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch("/api/goto/" + location, {
|
|
||||||
credentials: "include",
|
|
||||||
method: "GET",
|
|
||||||
mode: "cors",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP ${response.status}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for the full body to download - this is usually the slow part
|
|
||||||
const [metadata, content] = await response.json();
|
|
||||||
|
|
||||||
document.dispatchEvent(new Event('beforenavigate'));
|
|
||||||
hideNavNotice();
|
|
||||||
|
|
||||||
const root = document.getElementById("root");
|
|
||||||
root.innerHTML = content;
|
|
||||||
|
|
||||||
// Re-execute scripts
|
|
||||||
root.querySelectorAll("script").forEach(function(oldScript) {
|
|
||||||
const newScript = document.createElement("script");
|
|
||||||
Array.from(oldScript.attributes).forEach(function(attr) {
|
|
||||||
newScript.setAttribute(attr.name, attr.value);
|
|
||||||
});
|
|
||||||
newScript.textContent = oldScript.textContent;
|
|
||||||
oldScript.parentNode.replaceChild(newScript, oldScript);
|
|
||||||
});
|
|
||||||
|
|
||||||
const target = hash || (push ? "" : decodeURIComponent(window.location.hash.substring(1)));
|
|
||||||
const targetEl = target ? document.getElementById(target) : null;
|
|
||||||
if (targetEl) {
|
|
||||||
revealTarget(targetEl);
|
|
||||||
targetEl.scrollIntoView({ behavior: "instant", block: "start" });
|
|
||||||
} else {
|
|
||||||
window.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleMenu(true);
|
|
||||||
markCurrentPage(location);
|
|
||||||
document.querySelector("title").textContent = metadata["title"];
|
|
||||||
if (push) {
|
|
||||||
history.pushState(null, null, metadata["canonical"] + (hash ? "#" + hash : ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Navigation failed:", err);
|
|
||||||
showNavNotice("Couldn't load that page. Check your connection and try again.");
|
|
||||||
} finally {
|
|
||||||
clearTimeout(loadingTimeout);
|
|
||||||
if (loadingBar && loadingBar.classList.contains('active')) {
|
|
||||||
loadingBar.classList.add('finish');
|
|
||||||
loadingBar.classList.remove('active');
|
|
||||||
setTimeout(() => {
|
|
||||||
if (!loadingBar.classList.contains('active')) {
|
|
||||||
loadingBar.style.width = '0%';
|
|
||||||
loadingBar.classList.remove('finish');
|
|
||||||
loadingBar.classList.remove('visible');
|
|
||||||
}
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Featured project panels: collapsed to a short peek until expanded.
|
|
||||||
function setFeatureExpanded(feature, expanded) {
|
|
||||||
const clips = feature.querySelectorAll(".feature-clip");
|
|
||||||
const btn = feature.querySelector(".feature-expand");
|
|
||||||
if (expanded) {
|
|
||||||
feature.classList.add("expanded");
|
|
||||||
clips.forEach(function (el) {
|
|
||||||
el.style.maxHeight = el.scrollHeight + "px";
|
|
||||||
});
|
|
||||||
// Once open, let the regions size themselves so late-loading content is never clipped.
|
|
||||||
setTimeout(function () {
|
|
||||||
if (!feature.classList.contains("expanded")) return;
|
|
||||||
clips.forEach(function (el) {
|
|
||||||
el.style.maxHeight = "none";
|
|
||||||
});
|
|
||||||
}, 400);
|
|
||||||
} else {
|
} else {
|
||||||
// Pin the current heights, force a reflow, then let CSS animate down to the peek.
|
// mobile view
|
||||||
clips.forEach(function (el) {
|
document.querySelector(".header").style.borderBottomWidth = "3px";
|
||||||
el.style.maxHeight = el.scrollHeight + "px";
|
e.style.maxHeight = "0px";
|
||||||
});
|
document.querySelectorAll(".navElement *").forEach((x) => {
|
||||||
void feature.offsetHeight;
|
x.style.paddingTop = ".3rem";
|
||||||
feature.classList.remove("expanded");
|
x.style.paddingBottom = ".3rem";
|
||||||
clips.forEach(function (el) {
|
x.style.fontSize = "1rem";
|
||||||
el.style.maxHeight = "";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (btn) btn.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleFeature(btn) {
|
|
||||||
const feature = btn.closest(".feature");
|
|
||||||
if (feature) setFeatureExpanded(feature, !feature.classList.contains("expanded"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expand a collapsed panel (or the one containing the target) before jumping to it.
|
|
||||||
function revealTarget(el) {
|
|
||||||
const feature = el.closest(".feature");
|
|
||||||
if (feature && !feature.classList.contains("expanded")) {
|
|
||||||
setFeatureExpanded(feature, true);
|
|
||||||
feature.querySelectorAll(".feature-clip").forEach(function (el) {
|
|
||||||
el.style.maxHeight = "none";
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
function toggleMenu() {
|
||||||
if (!window.location.hash) return;
|
if (window.innerWidth < 1400) {
|
||||||
const el = document.getElementById(decodeURIComponent(window.location.hash.substring(1)));
|
const e = document.querySelector(".navControl");
|
||||||
if (el) {
|
const bar = document.querySelector(".header");
|
||||||
revealTarget(el);
|
if (e.style.maxHeight === "0px") {
|
||||||
el.scrollIntoView({ behavior: "instant", block: "start" });
|
e.style.maxHeight = `${e.scrollHeight + 10}px`;
|
||||||
|
bar.style.borderBottomWidth = "0px";
|
||||||
|
} else {
|
||||||
|
e.style.maxHeight = "0px";
|
||||||
|
bar.style.borderBottomWidth = "3px";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
async function goto(location, { push = true, toggle = true } = {}) {
|
||||||
|
let a = await fetch("/api/goto/" + location, {
|
||||||
|
credentials: "include",
|
||||||
|
method: "GET",
|
||||||
|
mode: "cors",
|
||||||
|
});
|
||||||
|
const response = await a.json();
|
||||||
|
if (!location.includes("#")) {
|
||||||
|
window.scrollTo({top: 0, left: 0, behavior:"instant"});
|
||||||
|
}
|
||||||
|
const metadata = response[0];
|
||||||
|
const content = response[1];
|
||||||
|
let root = document.getElementById("root");
|
||||||
|
root.innerHTML = content;
|
||||||
|
root.querySelectorAll("script").forEach((x) => {
|
||||||
|
eval(x.innerHTML);
|
||||||
|
});
|
||||||
|
if (toggle) {
|
||||||
|
toggleMenu();
|
||||||
|
}
|
||||||
|
document.querySelector("title").textContent = metadata["title"];
|
||||||
|
if (push) {
|
||||||
|
history.pushState(null, null, metadata["canonical"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function backButton() {
|
function backButton() {
|
||||||
const path = window.location.pathname;
|
const location = window.location.pathname;
|
||||||
goto(path.substring(1) || "home", { push: false });
|
goto(location.substring(1), { push: false }); // remove slash, goto already does that
|
||||||
}
|
|
||||||
|
|
||||||
function activeSkill(obj) {
|
|
||||||
let skill = obj.closest(".skill");
|
|
||||||
if (skill.classList.contains("activeSkill")) {
|
|
||||||
skill.classList.remove("activeSkill");
|
|
||||||
const btn = obj.closest('.skillname') || obj.querySelector?.('.skillname') || obj;
|
|
||||||
if (btn && btn.setAttribute) btn.setAttribute("aria-expanded", "false");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (skill) {
|
|
||||||
skill.classList.add("activeSkill");
|
|
||||||
const nameEl = skill.querySelector?.(':scope > .skillname') || skill.querySelector('.skillname');
|
|
||||||
if (nameEl) nameEl.setAttribute("aria-expanded", "true");
|
|
||||||
skill = skill.parentElement.closest(".skill");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,253 +0,0 @@
|
|||||||
// Use a global to track the interval and ensure we don't stack listeners
|
|
||||||
if (window.statusIntervalId) {
|
|
||||||
clearInterval(window.statusIntervalId);
|
|
||||||
window.statusIntervalId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchStatus() {
|
|
||||||
try {
|
|
||||||
const response = await fetch('/api/status');
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
|
||||||
}
|
|
||||||
const data = await response.json();
|
|
||||||
updateStatusDisplay(data);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching status:', error);
|
|
||||||
showError('Failed to fetch service status. Please try again later.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateStatusDisplay(data) {
|
|
||||||
showStaleNotice(!!data.stale);
|
|
||||||
|
|
||||||
if (data.last_check) {
|
|
||||||
const lastCheck = new Date(data.last_check);
|
|
||||||
const lastUpdateEl = document.getElementById('lastUpdate');
|
|
||||||
if (lastUpdateEl) lastUpdateEl.textContent = lastCheck.toLocaleString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.next_check) {
|
|
||||||
const nextCheckEl = document.getElementById('nextUpdate');
|
|
||||||
if (nextCheckEl) {
|
|
||||||
const nextCheck = new Date(data.next_check);
|
|
||||||
nextCheckEl.textContent = nextCheck.toLocaleString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.services) {
|
|
||||||
data.services.forEach(function(service) {
|
|
||||||
updateServiceCard(service);
|
|
||||||
});
|
|
||||||
updateOverallStatus(data.services);
|
|
||||||
}
|
|
||||||
|
|
||||||
const refreshBtn = document.getElementById('refreshBtn');
|
|
||||||
if (refreshBtn) {
|
|
||||||
refreshBtn.disabled = false;
|
|
||||||
refreshBtn.textContent = 'Refresh now';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUptimeClass(value) {
|
|
||||||
if (value === null) return 'text-muted';
|
|
||||||
if (value >= 99) return 'text-excellent';
|
|
||||||
if (value >= 95) return 'text-good';
|
|
||||||
if (value >= 90) return 'text-fair';
|
|
||||||
return 'text-poor';
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatUptime(value, label) {
|
|
||||||
const display = value !== null ? `${value}%` : '--';
|
|
||||||
return `${label}: <strong class="${getUptimeClass(value)}">${display}</strong>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateServiceCard(service) {
|
|
||||||
const card = document.getElementById(`status-${service.id}`);
|
|
||||||
if (!card) return;
|
|
||||||
|
|
||||||
const stateDot = card.querySelector('.state-dot');
|
|
||||||
const stateText = card.querySelector('.state-text');
|
|
||||||
const timeDisplay = document.getElementById(`time-${service.id}`);
|
|
||||||
const codeDisplay = document.getElementById(`code-${service.id}`);
|
|
||||||
const uptimeDisplay = document.getElementById(`uptime-${service.id}`);
|
|
||||||
const checksDisplay = document.getElementById(`checks-${service.id}`);
|
|
||||||
|
|
||||||
if (timeDisplay) timeDisplay.textContent = service.response_time !== null ? `${service.response_time}ms` : '--';
|
|
||||||
|
|
||||||
if (codeDisplay) {
|
|
||||||
if (service.status_code !== null) {
|
|
||||||
codeDisplay.textContent = service.status_code;
|
|
||||||
} else {
|
|
||||||
codeDisplay.textContent = service.status === 'unknown' ? 'Unknown' : 'Error';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
card.classList.remove('online', 'degraded', 'offline', 'unknown');
|
|
||||||
|
|
||||||
switch (service.status) {
|
|
||||||
case 'online':
|
|
||||||
if (stateDot) stateDot.className = 'state-dot online';
|
|
||||||
if (stateText) stateText.textContent = 'Operational';
|
|
||||||
card.classList.add('online');
|
|
||||||
break;
|
|
||||||
case 'degraded':
|
|
||||||
case 'timeout':
|
|
||||||
if (stateDot) stateDot.className = 'state-dot degraded';
|
|
||||||
if (stateText) stateText.textContent = service.status === 'timeout' ? 'Timeout' : 'Degraded';
|
|
||||||
card.classList.add('degraded');
|
|
||||||
break;
|
|
||||||
case 'offline':
|
|
||||||
if (stateDot) stateDot.className = 'state-dot offline';
|
|
||||||
if (stateText) stateText.textContent = 'Offline';
|
|
||||||
card.classList.add('offline');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (stateDot) stateDot.className = 'state-dot loading';
|
|
||||||
if (stateText) stateText.textContent = 'Unknown';
|
|
||||||
card.classList.add('unknown');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uptimeDisplay && service.uptime) {
|
|
||||||
uptimeDisplay.innerHTML = [
|
|
||||||
formatUptime(service.uptime['24h'], '24h'),
|
|
||||||
formatUptime(service.uptime['7d'], '7d'),
|
|
||||||
formatUptime(service.uptime['30d'], '30d'),
|
|
||||||
formatUptime(service.uptime.all_time, 'All'),
|
|
||||||
].join(' · ');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checksDisplay && service.total_checks !== undefined) {
|
|
||||||
checksDisplay.textContent = service.total_checks;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateOverallStatus(services) {
|
|
||||||
const overallBar = document.getElementById('overallStatus');
|
|
||||||
if (!overallBar) return;
|
|
||||||
|
|
||||||
const icon = overallBar.querySelector('.summary-icon');
|
|
||||||
const title = overallBar.querySelector('.summary-title');
|
|
||||||
const subtitle = document.getElementById('summary-subtitle');
|
|
||||||
const onlineCount = document.getElementById('onlineCount');
|
|
||||||
const totalCount = document.getElementById('totalCount');
|
|
||||||
|
|
||||||
const total = services.length;
|
|
||||||
const online = services.filter(function(s) { return s.status === 'online'; }).length;
|
|
||||||
const degraded = services.filter(function(s) { return s.status === 'degraded' || s.status === 'timeout'; }).length;
|
|
||||||
const offline = services.filter(function(s) { return s.status === 'offline'; }).length;
|
|
||||||
|
|
||||||
if (onlineCount) onlineCount.textContent = online;
|
|
||||||
if (totalCount) totalCount.textContent = total;
|
|
||||||
|
|
||||||
overallBar.classList.remove('online', 'degraded', 'offline');
|
|
||||||
if (icon) icon.classList.remove('operational', 'partial', 'major', 'loading');
|
|
||||||
|
|
||||||
// Determine overall status
|
|
||||||
if (online === total) {
|
|
||||||
overallBar.classList.add('online');
|
|
||||||
if (icon) {
|
|
||||||
icon.classList.add('operational');
|
|
||||||
icon.textContent = '\u2713';
|
|
||||||
}
|
|
||||||
if (title) title.textContent = 'All Systems Operational';
|
|
||||||
if (subtitle) subtitle.textContent = `All ${total} services are running normally`;
|
|
||||||
} else if (offline >= Math.ceil(total / 2)) {
|
|
||||||
overallBar.classList.add('offline');
|
|
||||||
if (icon) {
|
|
||||||
icon.classList.add('major');
|
|
||||||
icon.textContent = '\u2715';
|
|
||||||
}
|
|
||||||
if (title) title.textContent = 'Major Outage';
|
|
||||||
if (subtitle) subtitle.textContent = `${offline} service${offline !== 1 ? 's' : ''} offline, ${degraded} degraded`;
|
|
||||||
} else if (offline > 0 || degraded > 0) {
|
|
||||||
overallBar.classList.add('degraded');
|
|
||||||
if (icon) {
|
|
||||||
icon.classList.add('partial');
|
|
||||||
icon.textContent = '\u26A0';
|
|
||||||
}
|
|
||||||
if (title) title.textContent = 'Partial Outage';
|
|
||||||
if (subtitle) {
|
|
||||||
if (offline > 0 && degraded > 0) {
|
|
||||||
subtitle.textContent = `${offline} offline, ${degraded} degraded`;
|
|
||||||
} else if (offline > 0) {
|
|
||||||
subtitle.textContent = `${offline} service${offline !== 1 ? 's' : ''} offline`;
|
|
||||||
} else {
|
|
||||||
subtitle.textContent = `${degraded} service${degraded !== 1 ? 's' : ''} degraded`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (icon) {
|
|
||||||
icon.classList.add('loading');
|
|
||||||
icon.textContent = '\u25D0';
|
|
||||||
}
|
|
||||||
if (title) title.textContent = 'Status Unknown';
|
|
||||||
if (subtitle) subtitle.textContent = 'Waiting for service data';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showError(message) {
|
|
||||||
const errorDiv = document.createElement('div');
|
|
||||||
errorDiv.className = 'status-error';
|
|
||||||
errorDiv.textContent = message;
|
|
||||||
|
|
||||||
|
|
||||||
const container = document.querySelector('.page');
|
|
||||||
if (container) {
|
|
||||||
container.insertBefore(errorDiv, container.firstChild);
|
|
||||||
setTimeout(function() { errorDiv.remove(); }, 5000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Persistent (not auto-dismissed) notice that the last successful check is
|
|
||||||
// older than expected -- the monitor may have hit a snag, so don't let the
|
|
||||||
// page keep implying the numbers below are fresh.
|
|
||||||
function showStaleNotice(isStale) {
|
|
||||||
const container = document.querySelector('.page');
|
|
||||||
if (!container) return;
|
|
||||||
let noticeEl = document.getElementById('staleNotice');
|
|
||||||
|
|
||||||
if (!isStale) {
|
|
||||||
if (noticeEl) noticeEl.remove();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!noticeEl) {
|
|
||||||
noticeEl = document.createElement('div');
|
|
||||||
noticeEl.id = 'staleNotice';
|
|
||||||
noticeEl.className = 'status-notice';
|
|
||||||
noticeEl.textContent = 'Data below may be out of date -- the last successful check was longer ago than expected.';
|
|
||||||
container.insertBefore(noticeEl, container.firstChild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshStatus() {
|
|
||||||
const refreshBtn = document.getElementById('refreshBtn');
|
|
||||||
if (refreshBtn) {
|
|
||||||
refreshBtn.disabled = true;
|
|
||||||
refreshBtn.textContent = 'Checking';
|
|
||||||
}
|
|
||||||
fetchStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function initStatusPage() {
|
|
||||||
if (window.statusIntervalId) {
|
|
||||||
clearInterval(window.statusIntervalId);
|
|
||||||
}
|
|
||||||
fetchStatus();
|
|
||||||
window.statusIntervalId = setInterval(fetchStatus, 60000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function cleanupStatusPage() {
|
|
||||||
if (window.statusIntervalId) {
|
|
||||||
clearInterval(window.statusIntervalId);
|
|
||||||
window.statusIntervalId = null;
|
|
||||||
}
|
|
||||||
document.removeEventListener('beforenavigate', cleanupStatusPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('beforenavigate', cleanupStatusPage);
|
|
||||||
|
|
||||||
if (document.getElementById('overallStatus')) {
|
|
||||||
initStatusPage();
|
|
||||||
}
|
|
||||||
66
src/static/json/books.json
Executable file → Normal file
@@ -1,22 +1,11 @@
|
|||||||
{
|
{
|
||||||
"selection": [
|
"selection": [
|
||||||
"The Rational Optimist",
|
"The Rational Optimist",
|
||||||
"Project Hail Mary",
|
|
||||||
"Freakonomics",
|
|
||||||
"The Accidental Superpower",
|
"The Accidental Superpower",
|
||||||
"The Martian"
|
"Freakonomics",
|
||||||
|
"Zero To One"
|
||||||
],
|
],
|
||||||
"books": {
|
"books": {
|
||||||
"Project Hail Mary": {
|
|
||||||
"filename": "hailmary.jpg",
|
|
||||||
"link": "https://www.amazon.com/Project-Hail-Mary-Andy-Weir/dp/0593135202",
|
|
||||||
"review": "This must be the first hard-sci-fi book I have read and I absolutely loved it. When I watched the movie I concluded that both executed on an inspiring story with an endearing tone but only the book held the creative practicality that really made it a favorite."
|
|
||||||
},
|
|
||||||
"The Martian": {
|
|
||||||
"filename": "themartian.jpg",
|
|
||||||
"link": "https://www.amazon.com/Martian-Andy-Weir/dp/0553418025",
|
|
||||||
"review": "I picked this up after Project Hail Mary looking for more creative uses of hard scifi. On that account The Martian surpassed expectations - partially because the plot didn't have to contend with fantasy elements. I aspire to one day use a radioactive space heater as a hot tub power source, just as my hero, Mark Watney, once did."
|
|
||||||
},
|
|
||||||
"The Rational Optimist": {
|
"The Rational Optimist": {
|
||||||
"filename": "ratOpt.jpg",
|
"filename": "ratOpt.jpg",
|
||||||
"link": "https://www.amazon.com/Rational-Optimist-Prosperity-Evolves-P-s/dp/0061452068",
|
"link": "https://www.amazon.com/Rational-Optimist-Prosperity-Evolves-P-s/dp/0061452068",
|
||||||
@@ -42,16 +31,6 @@
|
|||||||
"link": "https://freakonomics.com/books/",
|
"link": "https://freakonomics.com/books/",
|
||||||
"review": "More like the other Freakonomics books than I expected (cracked storytelling), which is still excellent, but I wished there was greater insights into seeing past conventional wisdom, which is what thinking like a freak means. Still a great book."
|
"review": "More like the other Freakonomics books than I expected (cracked storytelling), which is still excellent, but I wished there was greater insights into seeing past conventional wisdom, which is what thinking like a freak means. Still a great book."
|
||||||
},
|
},
|
||||||
"Fooled By Randomness": {
|
|
||||||
"filename": "fooledbyrandomness.jpg",
|
|
||||||
"link": "https://www.amazon.com/Fooled-Randomness-Hidden-Chance-Markets-dp-B006Q7VYC4/dp/B006Q7VYC4/ref=dp_ob_title_bk",
|
|
||||||
"review": "A lengthy compendium on probabilistic reasoning that helped kick off a curiosity of indefinite computation. There's more ancient philosophy than a book like this really needs but the occasional brazen punchline from the contemporary anecdotes make it bearable."
|
|
||||||
},
|
|
||||||
"The Tyranny of Metrics": {
|
|
||||||
"filename": "TyrannyOfMetrics.jpg",
|
|
||||||
"link": "https://www.amazon.com/Tyranny-Metrics-Jerry-Z-Muller/dp/0691174954",
|
|
||||||
"review": "Library find. Very appreciated read given my field of study. Adds a new lens on the cost of information and how it impacts us from the cube office to the oval office."
|
|
||||||
},
|
|
||||||
"The Accidental Superpower": {
|
"The Accidental Superpower": {
|
||||||
"filename": "theAccidentalSuperpower.jpeg",
|
"filename": "theAccidentalSuperpower.jpeg",
|
||||||
"link": "https://zeihan.com/",
|
"link": "https://zeihan.com/",
|
||||||
@@ -80,17 +59,12 @@
|
|||||||
"No, They Can't": {
|
"No, They Can't": {
|
||||||
"filename": "no-they-cant.jpeg",
|
"filename": "no-they-cant.jpeg",
|
||||||
"link": "https://www.goodreads.com/book/show/13260131-no-they-can-t",
|
"link": "https://www.goodreads.com/book/show/13260131-no-they-can-t",
|
||||||
"review": "I much preferred Give Me A Break (which I read first). Stossel's writing style in this book is less developed - it feels aimless and with an intent to lecture."
|
"review": "I much preferred Give Me A Break (which I read first). Sossel's writing style in this book is less developed - it feels aimless and with an intent to lecture."
|
||||||
},
|
},
|
||||||
"Give Me a Break": {
|
"Give Me a Break": {
|
||||||
"filename": "giveMeABreak.jpeg",
|
"filename": "giveMeABreak.jpeg",
|
||||||
"link": "https://www.amazon.com/Give-Me-Break-Exposed-Hucksters-ebook/dp/B000FC2NF8/",
|
"link": "https://www.amazon.com/Give-Me-Break-Exposed-Hucksters-ebook/dp/B000FC2NF8/",
|
||||||
"review": "I expected a boring autobiography-type book, but instead is a glimpse inside Stossel's work that transformed itself as it transformed his view."
|
"review": "I expected a boring autobiography-type book, but instead is a glimpse inside Stossel's work that transformed itself as it transformed his view. Was very happy to see a figure of similar personal ideology. Probably made it a little too easy to swallow that pill."
|
||||||
},
|
|
||||||
"Reign of Terror": {
|
|
||||||
"filename": "reignofterror.jpg",
|
|
||||||
"link": "https://www.amazon.com/Reign-Terror-Destabilized-America-Produced/dp/1984879774",
|
|
||||||
"review": "Packed with real news events and first person accounts, Reign of Terror chronicles the story of politics and intelligence agencies during the War on Terror. In typical journalist fashion, the populist (read: racist) cause for the events is mostly conjecture to fit a progressive narrative. Nonetheless, a comprehensive history of malpractice in public office."
|
|
||||||
},
|
},
|
||||||
"Zero To One": {
|
"Zero To One": {
|
||||||
"filename": "zeroToOne.jpeg",
|
"filename": "zeroToOne.jpeg",
|
||||||
@@ -107,26 +81,21 @@
|
|||||||
"link": "https://www.amazon.com/Discipline-Destiny-Power-Self-Control-Virtues/dp/0593191692",
|
"link": "https://www.amazon.com/Discipline-Destiny-Power-Self-Control-Virtues/dp/0593191692",
|
||||||
"review": "Much like the first in its series - small chapters (very helpful) each with inspiring insider stories of figures of history. Anyone capable of learning from these figures would benefit greatly from implementing the virtues in this series."
|
"review": "Much like the first in its series - small chapters (very helpful) each with inspiring insider stories of figures of history. Anyone capable of learning from these figures would benefit greatly from implementing the virtues in this series."
|
||||||
},
|
},
|
||||||
"Right Thing, Right Now": {
|
|
||||||
"filename": "rightthingrightnow.png",
|
|
||||||
"link": "https://www.amazon.com/Right-Thing-Now-Values-Character/dp/0593191714",
|
|
||||||
"review": "As the third in its series, the virtue of justice derives a large portion of its meaning from the previous two. While still an good read with a valuable influence for personal growth, it lacks a distinction between justice as a virtue and fighting for the right cause. Some sections preach for ideological purity while others insist on pragmatism which is a pretty important detail regarding justice."
|
|
||||||
},
|
|
||||||
"On Grand Strategy": {
|
"On Grand Strategy": {
|
||||||
"filename": "onGrandStrategy.jpeg",
|
"filename": "onGrandStrategy.jpeg",
|
||||||
"link": "https://www.amazon.com/Grand-Strategy-John-Lewis-Gaddis/dp/1594203512",
|
"link": "https://www.amazon.com/Grand-Strategy-John-Lewis-Gaddis/dp/1594203512",
|
||||||
"review": "Book for the academically-inclined. Not fun to read. Big words scary. It's insightful to be sure but I wouldn't read it again. The message on conceptual contradictions has stuck with me. Quite the brain food."
|
"review": "Book for the academically-inclined. Not fun to read. Big words scary. It's insightful to be sure but I wouldn't read it again. The message on conceptual contradictions has stuck with me. Quite the brain food."
|
||||||
},
|
},
|
||||||
|
"The Parasitic Mind": {
|
||||||
|
"filename": "theParasiticMind.jpeg",
|
||||||
|
"link": "https://www.amazon.com/Parasitic-Mind-Infectious-Killing-Common/dp/1684512298/",
|
||||||
|
"review": "The humor is the most memorable part but the concepts are no slouches. The contemporary culture war basis makes it tricky to talk about, but it absolutely should be discussed."
|
||||||
|
},
|
||||||
"David and Goliath": {
|
"David and Goliath": {
|
||||||
"filename": "davidAndGoliath.png",
|
"filename": "davidAndGoliath.png",
|
||||||
"link": "https://www.amazon.com/David-Goliath-Underdogs-Misfits-Battling/dp/0316239852/",
|
"link": "https://www.amazon.com/David-Goliath-Underdogs-Misfits-Battling/dp/0316239852/",
|
||||||
"review": "Book contains takes that may not be hot, but *are* incredibly based. In a sentence: Goliath is only the giant from the wrong perspectives. The only reason it's not one of my favorites is that it's tamer than the aggressively standoffish and hilarious."
|
"review": "Book contains takes that may not be hot, but *are* incredibly based. In a sentence: Goliath is only the giant from the wrong perspectives. The only reason it's not one of my favorites is that it's tamer than the aggressively standoffish and hilarious."
|
||||||
},
|
},
|
||||||
"The Scout Mindset": {
|
|
||||||
"filename": "scoutMindset.png",
|
|
||||||
"link": "https://www.amazon.com/Scout-Mindset-People-Things-Clearly-ebook/dp/B07L2HQ26K/",
|
|
||||||
"review": "Felt like a list of things that I already do that I should be more mindful of. Maybe that's just me. There was some interesting mental probabilism sprinkled in the first half but the second half did not have much new to say. Good but not eye-opening."
|
|
||||||
},
|
|
||||||
"Verbal Judo": {
|
"Verbal Judo": {
|
||||||
"filename": "verbalJudo.png",
|
"filename": "verbalJudo.png",
|
||||||
"link": "https://www.amazon.com/Verbal-Judo-Second-Gentle-Persuasion-ebook/dp/B00FJ3CMI6/",
|
"link": "https://www.amazon.com/Verbal-Judo-Second-Gentle-Persuasion-ebook/dp/B00FJ3CMI6/",
|
||||||
@@ -137,11 +106,6 @@
|
|||||||
"link": "https://www.amazon.com/YOU-READ-ANYONE-David-Lieberman-ebook/dp/B001J6OV0Y",
|
"link": "https://www.amazon.com/YOU-READ-ANYONE-David-Lieberman-ebook/dp/B001J6OV0Y",
|
||||||
"review": "Not as page-turning as many of the others and clearly not as memorable. The techniques pique curiosity but are difficult to use without practice."
|
"review": "Not as page-turning as many of the others and clearly not as memorable. The techniques pique curiosity but are difficult to use without practice."
|
||||||
},
|
},
|
||||||
"The Parasitic Mind": {
|
|
||||||
"filename": "theParasiticMind.jpeg",
|
|
||||||
"link": "https://www.amazon.com/Parasitic-Mind-Infectious-Killing-Common/dp/1684512298/",
|
|
||||||
"review": "The humor is the most memorable part but the concepts are no slouches. The contemporary culture war basis makes it tricky to talk about, but it absolutely should be discussed."
|
|
||||||
},
|
|
||||||
"Profiles in Courage": {
|
"Profiles in Courage": {
|
||||||
"filename": "profilesInCourage.jpeg",
|
"filename": "profilesInCourage.jpeg",
|
||||||
"link": "https://www.amazon.com/Profiles-Courage-John-F-Kennedy/dp/0060854936",
|
"link": "https://www.amazon.com/Profiles-Courage-John-F-Kennedy/dp/0060854936",
|
||||||
@@ -150,7 +114,12 @@
|
|||||||
"Where Good Ideas Come From": {
|
"Where Good Ideas Come From": {
|
||||||
"filename": "where-good-ideas-come-from.png",
|
"filename": "where-good-ideas-come-from.png",
|
||||||
"link": "https://www.goodreads.com/book/show/8034188-where-good-ideas-come-from",
|
"link": "https://www.goodreads.com/book/show/8034188-where-good-ideas-come-from",
|
||||||
"review": "I got this book at a recycling center. I didn't want to read it or like it. Unfortunately, it's pretty good. 200 pages of considerate review of how innovation comes to be + suggestions to expand the utility of your ideas (I've adopted several!)"
|
"review": "I got this book at a recycling center. I didn't want to read it or like it. Unfortnuately, it's pretty good. 200 pages of considerate review of how innovation comes to be + suggestions to expand the utility of your ideas (I've adopted several!)"
|
||||||
|
},
|
||||||
|
"Make Your Bed": {
|
||||||
|
"filename": "makeYourBed.jpg",
|
||||||
|
"link": "https://www.amazon.com/Make-Your-Bed-Little-Things/dp/1455570249",
|
||||||
|
"review": "Something small to read on a rainy day or flight. Valuable advice condensed into personal stories that stretch beyond anecdotes."
|
||||||
},
|
},
|
||||||
"12 Rules for Life": {
|
"12 Rules for Life": {
|
||||||
"filename": "12RulesForLife.jpg",
|
"filename": "12RulesForLife.jpg",
|
||||||
@@ -166,11 +135,6 @@
|
|||||||
"filename": "HitchhikersGuideToTheGalaxy.jpeg",
|
"filename": "HitchhikersGuideToTheGalaxy.jpeg",
|
||||||
"link": "https://www.amazon.com/Hitchhikers-Guide-Galaxy-Douglas-Adams/dp/0345418913",
|
"link": "https://www.amazon.com/Hitchhikers-Guide-Galaxy-Douglas-Adams/dp/0345418913",
|
||||||
"review": "It's alright. It felt like an aimless journey without defined boundaries that reveled in that fact for irony and wit points."
|
"review": "It's alright. It felt like an aimless journey without defined boundaries that reveled in that fact for irony and wit points."
|
||||||
},
|
|
||||||
"The Adventures of Sherlock Holmes": {
|
|
||||||
"filename": "sherlockholmes.jpg",
|
|
||||||
"link": "https://www.amazon.com/Adventures-Sherlock-Holmes-Arthur-Conan/dp/0141034332",
|
|
||||||
"review": "Had there not been half a dozen TV shows and movies about Sherlock Holmes all pulling from the same source material, I might have been intrigued. Instead, I felt like I was proofreading an old English fan rewrite of a book that I had already read. By today's standards, the outcomes were very telegraphed. Still enjoyed thinking through the deductions, though."
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"homelab": {
|
|
||||||
"title": "AI Homelab and Self Hosted Web Tooling",
|
|
||||||
"tagline": "A self-hosted cluster serving Mixture-of-Experts models beyond their rated VRAM and independent web services",
|
|
||||||
"body": "<p>I refined a method to pool GPUs from different vendors and generations into a single inference backend of roughly 20 GB over Vulkan. FreeToken, a bleeding-edge MoE inference server, fronts the cluster and handles the elastic inference, running Mixture-of-Experts models with far more total parameters than the cluster's VRAM would normally allow. My own scripts handle KV caching and system-prompt compaction, which is what makes the setup harness-capable.</p><p>The same rig trains as well as it serves, having refined Qwen SLMs and diffusion image models. All this is hosted alongside my personal web assets, like this website. I voluntarily subject myself to the maintenance of production-grade systems on every level of the tech stack to ensure that I survive the Big Tech apocalypse.</p>",
|
|
||||||
"stack": ["FreeToken", "ComfyUI", "PEFT / TRL", "Docker", "Cloudflare", "Reverse Proxy"],
|
|
||||||
"image": "photos/deepdives/homelab-dashboard.png",
|
|
||||||
"caption": "Cluster dashboard during a long inference run."
|
|
||||||
},
|
|
||||||
"capstone": {
|
|
||||||
"title": "Subatomic Particle Tracing and Anomaly Control",
|
|
||||||
"tagline": "My Master's Capstone: Building a Diffusion Cloud Chamber and using stereo reconstruction to classify Muons and Alpha/Beta particles.",
|
|
||||||
"body": "<p>My ongoing Data Science Capstone Project combines existing utilities for cheap quantum demonstrations and real world measuring techniques to create effective sensing of subatomic phenomena without breaking the bank or into the IAEA</p>",
|
|
||||||
"stack": ["Ego"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
60
src/static/json/pages.json
Executable file → Normal file
@@ -1,22 +1,22 @@
|
|||||||
{
|
{
|
||||||
"home": {
|
"home": {
|
||||||
"template": "home.html",
|
"template": "home.html",
|
||||||
"title": "Andrew Simonson - Data Scientist & Researcher",
|
"title": "Andrew Simonson - Portfolio Home",
|
||||||
"description": "Andrew Simonson - Data Scientist at Ecolab, graduate student at RIT. Projects, research papers, and more.",
|
"description": "Andrew Simonson's Digital Portfolio home",
|
||||||
"canonical": "/"
|
"canonical": "/"
|
||||||
},
|
},
|
||||||
"status": {
|
|
||||||
"template": "status.html",
|
|
||||||
"title": "Andrew Simonson - Status Page",
|
|
||||||
"description": "Status page for my services",
|
|
||||||
"canonical": "/status"
|
|
||||||
},
|
|
||||||
"projects": {
|
"projects": {
|
||||||
"template": "projects.html",
|
"template": "projects.html",
|
||||||
"title": "Projects & Research - Andrew Simonson",
|
"title": "Andrew Simonson - Projects",
|
||||||
"description": "Data science projects, geospatial analysis, research papers, and software experiments by Andrew Simonson.",
|
"description": "Recent projects by Andrew Simonson on his lovely portfolio website :)",
|
||||||
"canonical": "/projects"
|
"canonical": "/projects"
|
||||||
},
|
},
|
||||||
|
"about": {
|
||||||
|
"template": "about.html",
|
||||||
|
"title": "Andrew Simonson - About Me",
|
||||||
|
"description": "About Andrew Simonson",
|
||||||
|
"canonical": "/about"
|
||||||
|
},
|
||||||
"books": {
|
"books": {
|
||||||
"template": "books.html",
|
"template": "books.html",
|
||||||
"title": "Andrew Simonson - Bookshelf",
|
"title": "Andrew Simonson - Bookshelf",
|
||||||
@@ -25,46 +25,8 @@
|
|||||||
},
|
},
|
||||||
"duck": {
|
"duck": {
|
||||||
"template": "duck.html",
|
"template": "duck.html",
|
||||||
"title": "You've been ducked!",
|
"title":"You've been ducked!",
|
||||||
"description": "Face it, you've been ducked",
|
"description": "Face it, you've been ducked",
|
||||||
"canonical": "/duck"
|
"canonical": "/duck"
|
||||||
},
|
|
||||||
"about": {
|
|
||||||
"template": "about.html",
|
|
||||||
"title": "About, Timeline & Certifications - Andrew Simonson",
|
|
||||||
"description": "Bio, career/education timeline, and certifications for Andrew Simonson - Data Scientist at Ecolab.",
|
|
||||||
"canonical": "/about",
|
|
||||||
"timeline": {
|
|
||||||
"ecolab": {
|
|
||||||
"title": "Data Scientist / Data Engineer — Ecolab",
|
|
||||||
"date": "January 2024 – Present",
|
|
||||||
"content": "<p class=\"timeitem-org\">Ecolab · Saint Paul, MN</p><ul><li>Primary model developer of RushReady from inception through multimillion-dollar product commercialization</li><li>Engineered near-real-time data platform with Delta Live Tables and automated MLOps lifecycle across QSR brands</li><li>Built explainable anomaly detection and brand-configurable recommendations, increasing speed of service by 20%</li><li>Represented Ecolab as liaison in Microsoft's 100-member AI accelerator program</li></ul>",
|
|
||||||
"classes": "experience"
|
|
||||||
},
|
|
||||||
"rit_ms": {
|
|
||||||
"title": "M.S. Data Science — RIT",
|
|
||||||
"date": "Dec 2026 (expected)",
|
|
||||||
"content": "<p class=\"timeitem-org\">Rochester Institute of Technology · Rochester, NY</p><ul><li>Focus on probability theory, statistical learning, and Bayesian methods</li><li>Capstone: Fall 2026</li></ul>",
|
|
||||||
"classes": "education"
|
|
||||||
},
|
|
||||||
"dow_chemical": {
|
|
||||||
"title": "Data Engineer — Dow Chemical",
|
|
||||||
"date": "January 2023 – May 2023",
|
|
||||||
"content": "<p class=\"timeitem-org\">Dow Chemical · Freeport, TX</p><ul><li>Independently built reactive chemistry analysis Flask app encoding adiabatic correction and exotherm-detection logic across 9 test types</li><li>Architected object-model abstraction, decoupling test-type parsers from report generation and replacing 4 legacy VBA tools</li><li>Product became the interdepartmental data standard, saving >1,020 hours (~0.65 FTE) annually</li></ul>",
|
|
||||||
"classes": "experience"
|
|
||||||
},
|
|
||||||
"rit_bs": {
|
|
||||||
"title": "B.S. Computer Science & Data Science — RIT",
|
|
||||||
"date": "Dec 2024",
|
|
||||||
"content": "<p class=\"timeitem-org\">Rochester Institute of Technology · Rochester, NY</p><ul><li>GPA 3.63 · Dean's List</li><li>Minor in International Relations</li><li>MicroMasters in Data Science – UC San Diego (edX)</li></ul>",
|
|
||||||
"classes": "education"
|
|
||||||
},
|
|
||||||
"csh": {
|
|
||||||
"title": "E-Board Member & Presenter — CSH",
|
|
||||||
"date": "Aug 2021 – Present",
|
|
||||||
"content": "<p class=\"timeitem-org\">Computer Science House · Rochester, NY</p><ul><li>Presented seminars on web scraping, analytics, and GIS</li><li>Built and maintained web services for 80+ members</li></ul>",
|
|
||||||
"classes": "experience technical"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
178
src/static/json/projects.json
Executable file → Normal file
@@ -1,96 +1,81 @@
|
|||||||
{
|
{
|
||||||
"Human vs AI Code Smell Study": {
|
|
||||||
"status": "complete",
|
|
||||||
"classes": "programming",
|
|
||||||
"bgi": "aiCodeGroups.png",
|
|
||||||
"content": "Research paper comparing human vs AI code maintainability based on mature code smell detection algorithms.",
|
|
||||||
"links": [
|
|
||||||
[
|
|
||||||
"globe",
|
|
||||||
"https://files.asimonson.com/u/AIcodeSmells.pdf",
|
|
||||||
"Paper"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Generalized Trust Review": {
|
|
||||||
"status": "complete",
|
|
||||||
"classes":"programming",
|
|
||||||
"bgi": "blanketTrust.png",
|
|
||||||
"content": "Short analysis correlating societal blanket trust of press and scientific institutions.",
|
|
||||||
"links": [
|
|
||||||
[
|
|
||||||
"globe",
|
|
||||||
"https://files.asimonson.com/u/blanketTrust.pdf",
|
|
||||||
"Paper"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PhysCom - Physical Combinatorics": {
|
|
||||||
"status": "WIP",
|
|
||||||
"classes": "programming",
|
|
||||||
"content": "Experimental innovation engine operating on physical attributes and limitations of proven existing technologies with further AI review."
|
|
||||||
},
|
|
||||||
"Antietam-Conococheague Watershed Monitoring": {
|
|
||||||
"status": "complete",
|
|
||||||
"classes": "geospatial",
|
|
||||||
"bgi": "watershedTemps.png",
|
|
||||||
"content": "Live geospatial analysis of Maryland's Antietam and Conococheague sub-watersheds, monitoring water quality and temperatures through the summer months for governmental environment health review boards."
|
|
||||||
},
|
|
||||||
"Automotive Brand Valuation Analysis": {
|
|
||||||
"status": "complete",
|
|
||||||
"classes": "programming",
|
|
||||||
"bgi": "automotiveBrandAnalysis.png",
|
|
||||||
"content": "Brand valuation analysis of the used car market, measuring value decay by mileage to extrapolate qualities such as perceived reliability and persistent value of luxury features."
|
|
||||||
},
|
|
||||||
"RIT Hotspots": {
|
"RIT Hotspots": {
|
||||||
"status": "incomplete",
|
"status": "WIP",
|
||||||
"classes": "pinned geospatial programming",
|
"classes": "pinned geospacial programming",
|
||||||
"bgi": "hotspotsrit.png",
|
"bgi": "hotspotsrit.png",
|
||||||
"content": "Live crowd migration map using RIT occupancy data. It seems RIT didn't like me exposing their surveillance state but since they didn't want to talk to me about it they instead changed the service response schema a few times. When that didn't stop me they just shut down the whole service. Nerds.",
|
"content": "Live crowd migration map using RIT occupancy data",
|
||||||
"links": [
|
"links": [
|
||||||
["github", "https://github.com/asimonson1125/hotspotsrit", "git repo"]
|
[
|
||||||
|
"github", "https://github.com/asimonson1125/hotspotsrit", "git repo"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"globe", "https://asimonson.com/hotspots", "demo"
|
||||||
|
]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Calorimetry Analysis Engineering": {
|
"LogicFlow": {
|
||||||
"status": "complete",
|
"status": "incomplete",
|
||||||
"classes": "pinned programming",
|
"classes": "programming",
|
||||||
"bgi": "calorimeterAnalysis.png",
|
"bgi": "logicflow.jpg",
|
||||||
"content": "An analytical toolkit designed for reactive chemistry analysis, especially calorimetry. Works include automatic analysis, alerting unusual and dangerous results derived from a wide range of testing environments and equipment",
|
"content": "Translate paragraphs to logical flowcharts, powered by ChatGPT Winner of CSHacks' Best Use of AI by Paychex",
|
||||||
"links": []
|
"links": [
|
||||||
|
[
|
||||||
|
"github", "https://github.com/asimonson1125/LogicFlow", "git repo"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"globe", "https://devpost.com/software/logicflow", "Hackathon listing"
|
||||||
|
]
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"Geography of Alternative Energy": {
|
"Alternative Energy Map": {
|
||||||
"status": "complete",
|
"status": "complete",
|
||||||
"classes": "pinned geospatial",
|
"classes": "pinned geospacial",
|
||||||
"bgi": "energyGeography.png",
|
"bgi": "geovisF.png",
|
||||||
"content": "An ArcGIS geospatial analysis comparing the difference in effectiveness of wind, solar, and geothermal energy across the continental 48 United States.",
|
"content": "ArcGIS Map of the most effective alternative energy sources in the continental United States",
|
||||||
"links": [
|
"links": [
|
||||||
[
|
[
|
||||||
"globe",
|
"globe",
|
||||||
"https://ritarcgis.maps.arcgis.com/apps/dashboards/17d5bda01edc4a2eb6205a4922d889c9",
|
"https://ritarcgis.maps.arcgis.com/apps/dashboards/17d5bda01edc4a2eb6205a4922d889c9",
|
||||||
"Dashboard"
|
"ArcGIS"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"OccupyRIT": {
|
"OccupyRIT": {
|
||||||
"status": "complete",
|
"status": "WIP",
|
||||||
"classes": "pinned programming",
|
"classes": "programming",
|
||||||
"bgi": "occupyRIT.png",
|
"bgi": "occupyRIT.png",
|
||||||
"content": "Collects RIT Gym Occupancy data, determining busiest workout times",
|
"content": "Collects RIT Gym Occupancy data, determining busiest workout times",
|
||||||
"links": [
|
"links": [
|
||||||
["github", "https://github.com/asimonson1125/Occupy-RIT", "git repo"]
|
["github", "https://github.com/asimonson1125/Occupy-RIT", "git repo"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Portfolio Website": {
|
"Chesscom Embeds": {
|
||||||
"status": "complete",
|
"status": "complete",
|
||||||
"classes": "programming",
|
"classes": "programming",
|
||||||
"content": "This website is my personal sandbox where I've integrated some of my data projects via docker cluster. It is self hosted and dynamic, generally free of the tech debt that comes with pre-designed sites and excessive framework application. Yeah, I can do E2E.",
|
"bgi": "chessbed.png",
|
||||||
|
"content": "A template for creating Chess.com user profile embeds",
|
||||||
"links": [
|
"links": [
|
||||||
["globe", "https://asimonson.com", "Homepage"],
|
["github", "https://github.com/asimonson1125/chesscom-embed", "git repo"]
|
||||||
[
|
]
|
||||||
"github",
|
},
|
||||||
"https://github.com/asimonson1125/asimonson1125.github.io",
|
"Resume": {
|
||||||
"git repo"
|
"status": "WIP",
|
||||||
]
|
"classes": "programming",
|
||||||
|
"bgi": "resume.png",
|
||||||
|
"content": "My Resume, made in LaTeX with a custom design derived by the AltaCV template on OverLeaf",
|
||||||
|
"links": [
|
||||||
|
["github", "https://github.com/asimonson1125/Resume", "git repo"],
|
||||||
|
["globe", "https://asimonson.com/Resume.pdf", "Resume"]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Digital Portfolio": {
|
||||||
|
"status": "WIP",
|
||||||
|
"classes": "programming",
|
||||||
|
"bgi": "website.png",
|
||||||
|
"content": "My personal portfolio website (you're on it now!)",
|
||||||
|
"links": [
|
||||||
|
["github", "https://github.com/asimonson1125/asimonson1125.github.io", "git repo"],
|
||||||
|
["globe", "https://asimonson.com", "site link"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Slate": {
|
"Slate": {
|
||||||
@@ -99,21 +84,62 @@
|
|||||||
"bgi": "slate.png",
|
"bgi": "slate.png",
|
||||||
"content": "Slate is a web app designed to help event coordinators schedule events by congregating participant calendar data. Includes Computer Science House account integration",
|
"content": "Slate is a web app designed to help event coordinators schedule events by congregating participant calendar data. Includes Computer Science House account integration",
|
||||||
"links": [
|
"links": [
|
||||||
["globe", "https://slate.csh.rit.edu", "site link"],
|
["github", "https://github.com/asimonson1125/Slate", "git repo"],
|
||||||
["github", "https://github.com/asimonson1125/Slate", "git repo"]
|
["globe", "https://slate.csh.rit.edu", "site link"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Monte Carlo Engine for NationsGame": {
|
"HvZ Bot": {
|
||||||
|
"status": "complete",
|
||||||
|
"classes": "programming",
|
||||||
|
"bgi": "",
|
||||||
|
"content": "A Discord bot to handle role management and statistics for RIT's Humans vs. Zombies games",
|
||||||
|
"links": [
|
||||||
|
["github", "https://github.com/asimonson1125/HvZ-bot", "git repo"]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"FinTech": {
|
||||||
|
"status": "WIP",
|
||||||
|
"classes": "pinned programming",
|
||||||
|
"bgi": "",
|
||||||
|
"content": "A team derived from the RIT Financial Management Association dedicated to learning about financial management of equities using automated solutions developed by students",
|
||||||
|
"links": [
|
||||||
|
["github", "https://github.com/LukeHorigan/Financial-Management-Assocation-", "git repo"]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Browser Trivia Bot": {
|
||||||
|
"status": "complete",
|
||||||
|
"classes": "programming",
|
||||||
|
"bgi": "",
|
||||||
|
"content": "A tampermonkey tool used to automatically answer and submit online trivia forms, which can be tailored to different site layouts. Source currently private.",
|
||||||
|
"links": [
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"NationsGame Rolls Sim": {
|
||||||
"status": "complete",
|
"status": "complete",
|
||||||
"classes": "programming",
|
"classes": "programming",
|
||||||
"bgi": "ceoOfYugo.png",
|
"bgi": "ceoOfYugo.png",
|
||||||
"content": "A simulator for the browser game, NationsGame, to analyze unit composition and predict in-game victors and unit statistics. Unfortunately, NationsGame is now defunct. Limited screenshots of functionality.",
|
"content": "A simulator for the browser game, NationsGame, to analyze unit composition and predict in-game victors and unit statistics. Unfortunately, NationsGame is now defunct. Limited screenshots of functionality.",
|
||||||
"links": [
|
"links": [
|
||||||
[
|
["github", "https://github.com/asimonson1125/NG-Rolls-Simulator", "git repo"]
|
||||||
"github",
|
]
|
||||||
"https://github.com/asimonson1125/NG-Rolls-Simulator",
|
},
|
||||||
"git repo"
|
"VEXcode Button Engine": {
|
||||||
]
|
"status": "complete",
|
||||||
|
"classes": "programming",
|
||||||
|
"bgi": "vexcodeButtons.jpeg",
|
||||||
|
"content": "VEXcode button library + examples and template for the VEX V5 brain",
|
||||||
|
"links": [
|
||||||
|
["github", "https://github.com/asimonson1125/VEXcode-Button-Generator", "git repo"],
|
||||||
|
["globe", "https://www.vexforum.com/t/vexcode-button-generator/72450", "Forum post"]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"WinKeylogger": {
|
||||||
|
"status": "complete",
|
||||||
|
"classes": "programming",
|
||||||
|
"bgi": "",
|
||||||
|
"content": "A C++ keylogger for windows based off a Udemy course with my custom modifications and powershell script",
|
||||||
|
"links": [
|
||||||
|
["github", "https://github.com/asimonson1125/WinKeylogger", "git repo"]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
43
src/static/json/skills.json
Executable file → Normal file
@@ -1,35 +1,26 @@
|
|||||||
{
|
{
|
||||||
"Data and AI": {
|
"Data and AI": {
|
||||||
"ML": {
|
"Python": {
|
||||||
"PySpark ML": {},
|
"PyTorch/TensorFlow": {},
|
||||||
"Numpy/Pandas/Polars": {},
|
"Numpy/Pandas": {},
|
||||||
"TensorFlow": {},
|
"Selenium/BS4": {}
|
||||||
"Scikit": {}
|
|
||||||
},
|
},
|
||||||
"PySpark": {},
|
"R": {},
|
||||||
"Selenium/BS4 Web Hacking": {},
|
"SQL": {}
|
||||||
"SQL": {},
|
|
||||||
"Declarative Pipelines": {},
|
|
||||||
"ArcGIS": {}
|
|
||||||
},
|
|
||||||
"DevOps": {
|
|
||||||
"Docker": {},
|
|
||||||
"Microsoft Azure": {},
|
|
||||||
"Databricks": {},
|
|
||||||
"Kubernetes/Openshift": {},
|
|
||||||
"Cloudflare": {},
|
|
||||||
"Bash": {}
|
|
||||||
},
|
},
|
||||||
"Frontend": {
|
"Frontend": {
|
||||||
"Flask (Python)": {},
|
"Flask (Python)": {},
|
||||||
"REST APIs": {},
|
"React (Javascript)": {},
|
||||||
"Web Scraping": {}
|
"Angular (Typescript)": {}
|
||||||
},
|
},
|
||||||
"Offline Skills": {
|
"Backend & DevOps": {
|
||||||
"Circuitry": {},
|
"DevOps": {
|
||||||
"Skiing": {},
|
"Docker": {},
|
||||||
"Chess": {},
|
"Microsoft Azure": {},
|
||||||
"Plinking": {},
|
"Kubernetes/Openshift": {},
|
||||||
"Building something with trash that solves my problems": {}
|
"Bash": {}
|
||||||
|
},
|
||||||
|
"C#": {},
|
||||||
|
"C++": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
src/static/json/timeline.json
Executable file → Normal file
@@ -1,53 +1,18 @@
|
|||||||
{
|
{
|
||||||
"Data Scientist @ Ecolab": {
|
"Co-op @ Dow Chemical": {
|
||||||
"classes": "pinned experience technical",
|
|
||||||
"date": "01/2024 - Present",
|
|
||||||
"content": "Primary model developer of RushReady from inception through multimillion-dollar product commercialization. Engineered near-real-time data platform with Delta Live Tables and automated MLOps lifecycle. Built explainable anomaly detection, increasing speed of service by 20%. Represented Ecolab in Microsoft's 100-member AI accelerator program."
|
|
||||||
},
|
|
||||||
"Data Scientist / Data Engineer": {
|
|
||||||
"classes": "pinned experience technical",
|
"classes": "pinned experience technical",
|
||||||
"date": "01/2023 - 05/2023",
|
"date": "01/2023 - 05/2023",
|
||||||
"content": "Co-op under Dow Chemical's Global Reactive Chemicals team in Analytical Sciences. Independently built reactive chemistry analysis Flask app encoding adiabatic correction and exotherm-detection logic. Replaced 4 legacy VBA tools with an object-model abstraction architecture. Product became the interdepartmental data standard, saving >1,020 hours (~0.65 FTE) annually."
|
"content": "Spring 2023 Semester Co-op under Dow Chemical's Global Reactive Chemicals team in Analytical Sciences. Responsibilities included management of chemical compatability data and tool creation for parsing, generating, and submitting reports."
|
||||||
},
|
|
||||||
"Rochester Institute of Technology — M.S.": {
|
|
||||||
"classes": "pinned education technical",
|
|
||||||
"date": "01/2023 - 12/2026",
|
|
||||||
"content": "Data Science M.S. with dual cluster in Data Science and AI. Capstone Fall 2026. Certified by Databricks in ML Model Deployment, Retrieval Agents, and MLOps. Certified by Microsoft in Data Analysis Career Essentials and Docker Foundations."
|
|
||||||
},
|
|
||||||
"Rochester Institute of Technology — B.S.": {
|
|
||||||
"classes": "pinned education technical",
|
|
||||||
"date": "08/2021 - 12/2024",
|
|
||||||
"content": "Computer Science B.S. (GPA 3.63, Dean's List) with a minor in International Relations. Active member of Computer Science House — built and maintained web services for 80+ members, presented seminars on web scraping, analytics, and GIS."
|
|
||||||
},
|
|
||||||
"UCSanDiegoX Data Science MicroMasters": {
|
|
||||||
"classes": "education technical",
|
|
||||||
"date": "2024",
|
|
||||||
"content": "Completed MicroMasters program in Data Science through UC San Diego on edX."
|
|
||||||
},
|
},
|
||||||
"Started Portfolio": {
|
"Started Portfolio": {
|
||||||
"classes": "",
|
"classes": "",
|
||||||
"date": "08/26/2021",
|
"date": "08/26/2021",
|
||||||
"content": "I started building this website on this day. I wish I could say I was farther along than I am."
|
"content": "I started building this website on this day. I wish I could say I was farther along than I am."
|
||||||
},
|
},
|
||||||
"Human vs AI Code Smell Study": {
|
"Rochester Institute of Technology": {
|
||||||
"classes": "technical",
|
"classes": "pinned education technical",
|
||||||
"date": "2024 - 2025",
|
"date": "08/2021 - 12/2024",
|
||||||
"content": "Analyzed 85K+ code definitions comparing AI vs human code maintainability via static analysis and non-parametric statistics. Found AI code carries 3-4x more structural debt invisible to reviewers."
|
"content": "Studying in Rochester Institute of Technology's Computer Science BS program with a minor in International Relations."
|
||||||
},
|
|
||||||
"Generalized Trust Review": {
|
|
||||||
"classes": "technical",
|
|
||||||
"date": "2023 - 2024",
|
|
||||||
"content": "Cross-national correlation analysis of media and science trust across 128 countries with subgroup OLS regression. Found trust transfer attenuates 5.7x in low press-freedom regimes."
|
|
||||||
},
|
|
||||||
"Antietam Watershed Monitoring": {
|
|
||||||
"classes": "technical",
|
|
||||||
"date": "2023",
|
|
||||||
"content": "ArcGIS choropleth dashboard monitoring stream temps and biotic indices across Upper Potomac sub-watersheds. Flags exceedances of healthy stream conditions for state environmental review."
|
|
||||||
},
|
|
||||||
"Hackathon Awards": {
|
|
||||||
"classes": "technical",
|
|
||||||
"date": "2023 - 2024",
|
|
||||||
"content": "CSHacks - Best Use of AI (Paychex). Tiger Games - Social Impact Winner. HACK.COMS '24 - Accessibility Winner."
|
|
||||||
},
|
},
|
||||||
"Pretzel & Pizza Creations": {
|
"Pretzel & Pizza Creations": {
|
||||||
"classes": "experience",
|
"classes": "experience",
|
||||||
@@ -62,11 +27,11 @@
|
|||||||
"Boonsboro High School": {
|
"Boonsboro High School": {
|
||||||
"classes": "education",
|
"classes": "education",
|
||||||
"date": "09/2016 - 06/2021",
|
"date": "09/2016 - 06/2021",
|
||||||
"content": "Graduated high school with highest honors. Member of National Honor Society, Academic Team County Champions. Participated in Physics Olympics, Robotics Club, and scored at state championships in Cross Country and Track and Field (4x800, 800)."
|
"content": "Graduated high school with highest honors.\nMember of National Honor Society, Academic Team County Champions. Participated in Physics Olympics, Robotics Club, and scored at state championships in Cross Country and Track and Field (4x800, 800)."
|
||||||
},
|
},
|
||||||
"Vex Robotics Team Lead/Club President": {
|
"Vex Robotics Team Lead/Club Preisdent": {
|
||||||
"classes": "technical",
|
"classes": "technical",
|
||||||
"date": "10/2015 - 04/2021",
|
"date": "10/2015 - 04/2021",
|
||||||
"content": "Led 5 teams through middle and high school to VEX Robotics Competitions, elevating Boonsboro from county group-stage elimination to its first state championship participation. Reorganized club and set up its first interface with the community + sponsors."
|
"content": "Led 5 teams through middle and high school to VEX Robotics Competitions, elevating Boonsboro from county group-stage elimination to its first state championship participation. Reorganized club and set up its first interface with the community + sponsors"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/static/photos/AcademicTeam.jpg
Normal file
|
After Width: | Height: | Size: 98 KiB |
BIN
src/static/photos/WeThePeople.jpg
Normal file
|
After Width: | Height: | Size: 813 KiB |
BIN
src/static/photos/WeThePeople_Districts.jpg
Normal file
|
After Width: | Height: | Size: 898 KiB |
BIN
src/static/photos/WeThePeople_NationalsSetup.jpg
Normal file
|
After Width: | Height: | Size: 463 KiB |
|
Before Width: | Height: | Size: 987 B |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 620 B |
0
src/static/photos/books/12RulesForLife.jpg
Executable file → Normal file
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
0
src/static/photos/books/BeyondOrder.jpg
Executable file → Normal file
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
0
src/static/photos/books/HitchhikersGuideToTheGalaxy.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 320 KiB After Width: | Height: | Size: 320 KiB |
|
Before Width: | Height: | Size: 110 KiB |
0
src/static/photos/books/autobioOfJefferson.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
0
src/static/photos/books/courageIsCalling.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
0
src/static/photos/books/davidAndGoliath.png
Executable file → Normal file
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
0
src/static/photos/books/disciplineIsDestiny.jpg
Executable file → Normal file
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
0
src/static/photos/books/disunitedNations.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 17 KiB |
0
src/static/photos/books/freakonomics.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
0
src/static/photos/books/giveMeABreak.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 41 KiB |
0
src/static/photos/books/makeYourBed.jpg
Executable file → Normal file
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
0
src/static/photos/books/no-they-cant.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 308 KiB After Width: | Height: | Size: 308 KiB |
0
src/static/photos/books/onGrandStrategy.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 111 KiB |
0
src/static/photos/books/profilesInCourage.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB |
0
src/static/photos/books/ratOpt.jpg
Executable file → Normal file
|
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 164 KiB |
|
Before Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 204 KiB |
|
Before Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 27 KiB |
0
src/static/photos/books/superfreakonomics.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 235 KiB |
0
src/static/photos/books/theAbsentSuperpower.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
0
src/static/photos/books/theAccidentalSuperpower.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
0
src/static/photos/books/theEndOfTheWorldIsJustTheBeginning.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 140 KiB |
0
src/static/photos/books/theParasiticMind.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
0
src/static/photos/books/theStormBeforeTheCalm.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 44 KiB |
0
src/static/photos/books/thinkLikeAFreak.jpg
Executable file → Normal file
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
0
src/static/photos/books/verbalJudo.png
Executable file → Normal file
|
Before Width: | Height: | Size: 201 KiB After Width: | Height: | Size: 201 KiB |
0
src/static/photos/books/whenToRobABank.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 129 KiB |
0
src/static/photos/books/where-good-ideas-come-from.png
Executable file → Normal file
|
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 184 KiB |
0
src/static/photos/books/youCanReadAnyone.jpg
Executable file → Normal file
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
0
src/static/photos/books/zeroToOne.jpeg
Executable file → Normal file
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |