Category Archives: Coding

How to autofill an address using mapbox

I have been poking at the Milwaukee County Trasit System (MCTS) APIs over the past few weeks.  A few years ago, I tried to write a bus app using Angular and it just didn’t work out well.  I figured that I would try it again, using what I have learned since then.  The first step was to build out a data infrastructure using Cloudflare Workers and Cloudflare KV.  The end-result of that is what drives the MCTS mastodon bot.  The workers JSON api returns every bus stop in the system, along with the route, direction, and location.  The next step is to figure out where the user is and where they are going.  That is the subject of today’s post. Continue reading How to autofill an address using mapbox

How to calculate the sunset and sunrise times in JavaScript

Over the holidays, I created Good Morning, Milwaukee! (a Mastodon bot that posts a “Good Morning” toot every morning).  The problem is that it hasn’t been behaving correctly since shortly after I finished it.  I want to simplify it a bit, so I can make it a little less fragile.  The first component of the message that I decided to focus on is the bit that gets today’s sunrise and sunset. Continue reading How to calculate the sunset and sunrise times in JavaScript

I might have been spending a lot of time on Mastodon

In my previous post, I talked about how after Elon Musk’s purchase of Twitter, I was giving more attention to Mastodon.  Since then, I killed my twitter account, launched my own Mastodon instance, launched three new Mastodon bots (including a new one that goes live this morning), and converted Joe Travels to only post to Mastodon.

The new bot is called Good Morning, Milwaukee! and I created it to test the limits of my ability to create a Mastodon bot.  It gets sunset info, sunrise info, the weather, the news, and a live photo.  For the news article, it randomly picks between the Milwaukee Journal Sentinal (limited to just local stories) and the Milwaukee Business Journal.  Once it picks a publication, it picks a random story amoungst the five most recent ones.  For the live photo, it picks a random one from three (i43 at Silver Spring Drive, Cathedral Square Park, or the Milwaukee River at the MIAD campus).  The whole bot is written in Node, using Pipedream.

The other two bots are MCTS and The Hop.  They both post the details of a random stop (including a Google Street View image) once per day.

I don’t consider any of this to be a finished product.  Everything is going to need some tweaking, moving forward.  I’m going to try to stop building new bots, though.

Please drop a comment if you have any questions and feel free to check out Toot Works if you are interested in checking out what Mastodon is all about.

 

[ Cover photo by Christopher Burns on Unsplash ]

What is a CSS Reset?

The goal of a CSS reset is to reduce inconsistencies with things like line height, font sizes, and margins.  Every browser defaults to different sizes and spacing and if you set a common baseline, you end up with a better end-product.

A basic example would look like:

body, div, h1,h2, h3, h4, h5, h6, p,ul {
margin: 0;
padding: 0;
}

Andy Bell and Josh W. Comeau have pretty good, pre-packaged CSS resets but the OG might be the one by Eric A. Meyer.

There is an argument that a CSS reset violates DRY (Don’t Repeat Yourself) but a good CSS reset is minified, blindly pasted in, and is common to all of your projects.  You might be setting things only set them again later but it will save you time and pain for a minimal cost.

 

[ Cover photo by Tom Grünbauer on Unsplash ]

How to deploy a Laravel app

As I promised in the most recent Laravel post, today we are going to talk about how to deploy a Laravel app to a production environment.  At the time that I write this, the most recent version of Laravel is 9.x but when you read this, there is a good chance that 10.x or 11.x will be available.  Starting with the release of Laravel 8, they transitioned to yearly releases.  Prior to that they were releasing major versions every 6 months.  Version 9 was released on February 8, 2022, it is scheduled to receive bug fixes until August 8, 2023, and it is scheduled to receive security fixes until February 8, 2024.  Laravel used to have an LTS (long-term support) version (similar to what Ubuntu does) but the LTS had 3 years of support and every version after version 8 has two years of support, so I’m guessing that it is what killed the LTS.  For this post, we are going to focus on version 9. Continue reading How to deploy a Laravel app

What are koans and how can they help level up your dev game?

A koan is a story, dialogue, question, or statement which is used in Zen practice to provoke the “great doubt” and to practice or test a student’s progress in Zen.  In the Zen school of Rinzai, the use of koans (often a paradoxical statement) is used to initiate the internal socratic method in the students, to break down prior deeply held notions that hold them back from Enlightenment.  An example of a koan is the question “What do you call the world?”

So, what does this have to do with application development?  There are technology-specific koans out there like Ruby Koans, ColdFusion Koans, Python Koans, and a number of different versions of JavaScript Koans.  The goals of each project is to teach the particular technology through testing.  A test runner like Jasmine, QUnit, or MXUnit is usually used.  With koans, you need to run the tests and see them fail, make the tests pass, and then take a moment to reflect upon the test to see what it is teaching you.  In doing this, the hope is that you will become a better coder.

 

[ Cover photo by Sean Stratton on Unsplash ]