Elaine Casap on Unsplash

There are occasions when running a Python/Ruby/PHP shell script from Node.js is necessary. This post looks at best practices around leveraging child_process.spawn to encapsulate this call in Node.js/JavaScript.

The goal here is to have an interoperability layer between Node.js and an outside shell. This is a quick workaround if some other part of your system isn’t developed in JavaScript.

We’ll use spawn over exec because we’re talking about passing data and potentially large amounts of it. To understand the difference between child_process.spawn and child_process.exec see “Difference between spawn and exec of Node.js child_process”.

The long and short of it is…

NeONBRAND on Unsplash

If you want to ship, use the tools you know. — A lot of people

Let’s apply that principle: I’m building Post Frequency/Accountable Blogging, I’m familiar with Vue and Node-based backends. Netlify makes frontend deployments trivial and I’ve settled on Dokku for databases/backend applications hosting.

See how I deploy my applications Deployment options: Netlify + Dokku on DigitalOcean vs now.sh, GitHub Pages, Heroku and AWS.

Table of contents:


Accountable Blogging was always going to be a single-ish page application, initially, the backend was going to be Netlify lambdas… when I hit some issues with that I just went back to what I know, setting up Dokku to deploy some backend services.

Since my lambdas were…

Oskar Yildiz on Unsplash

Here’s how I get productive for JavaScript/Node on Mac OS.


Setup iTerm2

Change edit mode to natural text

  • iTerm Preferences → Profiles → select your profile → Keys tab → Load Preset… → Natural Text Editing (See this StackOverflow answer)

Ruediger Theiselmann on Unsplash

Enhancing generators for ES6 in the Sequelize CLI

This is the story of my discovery of ES6-class style model definitions with Sequelize (see Using ES6 classes for Sequelize 4 models). The realisation that the current Sequelize CLI model generator didn’t support it (as is expected since it’s not the most common way of doing it). Finally, the impetus to just implement it myself.

In other words, I started using a style of Sequelize models that the Sequelize CLI didn’t support. I didn’t get an answer on a “feature request” issue, so I just forked it, implemented it and published it.

The Free Open Source Software movement has its…

Headway on Unsplash

ObservableHQ is a platform being built by Mike Bostock (creator of the D3 visualisation library), Jeremy Ashkenas (“Made CoffeeScript, Backbone.js, Underscore and other ragbag” from his Twitter bio) and Tom MacWright (creator of the big presentation framework, simple-statistics and documentation.js as well as D3 contributor amongst other things).

Observable is not just another JavaScript sandbox. It introduces the notebook paradigm to JavaScript projects, those of you familiar with Jupyter notebooks, this is the equivalent with JavaScript instead of Python. It turns out JavaScript is very well-suited to this type of paradigm.

What’s more, JavaScript developers already have some sort of…

Andre Mouton on Unsplash

There’s nothing as flashy and useful for JavaScript interviews than recursion.

If you just want to be impressive with recursion in JavaScript, here are some semi real-world (technical test type) examples.

The short definition of a recursive solution to a problem (in computer science) is: don’t use iteration. This usually means a function has to call itself with a smaller instance of the same problem. It does this until it hits a trivial case (usually defined in the problem).

Hence, recursion is composed of a couple of steps.

In this post, we’ll discuss:

Raymond Rasmusson on Unsplash

Writing multiple components in one file is a pattern from React where some files contain multiple components.

Some of those components are “private” to the file/exported component since no other component needs to consume them.

Here’s Swizec complaining about it:

Since I don’t have the full code for the above, we’re just going to use the default “Hello World” component from a project scaffolded using vue-cli as an example.

By default there are two files, one for App and one for HelloWorld (at src/App.vue and components/HelloWorld.vue). HelloWorld takes a msg prop and renders it.

To write these in a single file, using React it might look something like this:

const HelloWorld = ({ msg }) =>…

Annie Spratt on Unsplash

GraphQL is a great alternative to REST (or other HTTP API designs). This is a quick introduction to the core concepts around consuming a GraphQL API.

To see some examples consuming a GraphQL API:

What is GraphQL and what problems does it solve?

GraphQL is “a query language for your API”.

In plain English, it makes the client define what (nested) data it needs.

If we compare it to REST approaches:

  • the “pure” REST approach is to return IDs (or resource links) for any associations (or nested…

Andrew Pons on Unsplash

An example consuming a GraphQL API in JavaScript from Node and the browser using graphql.js

See the example live: https://codewithhugo.com/js-graphql-client-example/.

Full repo: https://github.com/HugoDF/js-graphql-client-example.

This was sent out on the Code with Hugo newsletter last Monday.

Subscribe to get the latest posts right in your inbox (before anyone else).

Fetching from Node


const graphql = require('graphql.js');const graph = graphql('https://graphql-pokemon.now.sh/');const query = graph(`{
pokemon(name: "Pikachu") {
attacks {
special {
if (require.main === module) {
res => console.log(JSON.stringify(res, null, 2)),
err => console.error(err)
module.exports = {
$ node fetch.js { "pokemon": { "attacks": { "special": [ {…

Hugo Di Francesco

https://codewithhugo.com . JavaScript Developer. UCL Mathematical Computation alum.

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