Image for post
Image for post
Photo by Émile Perron on Unsplash

Writing unit tests for asynchronous non-deterministic code can be tricky. How do you go about testing functions that make use of network calls or read from/write to the filesystem? Mocking libraries like testdouble or sinon can help. But what about testing these sorts of scenarios that make use of Node’s event loop? Consider the following example:


Image for post
Image for post
Photo by Eugene Chystiakov on Unsplash

One of the most powerful yet complex constructs of the Go programming language is that of interfaces. An interface in Go allows for flexibility in design and implementation of functions through polymorphism. If you are coming from Java or another statically typed object-oriented language, then these are concepts that you are most likely already familiar with. However, the implementation of interfaces in Go is implicit, rather than explicit. Consider the following example:


Image for post
Image for post
Photo by vivek kumar on Unsplash

The gap between development and production/deployment has long been narrowing. There is a growing need for developers to understand and master not just the development lifecycle of software, but also the deployment and maintenance of that software. Production environments can be notoriously difficult to maintain: compatibilities and dependencies must be carefully planned for when moving from a development environment to a production environment. What if there was a way to just create one environment — one time — and deploy that environment to production? This is exactly the problem that Docker aims to solve.

If you are unfamiliar with how Docker works, it operates with the concepts of images and containers. An image is like a blueprint for building a container: it defines how a container should be built, what dependencies the container needs, what network port(s) to expose, what commands to execute when a container is created, and so forth. A container is essentially an instance of an image. …


Image for post
Image for post
Photo by Su San Lee on Unsplash

Often when building web apps, we are writing asynchronous code — making a network request to an external API, for example. Data retrieved from a network request takes time to come back — the request must be sent to the server, the server executes code to form the response, and the data is then transferred back over the network to complete the request. We cannot access data that has not yet been resolved by the request in a synchronous manner. Consider the following example, which for our purposes simulates a network request:

function getUsers() {
return new Promise(resolve => {
return setTimeout(() => {
const payload = {
users: [
{
id: 1,
name: 'Spike Burton',
location: 'Atlanta, GA'
}
]
};

resolve(payload);
}, 300);
})…


Image for post
Image for post
Photo by Antoine Beauvillain on Unsplash

Rails version 6 is out! One of the most exciting things about the newest release of Rails is the treatment of JavaScript as a first-class citizen. Webpacker is now bundled by default with every new project bootstrapped with the Rails CLI, along with support for using Angular, React or Vue. I personally am a big fan of React, and wanted to test how easy it would be to setup a new Rails project with support for React right out of the box. Let’s get started building a simple app!

First, you’ll want to make sure you update to Rails 6. You’ll need to have Ruby 2.5 or greater installed: type ruby -v in your shell to see what version you are working with. I recommend using RVM for managing multiple installations. If needed, you can install a specific version by running the command rvm install 2.6.3. Next, update the Rails CLI: gem update rails. Now, when you type rails -v, you should see something like Rails 6.0.0. …


Image for post
Image for post
Photo by Joshua Aragon on Unsplash

The process of setting up a project for deployment doesn’t have to be a pain. If you are preparing and scaling for production throughout the development phase, pushing your final app out into the world can be simplified and streamlined. Build tools and testing frameworks can help make this process smooth and painless, and pushing your code regularly to a production build can alleviate a lot of pain points. Travis CI is a popular CI/CD tool which is free for use with open source projects. …


Image for post
Image for post
Photo by Johann Trasch on Unsplash

When I began thinking about how I’d like to build and structure a personal portfolio site, I looked into a number of options. Should I create a site with Squarespace or Wix, just to make things quick? Use a template from HTML5 UP? I knew I didn’t want to hand code everything from scratch, as it would be incredibly time consuming and inefficient. And then I heard about GatsbyJS.

I first heard about Gatsby when I went to a workshop at REFACTR.TECH. I was immediately intrigued after learning that Gatsby is a static site generator built on top of React and GraphQL. This meant that I could build dynamic pages using React components, source outside data with GraphQL, and build an incredibly fast and responsive site that is compiled to static pages. …


Image for post
Image for post
Photo by Andrew Neel on Unsplash

I am of the opinion that programming languages are merely tools in the creative arsenal — and as much as a hammer has a specific purpose, different languages are suited for different tasks. I am personally a big proponent of Ruby as a language to quickly hack and prototype ideas: the language is simple, expressive, and doesn’t require any thought about low level details like typing and garbage collection. I can drop into IRB or Pry in the terminal and play with ideas until I have a working prototype, which I can then quickly throw into a project skeleton that I have devised. …


Image for post
Image for post
Photo by Michel Paz on Unsplash

Cloud computing, serverless architecture, microservices … if you have been paying attention to the latest web development trends, you have undoubtedly heard these key terms. What does it mean to move part or all of your development cycle over to the cloud, and what does that look like?

AWS (Amazon Web Services) Lambda is a solution to build microservices using the serverless architecture paradigm. Instead of building out a server from scratch and spending time and resources on hosting and configuration, Lambda provides a function as a service — or FaaS — which allows you to quickly and easily write server side code in the cloud. This code is triggered by a specified event, which could be anything from a request to an API gateway to an upload to an S3 bucket. A popular example is image re-sizing or thumbnail creation: a user uploads a photo through your app, which is stored in an S3 bucket. The upload triggers a chunk of code which re-sizes the image to the desired dimensions and places the image in a target bucket. …


Image for post
Image for post
Photo by Trevin Rudy on Unsplash

Whenever I am building out an API, I am constantly testing every endpoint as I go to ensure functionality. Postman is an amazing tool to help with API testing, and its claim to be the “Complete API Development Environment” delivers. In this article we will discuss how to set up a testing environment for any stage of development using environment variables, and how to automate the process of testing using JavaScript within Postman.

For the purposes of this article I am going to use an API that I am currently building out, but you should feel free to use whatever you would like. If you are in need of an API to test with, I recommend https://httpbin.org/

About

Spike Burton

Observer.Thinker.Creator.Destroyer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store