Jon Newton

Pandemic programming and beyond! My Link Tree
December 6, 2024

Go with Go / Initial Thoughts

After reading more about async Rust and talking with some programmer friends, the consensus was to "go with Go". I've been learning the language using only resources on go.dev and have already written a web server for juran.io without even considering a 3rd party framework or library. Likes To paraphrase Rob Pike, Go is about different...
Read more
November 20, 2024

Avoiding code rot in your hobby project

Apropos of my recent musings on how to build a new project so that it can be easily run and maintained in the future, I see this HN thread "The tragedy of running an old Node project", https://news.ycombinator.com/item?id=42175316. With Rust's crate ecosystem, I was worried there would be a lot of mentions of horror stories but so far ...
Read more
November 20, 2024

Juran - which language for the backend?

I'd like to provide a compiled binary for the server in order to provide a better guarantee that the app can be used in the future. I'd also like a language that avoids python 2 -> 3 upgrade breakage, so ideally, someone can also modify the code in the future. My first instinct is to write the server in Javascript because I already kno...
Read more
November 20, 2024

New project - Juran

It's time for another project. This time I'll be focusing on scratching a work itch. Juran is test management tool named after Dr Joseph Juran who was "The Architect of Quality" Read more about him at https://www.juran.com/about-us/dr-jurans-history/. My experience with Test Management tools I needed to find a test management tool for ...
Read more
May 3, 2021

Notes on S3 Event Notifications

These are more terse than I prefer but I'm tired and want to capture some interesting points learned tonight: - When triggering a lambda function on Put, consider enabling "Multipart upload completed" if your objects are large. If you don't see the event generated, check the size of the upload and then check this setting :) - There are...
Read more
March 25, 2021

VS Code Semantic Highlighting, or "Why are some vars green and some blue?!"

Yet again staring at VS Code and wondering why "yaml" is blue and "toml" is green. Maybe toml is better? VS Code is clearly communicating some information with the coloring but it wasn't totally apparent. Some googling led to the semantic token classification and a way to inspect said tokens: Open the command palette, run "Developer: I...
Read more
March 15, 2021

Learning AWS SAM the hard way

I've successfully built an API Gateway integrated with Lambda which in turn writes out to S3. The gateway is also integrated with a Cognito user pool and I've even been able to pass the claim subject all the way back to S3 for use in partitioning the bucket. Really sweet! The next item on my list has been to get the configuration out o...
Read more
March 15, 2021

Finding a needle in the haystack with GitHub Code Search

I've been struggling to figure out a mis-configuration in my SAM/OpenAPI extension related to an API Gateway Authorizer definition. The template is valid according to "sam validate" but "sam deploy" returns an error. I think it's probably a yaml/ref problem because I'm referencing from the OpenAPI definition to the SAM template. It wou...
Read more
March 13, 2021

Don’t mess with Python

Just a quick note about my own ignorance of this week - Ubuntu and derivatives all depend heavily on Python I had forgotten this fact and while trying to fix an install problem with cfn-lint had reinstalled Python 3. This broke my entire system including network connectivity and I had to reinstall from the Live CD. 😫
Read more
March 4, 2021

