Richard Clayton

Avoid Synchronous Functions in Node.js

Sync Functions can dramatically slow down your app and they are almost never necessary.

tl;dr

Most synchronous methods in Node.js (statSync, readFileSync, etc.) have asynchronous alternatives (via callback). Using util.promisify can easily make these methods async/await compatible. Using the Promise-based equivalents can greatly speed up your application. In fact, I'd argue there's never a need for the . . .

Read More

Posted in: nodejstypescript

February 29, 2020

A Gentle Introduction to TypeScript

Talk given at Fullstack Talks (NC San Diego) - 02/2o/2020

title


This information has been updated since the talk (mostly extra info added, some grammar/spelling errors corrected).


Who am I?

  • Principal Software Engineer at Peachjar
  • 3/4 Stack Developer (or Pear-shaped Developer)
  • Former Marine Corps Meteorologist
  • Virgo
  • Foodie
  • . . .

Read More

February 21, 2020

Distributed Locking with Postgres Advisory Locks

TL;DR

Postgres Advisory Locks are a great solution for arbitrary application locks, particularly in scenarios where you are already using Postgres and have a need to block concurrent mutations to a resource (that resource DOES NOT have to be data in Postgres).


Concurrency is hard

We ran into a problem . . .

Read More

February 16, 2020

WebSequenceDiagrams.com TypeScript Client

https://gist.github.com/rclayton-the-terrible/493cd0811542ff9693ac02746517ba71

TL;DR - TypeScript Client Gist: https://gist.github.com/rclayton-the-terrible/493cd0811542ff9693ac02746517ba71


If you are not familiar with WebSequenceDiagrams, it's an excellent tool for creating sequence diagrams for planning software flows. If you are not familiar with sequence diagrams, a quick Google search will . . .

Read More

June 22, 2019

What's Making Me Happy - 01/21/2019

React w/out Redux, Kubernetes Node Draining, and Customizing DataDog

Hey friends, welcome back to WMMH! It's about a month since my last post -- my sincere apologies; work and vacation have sapped my free time. Fortunately, the extra time has given me more things to be happy about!

Over the last couple of weeks, I have been working on various projects up and down the stack. This work included . . .

Read More

Posted in: kuberneteswmmh

January 29, 2019

Kube-Native Workflows with Argo

Stitching Docker containers together to get stuff done fast!

About a month ago, was looking for a tool to help automate some of the analytic jobs our data scientist built in Python. My goal was to automate the following process:

  1. Execute Python jobs that analyze the day's activities, producing a CSV output.
  2. Create a new table in Postgres (that hold the CSV data).
  3. Insert the . . .

Read More

Posted in: architecture

December 20, 2018

Implementing "Options Object" Pattern using TypeScript and Joi

The Options Object pattern [1][2] is a technique in JavaScript for configuring a component using a single function parameter:

const client = createClient({
 host: 'localhost',
 port: 12345,
 username: 'foobar',
 password: 'work-at-peachjar',
});

This approach has many benefits over . . .

Read More

December 10, 2018

Archive