Your Last Computer Program

There are plenty of tutorials in the world for your first computer program, usually involving “Hello World.” But why are there not any for the last program you’ll ever write? This is the first tutorial for that, split into different scenarios:

    • Case 1: You’re paying Anthropic.
      import os; os.system("curl -fsSL https://claude.ai/install.sh | bash")

      Congrats; now you just dictate to Claude.

    • Case 2: You’re dying. Maybe don’t worry about starting a new project in this case and actually finish that Wordle-clone you promised your partner five years ago. I wish you the best.
    • Case 3: You’ve been promoted to manager.
      rm -rf /

      No more Linux for you buddy.

    • Case 4: You’ve joined a monastery. Not sure why you’re looking at this, but you can probably just write the following and be satified with your spiritual life.
      #!/usr/bin/env python3
      """
      verse_of_the_day.py from KJV
      Usage:
      python verse_of_the_day.py # today's verse
      python verse_of_the_day.py 2026-01-01 # verse for a specific date
      """
      import json
      import os
      import sys
      import hashlib
      import datetime
      import urllib.request
      CACHE_DIR = os.path.expanduser("~/.verse_of_the_day")
      CACHE_FILE = os.path.join(CACHE_DIR, "kjv.json")
      RAW_BASE = "https://raw.githubusercontent.com/aruljohn/Bible-kjv/master"
      BOOKS_URL = f"{RAW_BASE}/Books.json"

      def _book_filename(book_name: str) -> str:
      # "1 Samuel" -> "1Samuel.json", "Song of Solomon" -> "SongofSolomon.json"
      return book_name.replace(" ", "") + ".json"

      def download_bible():
      """Fetch all 66 books once and flatten into a single verse list."""
      os.makedirs(CACHE_DIR, exist_ok=True)
      with urllib.request.urlopen(BOOKS_URL) as resp:
      books = json.loads(resp.read())
      all_verses = []
      for book in books:
      url = f"{RAW_BASE}/{_book_filename(book)}"
      with urllib.request.urlopen(url) as resp:
      data = json.loads(resp.read())
      for chapter in data["chapters"]:
      for verse in chapter["verses"]:
      all_verses.append(
      {
      "ref": f"{book} {chapter['chapter']}:{verse['verse']}",
      "text": verse["text"],
      }
      )
      with open(CACHE_FILE, "w") as f:
      json.dump(all_verses, f)
      return all_verses

      def load_bible():
      if os.path.exists(CACHE_FILE):
      with open(CACHE_FILE) as f:
      return json.load(f)
      print("No local copy found — go get some wifi one last time...")
      return download_bible()

      def verse_for_date(verses, date: datetime.date):
      # Deterministic pick: same date always gives the same verse,
      # spread pseudo-randomly across all ~31,000 verses.
      digest = hashlib.sha256(date.isoformat().encode()).hexdigest()
      index = int(digest, 16) % len(verses)
      return verses[index]

      def main():
      if len(sys.argv) > 1:
      date = datetime.date.fromisoformat(sys.argv[1])
      else:
      date = datetime.date.today()
      verses = load_bible()
      verse = verse_for_date(verses, date)
      print(f"\n{date.isoformat()}")
      print(f"{verse['ref']}")
      print(f"{verse['text']}\n")

      if __name__ == "__main__":
      main()

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.