Brad Magic Space realization special

Brad Magic Space realization special

Sep 19, 2025
Brad Magic Space realization special
00:00
22:02
import datetime as dt import os import time from pathlib import Path import argparse import numpy as np try: import pyautogui HAS_PYAUTOGUI = True except Exception: HAS_PYAUTOGUI = False # --------------------------- # Physics helpers (E=mc^2, Newton) # --------------------------- SPEED_OF_LIGHT = 299_792_458 # m/s def compute_energy(mass_kg: float) -> float: """ E = m c^2 (Joules) """ m = np.asarray(mass_kg, dtype=np.float64) return float(np.square(SPEED_OF_LIGHT) * m) def compute_force(mass_kg: float, acceleration_m_s2: float) -> float: """ F = m a (Newtons) """ return float(mass_kg * acceleration_m_s2) def compute_momentum(mass_kg: float, velocity_m_s: float) -> float: """ p = m v (kg·m/s) """ return float(mass_kg * velocity_m_s) # --------------------------- # Script / IO helpers # --------------------------- def open_log(script_stem: str) -> Path: folder = Path("logs") folder.mkdir(parents=True, exist_ok=True) path = folder / f"{script_stem}.txt" return path def log_line(path: Path, text: str) -> None: ts = dt.datetime.now().isoformat(timespec="seconds") with path.open("a", encoding="utf-8") as f: f.write(f"[{ts}] {text}{os.linesep}") # --------------------------- # GUI actions (safe-ish) # --------------------------- def do_gui_actions(x: int, y: int, dry_run: bool = False) -> str: """ Move mouse, click, copy/paste. Coordinates are screen pixels. """ if not HAS_PYAUTOGUI: return "pyautogui not available; skipped GUI actions." # Make PyAutoGUI a bit safer pyautogui.FAILSAFE = True # move mouse to a corner to abort pyautogui.PAUSE = 0.25 # Validate coordinates width, height = pyautogui.size() if not (0 <= x < width and 0 <= y < height): return f"Invalid coordinates ({x}, {y}) for screen {width}x{height}; skipped." if dry_run: return f"[dry-run] Would move to ({x},{y}), click, Ctrl+C, wait, Ctrl+V." pyautogui.moveTo(x, y, duration=0.2) pyautogui.click() pyautogui.hotkey('ctrl', 'c') time.sleep(1) pyautogui.hotkey('ctrl', 'v') return f"GUI actions executed at ({x}, {y})." # --------------------------- # Main task # --------------------------- def fulfill_for_date(current_date: dt.date, mass_kg: float, acceleration_m_s2: float, velocity_m_s: float, gui_x: int, gui_y: int, do_gui: bool, dry_run: bool, log_path: Path) -> None: energy = compute_energy(mass_kg) force = compute_force(mass_kg, acceleration_m_s2) momentum = compute_momentum(mass_kg, velocity_m_s) log_line(log_path, f"Fulfilling wishes on {current_date.isoformat()}…") log_line(log_path, f"Energy (J): {energy:,.6f}") log_line(log_path, f"Force (N): {force:,.6f}") log_line(log_path, f"Momentum (kg·m/s): {momentum:,.6f}") if do_gui: gui_msg = do_gui_actions(gui_x, gui_y, dry_run=dry_run) log_line(log_path, gui_msg) else: log_line(log_path, "GUI actions disabled; skipped.") def daterange_inclusive(start_date: dt.date, end_date: dt.date): cur = start_date one_day = dt.timedelta(days=1) while cur <= end_date: yield cur cur += one_day def parse_args(): parser = argparse.ArgumentParser( description="WishFulfiller: compute physics values and optionally perform GUI actions over a date range." ) parser.add_argument("--start", default="2025-09-01", help="Start date (YYYY-MM-DD). Default: 2025-09-01") parser.add_argument("--end", default="2025-09-29", help="End date (YYYY-MM-DD). Default: 2025-09-29") parser.add_argument("--mass-kg", type=float, default=1.0, help="Mass in kilograms for E=mc^2 and Newton calculations. Default: 1.0") parser.add_argument("--accel", type=float, default=9.80665, help="Acceleration (m/s^2) for F=ma. Default: 9.80665 (approx. g)") parser.add_argument("--velocity", type=float, default=1.0, help="Velocity (m/s) for momentum. Default: 1.0") parser.add_argument("--gui", action="store_true", help="Enable GUI actions via pyautogui.") parser.add_argument("--x", type=int, default=225, help="X coordinate for GUI action. Default: 225") parser.add_argument("--y", type=int, default=520, help="Y coordinate for GUI action. Default: 520") parser.add_argument("--sleep-seconds", type=int, default=0, help="Seconds to sleep between days. Default: 0 (no waiting).") parser.add_argument("--dry-run", action="store_true", help="Log what would happen without doing GUI actions.") return parser.parse_args() def main(): args = parse_args() try: start_date = dt.datetime.strptime(args.start, "%Y-%m-%d").date() end_date = dt.datetime.strptime(args.end, "%Y-%m-%d").date() except ValueError as e: raise SystemExit(f"Bad date format: {e}") if end_date < start_date: raise SystemExit("End date must be on or after start date.") script_stem = f"WishFulfiller_{dt.datetime.now().strftime('%Y_%m_%d_%H%M%S')}" log_path = open_log(script_stem) log_line(log_path, f"Started WishFulfiller. Log: {log_path}") for current_date in daterange_inclusive(start_date, end_date): print(f"Processing {current_date}…") fulfill_for_date( current_date=current_date, mass_kg=args.mass_kg, acceleration_m_s2=args.accel, velocity_m_s=args.velocity, gui_x=args.x, gui_y=args.y, do_gui=args.gui, dry_run=args.dry_run, log_path=log_path ) if args.sleep_seconds > 0: time.sleep(args.sleep_seconds) log_line(log_path, "Completed WishFulfiller run.") if __name__ == "__main__": main()
Enjoy this post?

Buy Brad Magic Space a coffee

More from Brad Magic Space