small pixel drawing of a pufferfish existentialcrisis.sh

First draft of weekstolive
Jes Olson j3s@c3f.net
Mon, 24 Jan 2022 06:42:44 -0600
commit

0b0ba93075a505a3d17872045d1af4cc1e67a08a

parent

40168e2f04a736fe6cc2afa845a6c9a8684571ae

1 files changed, 25 insertions(+), 0 deletions(-)

jump to
M main.gomain.go

@@ -13,6 +13,7 @@

func main() { http.HandleFunc("/", serveTemplate) http.HandleFunc("/api/v1/crisis/quote", quoteHandler) + http.HandleFunc("/api/v1/crisis/life", lifeHandler) log.Println("listening on :4357 tbh") err := http.ListenAndServe(":4357", nil)

@@ -60,4 +61,28 @@ func quoteHandler(w http.ResponseWriter, r *http.Request) {

w.Header().Set("Content-Type", "text/plain") randomQuote := quote.GetRandomQuote() fmt.Fprintf(w, randomQuote) +} + +func lifeHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + // hardcoded for now + age := 29 + yearsTilDeath := 77 - age + weeksToLive := yearsTilDeath * 52 + text := "weeks of your life:\n" + weeksOfLifeOnAverage := 4004 + weekOfLifeYouAreOn := weeksOfLifeOnAverage - weeksToLive + + for i := 0; i < weeksOfLifeOnAverage; i++ { + if i % 50 == 0 { + text = text + "*\n" + } else if i == weekOfLifeYouAreOn { + text = text + "\n[*] you are here\n" + log.Println(i) + } else { + text = text + "*" + } + } + + fmt.Fprintf(w, text) }