Code Cookbook: Ideal Time

Welcome to the Code Cookbook newsletter, an offshoot from my other newsletters that focuses on coding, and recently agentic coding, aka vibe coding. It can be a sensational topic- someone who has no idea how to code or even how to deploy anything can prompt their tools of choice to instruct them how to do everything. It makes an engaging headline, for sure- but what about someone like me who knows Python, but doesn't have the time to invest to learn how to call APIs, let alone something as complex as Google Routes?
Enter Cursor.
With several hours and quite a bit of coaching, I was able to come up with a prototype I felt okayish sharing with all of you. The premise is simple- with a long commute through some major traffic hotspots, it became clear that this drive could vary wildly based on the day of the week and what time I left for work, or returned home. I have been daydreaming about data collection and ways to develop my own system for predicting this, then I heard about Cursor. With Cursor plugged into my paid AI plans, I thought I'd start with a simple outline of what I wanted. Over probably around 50 initial iterations, I needed to coach it to do things like deploy to the local Docker server, move any personal data to the .env file, take my personal data out of the .env.example (yikes!) and just generally argue with it sometimes how to run test scripts.
The result is Ideal Time. You give it the max speed you will drive in km/h, your starting or home GPS coordinates, your ending or work GPS coordinates, your windows for commuting, and the time you want to be notified for each. It will do some basic analysis and give you the ideal time to leave for work, or leave work for home, with an idea of the best time, plus a window with a variance you specify. It passes this info to Google Routes, which in turn iterates through in 10 minute increments to find the best time. You will need to get your Google Routes API key, and you will need to have Docker on a server setup with ssh connections to deploy, but overall it's pretty hands off. I plan to add commute days so it doesn't bug me on the weekend, and I usually find one tweak each week or so. I hope you enjoy! If you find it useful, let me know and drop a comment, or go crazy and subscribe.
Code: https://github.com/jdoscher/ideal-time
Language: Python
Platform: Linux, Docker, Pushover
Interfaces and Concepts: REST API's, headless servers, mobile notifications
Coding Platform: Cursor (https://cursor.com/?from=doscher.com)
Comments ()