Proxy support in Mongoose :(

I wanted to restrict my MongoDb Atlas cluster to an IP whitelist and with the Heroku free-tier that requires using a socks proxy but womp womp Mongoose/MongoDB does not currently support that type of connection and no real progress has been made on the feature request.
Read more
March 4, 2021

Repeat after me: Array.forEach expects a synchronous function

forEach expects a synchronous function! forEach does not wait for promises ! Additional reading • Array.prototype.forEach() • for statement • for...of statement
Read more
March 4, 2021

24 hour Amplify challenge

I have some rough code ready to deploy but have been struggling to get authentication working with the aws-sam configuration so I decided to give Amplify another shot again. I've been trying to follow https://github.com/aws-amplify/amplify-js-samples/tree/main/samples/vue/auth/authenticator but hit these problems 1. npm start reference...
Read more
March 4, 2021

My #1 AWS Amplify feature request

Hooking up AWS Amplify auth (using Cognito under the covers) allowed me to get signup/verify/login elements built pretty quickly, although I made the mistake of assuming the sign up promise would resolve to something meaningful (like a Cognito user) but instead it gives 'SUCCESS'. Here's my commit realizing that: https://github.com/jrn...
Read more
March 4, 2021

(Almost) one config file to rule them all

Each project has a pretty consistent setup and I’m digging the tooling in the Node world (eslint, prettier, etc). The number of dot files and other config chaff is building though… • editorconfig • eslintignore • eslintrc.js • prettierignore • prettierrc It becomes a bit tedious to setup a new project each time to the point we’re I’ve ...
Read more
March 4, 2021

Synchronous asynchronous-functions with async/await

MDN never disappoints and I find this part of their async/await guide the most interesting: Async/await makes your code look synchronous, and in a way it makes it behave more synchronously… This means that your code could be slowed down by a significant number of awaited promises happening straight after one another. Here’s a slightly ...
Read more
March 4, 2021

Where's my AWS service?

TLDR: Pay attention to the region set for the AWS web console. I’ve been deploying all of my sample projects using various AWS services like S3 static hosting and Amplify. Today I wanted to review the Amplify setup. I logged into the AWS console but when I navigated to the service page the ‘getting started’ splash screen appeared like ...
Read more
March 4, 2021

ES6 Function Shorthand

I’ve decided to take a detour in the loc8r project and use Vue instead of Angular on the frontend. I’m spending time today running through the Vue 3 tutorial and bumped into Yet Another Cool Javascript Feature: function shorthand. ES5 convention: const app = Vue.createApp({ data: function() { return { product: 'Socks' }; } }); ES6 conv...
Read more
March 4, 2021

Mongoose footnote: delete vs. remove

I’m nearing the end of chapter 6 in the Getting MEAN book and writing a REST function to delete locations from Mongo using Mongoose. The book recommends using findOneAndRemove(), while the Mongoose Guide recommends delete operations. Some further reading of findOneAndDelete() gives this weak recommendation: “This function differs sligh...
Read more
March 4, 2021

Configuring coc.vim for fun and profit

I took another break from VSCode to continuing playing around with NeoVim and coc.vim. The initial testing had pretty cool results, like showing basic lint warnings. Next was to get some of the doc popups like this: When learning new tools I typically start at the beginning of the README and just learn as much as I can front to back. I...
Read more
March 4, 2021

Handling invalid MongoDB IDs

I’m using Model.findById a lot when updating locations and their reviews in MongoDB. The +Getting MEAN+ book covers the 3 scenarios you’ll encounter in your callback: db.Location.findById(id).select('_id name').exec( (error, location) => { if (error) { console.log(`got error: ${error}`); //return 404 } else { if (location) { console.lo...
Read more
March 4, 2021

Array reduce, the interesting bits

Here’s the original snippet from the updateAverageRating function which uses Array.reduce to count all the review ratings. const total = location.reviews.reduce( (accumulator, rating) => { return accumulator + rating; }); My code had two problems which left me puzzled in the debugger for a bit. • Why was rating a MongoDb document inste...
Read more
March 4, 2021

Warning: Input is not from a terminal

This morning I was using locate to find some configuration files, and I wanted to edit them directly in Vim. locate config.xml | xargs vim -R Vim starts but gives this warning: Warning: Input is not from a terminal When you exit Vim, you’ll find your terminal is probably borked. You can use reset. Looking for the cause of the problem, ...
Read more
March 4, 2021

Hello, World

This is a my first blog post on https://hey.com/world/. "Blog via email" is a pretty great idea and something I'll try to use more often. I was struggling with my previous blog platform in part because writing was not instantaneous. For now I'll import my old posts and then see if I can more easily create new ones when the muse appears...
Read more