All Posts

Serverless Express API Boilerplate

About nine months ago, we started development on a Node.js Serverless application hosted (if that is the proper term for serverless) on AWS Lambda. I started laying the architecture by writing code directly in the Lambda console, then I progressed to uploading zip files of the code, and then, finally, I found the Serverless framework. Before Serverless, I would manually (or via a script) create API endpoints in AWS API Gateway and then hook them up to the appropriate Lambda function.

Deploying Multiple Sites Using Docker and Elastic Beanstalk

One of the problems that you face with many projects that you want to Dockerize is figuring out how to deploy them. This is particularly challenging if you want to deploy and scale multiple projects on the same server or set of servers since most deployment solutions target a single application or project at a time. Elastic Beanstalk, for example, out of the box only supports single site deployment from its GUI.

Annoying People

Can we be honest with each other? Some people are downright annoying. Many of the people that you meet or see in person or on electronic media do or say things that raise your blood pressure. From the nut that cuts you off in traffic, to the neighbor that allows their pooch to defecate in your yard, to the armchair political quarterbacks on Facebook there’s no shortage of vexatious people. The nice thing about this group is that you can often turn them off or relegate them to the outer reaches of your mind.

Flip the Bozo Bit

You know those “favorite” members of your team? Like the one who’s seemingly insipid, relentless, and endless communications appear to be tailored to cut your ego in half with every keystroke and are about as welcome as the smell of burning toast on your way out the door in the morning? You think they believe everything that they say should be written down and preserved for future generations and that you should feel privileged to be lacerated by their “feedback.

A Recipe for a Long Weekend - AWS Route53, GoDaddy, and the Dark Side

Do not underestimate the power of the dark side – Vader Recently, I transfered the DNS for several sites from GoDaddy over to AWS Route53 Hosted Zones. As is typical for most good devs, I over-optimistically thought that critical updates on Friday would be fine - I know what I’m doing, right? To start the process, I went to the GoDaddy DNS console for each site and selected the option to export a zone file.

Working with Remote and Overseas Teams

This particular project was a growing and learning experience in many ways. During this project, I worked remotely with an overseas team. While working with a remote team can be an enjoyable experience, it does present a few challenges. Those challenges are compounded when the remote team is also overseas. This project was no exception. There were many things that we could have done better. However, there were many things that we did well.

Plaintext Is Not So Plain

One of the bane’s of my current existence is having to deal with text encodings. I have a good friend that uses a few antique Windows programs that puke out Windows-1252 encoded characters as though it were going out of style. Much to my suprise when I opened up a csv file, made a few changes, and saved it, I ended up with a bunch of unicode replacement characters: “�” or otherwise known as \U+FFFD.

Rome Wasn't Built in a Day

Many of us have been on a project where everything starts out great and the client remains happy for a few months until suddenly they change their mind and are no longer happy. This project was certainly the case. However, there was quite a bit that we did right on the project. The code was clean and well architected. We used a transformation layer in the code to allow the API payloads to be detached from the database.

Computing Eloquent Model Deltas

Computing the differences or deltas between Eloquent models is a common task in many data oriented apps. The easiest way that I have found out how to do so is below: // This is assumed to be in \App\YourModel /** * @param \App\YourModel $model * * @return array */ public function delta(\App\YourModel $model) { // array_diff() is an easy way to produce deltas $baseline = $model->attributesToArray(); $possiblyChanged = $this->attributesToArray(); /* * $baseline = ['test' => 500, 'not_changed' => 5] * $possiblyChanged = ['test' => 700, 'not_changed' => 5] */ /* * $delta == ['test' => 700] */ $delta = array_diff($possiblyChanged, $baseline); // Here I unset possible changes that I don't care about unset($delta['id']); unset($delta['created_at']); unset($delta['updated_at']); return $delta; }

Eloquent Model JSON Serialization and Deserialization

Awhile back I needed to save an Eloquent model to the DB so that I might compute a delta later on. Json serves this purpose nicely since the json data type is now natively supported in many languages. One could do this manually but, fortunately, Laravel makes this easy on us. We can utilize model mutators to dynamically convert the input and output of a specific database column. For example, say we want to save a passed in model as json and that the column that we want to save to is called json: