Node file watching

How to Watch for Files Changes in Node.js

In a previous article on counting unique items in a JavaScript array, I introduced you to the system I am creating that enables our family to log when the fish 🐟 in our aquarium have been fed. The feeding times are logged to a file by pressing a push-button on a circuit board connected to a Raspberry Pi, pressing an Amazon Dash button, or clicking a button through a web interface. The resulting log file looks like this: 2018-5-21 19:06:48|circuit board 2018-5-21 10:11:22|dash button 2018-5-20 11:46:54|web Our next challenge is to watch this log file for changes as button pushes are streamed in from one of our three sources (Amazon Read More

Share
Count array items in JavaScript

How to Count Unique Items in JavaScript Arrays

The fish 🐟 in our home aquarium aren’t very communicative. I don’t necessarily need them to communicate their deepest emotions, but it would be helpful if they would at least tell me when they are hungry. Believe it or not, they don’t. Alas, when I peer inside the aquarium, I don’t know if they are hungry or if someone else in the family has already fed them breakfast🍩 or dinner🍕. IoT to the rescue! I am in the process of creating a system that enables our family to log when the fish have been fed. The feeding times can be logged by pressing a push-button on a circuit board connected Read More

Share
Node.js Handlebars

Learn Handlebars with Node.js and Help Freddy’s Fish Too

Our friend Freddy Fishman needs our help. He recently launched an aquaponics business to raise fish 🐟 and cultivate underwater plants, and he needs a real-time report to ensure the environmental conditions of his fish tanks are optimized so both his fish and plants can thrive. Another friend of his wired up some Arduino-based fish tank sensors and created a data stream that flows to a local JSON file; therefore, the data foundation is already in place. Can we help Freddy and his fish farm? I think we’re up for the task! We’ll help Freddy and we’ll help ourselves as we learn how to use Handlebars, a templating library that Read More

Share
Upgrade Node.js Windows

Install and Upgrade Node.js on Windows the Easy Way

It’s easy to install and upgrade Node.js on the Raspberry Pi as explained in my guides on installing Node.js and upgrading Node.js on a Raspberry Pi. In fact, it’s easy on any Linux-based system. For Windows systems, however, the default installation routine of downloading and running MSI files from the Node.js website is not so streamlined. I was not keeping Node.js on my Windows systems up to date due to the activation energy required to do the installations. Today, however, everything changes. In this article, we will learn how to install and upgrade Node.js on Windows from the command line—and make the ongoing upgrade process as easy as double clicking Read More

Share
toml files

Using TOML Config Files in Your Node.js Applications

In this article, we’ll learn how to use TOML, a rising star ⭐in the configuration file world, with Node.js. After reading this article, you will understand the TOML syntax including how to use it to model JavaScript objects in your Node applications. After recently finishing my tutorial on Using INI Files with Node.js, I stumbled across the TOML configuration file format when conducting some focused learning on Rust. It turns out that Cargo, Rust’s package manager, uses TOML for its Cargo.toml configuration file, which serves in a similar capacity to the package.json file used by npm with Node. I excitedly delved into TOML and to learn more, and emerged quite Read More

Share
Raspbian Lite

Create a Lightweight Raspberry Pi System with Raspbian Lite

In this tutorial, we’re going to build a highly optimized Raspberry Pi system that runs very lean on resources with the help of Raspbian Lite.  Whereas a baseline Raspbian system consumes around 158 MB of RAM, Raspbian Lite runs at a mere 34 MB.  To achieve this lighter weight footprint, we must give up the graphical user interface (GUI); however, we’ll include steps in the build (and tips) to help us work productively without a GUI. This guide follows the same flow as my popular Beginner’s Guide to Installing Node.js on a Raspberry Pi, and I recommend that you use that guide if you are a beginner or if you simply Read More

Share
VS Code Syntax Highlighting

How to Copy Visual Studio Code with Syntax Highlighting to Other Applications

In this article, we learn how to copy from Visual Studio Code with color syntax highlighting to various other applications including Word, PowerPoint, Outlook, OneNote, and Gmail to achieve beautiful, clear code samples for documentation, presentations, and general communication. This will prove useful whether you are using JavaScript, JSON, HTML, CSS, TypeScript, Markdown, C++, Java, PHP, Python, Go, T-SQL, XML, C# or a host of other languages and data formats that Visual Studio Code supports. How is this accomplished? It’s very simple! When you are in VS Code copy your selected code to the clipboard, VS Code brings the color syntax formatting along for the ride so the formatted text Read More

Share

Guide to Using Redis with Node.js Released

I just completed a pretty extensive Guide to Using Redis with Node.js.  In this guide, we explore using Redis, a fast in-memory database that persists on disk, in conjunction with Node.js. We work through real examples to help equip you to: Install Redis Use Redis as a standalone tool Build Node.js applications that interact with Redis You can check it out here.

Share

Do I Need an Umbrella Today? Google Sheets and JavaScript to the Rescue!

OK, Google Sheets! Send me an email if I need an umbrella today. Send an email using Google Sheets? Yes, that’s right! Sheets can do a lot more than add numbers and calculate your mortgage payments. In our last article, we learned how to consume JSON web data using Google Sheets and we built templates to display and sort weather forecast data. Today, we’ll build on what we covered last time and learn how to send email using Google Sheets based on the JSON data we retrieve. Let’s get practical and build something useful while we’re at it. Have you ever found yourself outside somewhere and it starts to rain Read More

Share