I recently left my full-time job in New York. This deserves a dedicated blog post, and I plan to do that once I can properly organize my thoughts.
But a big part of why I left is: 1. I want to spend time traveling and (what I've been calling) 'city shopping'. 2. I want to spend time building all sorts of fun tech projects. Anything that makes me and/or other people happy is the only criterion. Importantly, I'm hoping these projects will also drive learning in new areas for me.
On my About page, it says "Daniel is a web developer that lives in Brooklyn, New York." That's no longer true! I want to update this so that it pulls in dynamically from my current location.
Mostly, I just think this is fun. I like the idea of going somewhere for a weekend, and my website updating automatically. Realistically, there is no obvious benefit. But maybe my family/friends will enjoy having a reliable way of knowing where I am.
I want this to work based on the location of my phone; my phone is always on and always with me. But I don't know much about mobile, so I'm going to build the first iteration using the location of my laptop.
This project appears to have 3 or 4 parts. The first is the database, to store my location. The second is the client-side code, to fetch the location. The third is posting my location. If I post all details related to my location, that's it. But if I just post some information, the fourth will be a service that transforms the given information into everything required.
I don't want to be bothered much with the DB. My needs are small—I just want to store simple data remotely. Therefore, it seems ridiculous to set up and maintain a dedicated server.
For this reason, I think Firebase will be a good fit. I used it a while ago for a small project. The major benefits are that: 1. I don't have to manage anything myself and 2. it's free(!) for non-enterprise projects.
This should be fairly simple.
Once the remote endpoint is set up correctly,
the location can be retrieved with
and the DOM can be updated with
This will be the hard part. On first-pass, I will write a shell script that uses my current IP address to determine my city and state. Then post that to the remote Firebase DB.
I'm not great with bash, but I believe
simple APIs exist to find city/state from an IP.
I'm hoping I can accomplish everything with
To run the script regularly, I will use
to call it every hour
This should work on my laptop.
However, it will not transition nicely to mobile.
That is, I cannot run a
cron job on my phone.
And finding the city and state will be more difficult without
But I'll cross that bridge when I come to it.
Will I need to build a whole Android App, or does something already exist?
I can see just posting my IP address from mobile, and running a service
to transform that into city/state.
I can either use
cron on a remote server or use
something like AWS Lambda.
The good news is that it works! About. It's overly object oriented and uses Ruby instead of bash, but seems fine for such a tiny system.
allDateTimes[Math.max(...Object.keys(allDateTimes))]. Also, I forgot that JS is not a high-level language. It's often used in the same sentence as Ruby and Python, but it does not have nearly as many convenience methods.
awk. I'm not sure if the problem is that bash is the wrong tool or that I don't know how to use it well enough. I wanted to use bash because I thought that would translate to mobile better, but that might not be true.
I'm happy I got this working relatively quickly. I think it's a neat update to the About page.
Getting this working on mobile will be more interesting. I need to do some reading about bash. I will update this post as I continue working on this project.
I'm going to Michigan this weekend, so we'll see if it works!
[EDIT: Rather than updating this post, I wrote a new entry about getting this working on mobile.]
cron. I heard the term used for over a year, and always thought "I'm a web developer. That's a tool used by Systems people."
cronis now one of my favorite tools. It comes in handy all of the time, and is simple to use. If you're not familiar with it, definitely check it out. It allows you to schedule recurring jobs.
Have anything to say? Questions or feedback? Tweet at me @cmmn_nighthawk!