Coding and Cantrips

Thejus Chakravarthy
3 min readMay 17, 2022

I grew up in a tropical climate and currently live in a temperate one. So, I keep an eye on the weather to figure out what to wear.

Because I hate the cold. Oh, man, do I hate it.

The moment it drops below 60 degrees Fahrenheit, I am upset. It doesn’t matter how far below 60 it goes, I’m miffed. 50 degrees and sunny? Angry. 10 degrees and snowing? Still angry.

Photo by Craig Whitehead on Unsplash

In high school, I’d watch the weather report on television. In college, it was websites. Grad school? Mobile apps.

Then the issues started. One app got bought (I still miss you Dark Sky!). One app put ads on the home screen. One app wanted permissions to my contact list.

So I went back to the websites. And there were banner ads. And ad tracking cookies. And slowdowns because the site used so many libraries and had so many dependencies and just…ew, man.

But I couldn’t go back to watching television because I didn’t have one anymore! Just as I started thinking about the radio, I had an idea.

“Can I just do it myself?”

A while back, I wrote about how learning to code and learning magic are similar. Basically, there are parallels in learning how to code and learning how to be a wizard, going from “Yer a wizzurd, ‘arry!” to “LevioSA”

In D&D (Dungeons and Dragons, but you should know that), cantrips are “simple little spells.” Like, ‘Light’ or ‘Mend’.

Photo by Lisa Woakes on Unsplash

For me, cantrips are bits of code that make life a little easier.

So, using basic Javascript and trace amounts of CSS, I built a little HTML page on my laptop. It pulled weather data from https://openweathermap.org/, did a little math, and gave me a weather report. There were no servers or microservices or any libraries (other than the CSS one from Bootstrap)

Then the tinkering started.

What about a table? What about snow? Humidity? What about the rain? Oooh, what about a graph?! With tiny raindrop icons! and…and…GRADIENTS

And then the bugs started.

Then, while I was reading through tomes of documentation while fuming at a Javascript call that just wouldn’t behave, I asked myself a question.

Its a question every programmer asks. Usually out of frustration at first. Then as part of their process. And eventually, the one question that separates the solver from the solution.

“Why am I doing this?”

Photo by Júnior Ferreira on Unsplash

Do I really care about the details of the weather? No, I truly do not. I only care about what I need to wear, in response to the weather. I only care about whether I need a hoodie, or if I need an umbrella, or if I need my thermals today.

I mean, I’m going to be angry about the cold, but there’s a difference between angry and infuriated.

So I scrapped the whole thing and started over. And here’s the result.

It’s simple. It makes my morning easier. And that’s all it needs to do.

So, before you cough up your hard earned money and attention to some conglomerate who uses your GPS coordinates to sell you the latest geegaw, maybe take a step back and ask…

“Can I just do it myself?”

--

--

Thejus Chakravarthy

if i’m not optimizing some operations puzzle or the other, i’m probably reading (or writing, apparently)