New Tool – File Line Replacer

There a new command-line tool for searching files, scanning those files for blocks of multi-line content and then replacing those blocks with different lines. Some benefits of this are…

  • works on Windows, Mac, and Linux
  • no nasty RegEx or escape characters to specify multi-line values
  • backs up original files before making changes (if desired)
  • whitespace is either ignored or preserved … your choice
  • supports text files of virtually any size

Yes, I realize there are other utilities out there that will replace text… sed, awk, etc. PowerShell will even do it if you know the switches. However, in my opinion, all of them are heavily opinionated and take the geek-first approach. I wanted something I could give to a junior or mid-level person and know they can get the job done without spending their time researching how to structure some overly complex command.

One of the best tool sets for prototyping a relational data service is…

DbSchema : for brainstorming an designing the entities;

ExpressJS : probably the best web framework for hosting the web service; and,

Sequelize ORM : to generate the models and handle the data calls.

My original need came while using Sequelize to generate model files while for a new data service. I’m not sure what caused it (maybe switching between MySQL and PostgreSQL) but the models did not include logic for auto-incrementing primary key fields. So, models ended up having this…

id: {
  type: DataTypes.INTEGER.UNSIGNED,
  allowNull: false,
  primaryKey: true

… when they should have had this …

id: {
  type: DataTypes.INTEGER.UNSIGNED, 
  autoIncrement: true, 
  primaryKey: true 

So, why not contribute to the Sequelize project and submit a fix? The short answer is that the need to search & replace multiple lines is not specific to Sequelize. As a developer, all of your work is done with text files… the source code. And, over the years, I’ve had reason to perform this type of task several times. Creating file-line-replacer allowed me to get past the hiccup and be ready for the time when I need it again, outside of Sequelize.

Installing the utility is a snap. Once you have Node on your machine, simply install the command with…

npm install -g file-line-replacer

This installs the project and allows it to be used just like any other command-line utility. Then, correcting the model files was as simple as issuing one lil’ command…

file-line-replacer \
  --search-dir "/Users/flackey/my-project/src/data/models" \
  --backup-dir "/Users/flackey/my-project/_backup" \
  --old-lines "allowNull: false,|primaryKey: true" \
  --new-lines "autoIncrement: true,|primaryKey: true" \

The switches used here are the key. Here’s what they do…

Starting directory to search for files.

Each file is stored in this location before it is modified.

Pipe-delimited list of text lines to search for within each file.

Replacement lines for each occurrence of the –old-lines

Ensures we know the files will be overwritten (flags are set to true by simply adding the flag name to the command).

There are tons of other flags and features listed on the project page here. Some of them include…

Not everyone wants to search for files. You are able to specify the exact file to tweak. This is great if you want to use file-line-replacer in a BASH script.

--destination-file and --destination-dir
Maybe you don’t want to overwrite your files. Specifying the “destination” allows you to tweak your files and send them to a specific folder. This is great for working with source templates where overwriting or modifying the template is not desired.

--old-lines-file and --new-lines-file
Allows you to store the “old” and “new” lines inside of text files. You would provide a path to the file instead of supplying the actual values. This is handy for complex lines and making your scripts more “human-readable.”

--ignore-patterns and --ignore-patterns-file
The default search pattern is **/. (aka “all files, recursively”). Specifying “ignore” patterns allows more granular control on files and directories to skip.

In the grand scheme of things, I could have accomplished all of this with a BASH script. However, then I would have had more of a “uni-tasker” and not really gained anything in my developer toolbox.

Overall, I think this is a great lil’ utility. It performs a task that is quite common with developers and IT people while preventing folks from having to remember the complex syntax for outdated commands. It also allows me to personally overcome a speed bump that has been occasionally bothering me for years.

In the end, I hope whoever finds the utility is helped in some way. After all, that is why I love development so much.


Bixby Killed Samsung (for Me)

I’ve been writing software now for 36 years and have been focused on mobile apps for 12 of them. And, like many geeks, I’ve had every iPhone since the day it was released. However, a couple of years ago, I switched from iPhone to Android because of Samsung Mobile’s S7 Edge. It was the first Android phone that felt completely… natural in my hand. I also switched from my Apple Watch to the S2 and then the S3 (which I feel are infinitely better than the Apple Watch). When the S8 came out, I was confident that I would never switch phones again. And then came Bixby. I Hate BIXBY so much that I switched to an LG G6 just to get rid of the Bixby button. I now have THREE brand new S8 units, my S2 watch, my S3 watch, and two Gear VR headsets sitting in a drawer collecting dust. Have I considered the Samsung Galaxy S9? Of course I have. I loved my Galaxy & Frontier devices. However, until I can completely disable Bixby, I will never go back to Samsung.

I’m curious how many feel the same way.


Receive SMS Messages Via Email from Flowroute Phone Numbers

In today’s mobile world, people just assume every phone number is a cell phone… even if it’s clearly listed as “office” on your business card. And, in most cases, if the phone number belongs to a corporate phone system, or PBX, any text messages sent to that number are lost forever in the great bitbucket in the sky. Until now, that is! If you happen to be using Flowroute as your back-end trunking provider, you can now receive any SMS text message via email.

Here’s how to do it…

  1. Setup My Proxy App Using Docker I’ve whipped up a simple Node app to make life easy for you. In short, it receives all SMS text messages, from Flowroute, and emails them to you at either a single email address or custom “wildcard” domain. Assuming you have Docker installed a public server, install it via the following command:
docker run --name flowroute-proxy -p 3000:3000 \
    -e \
    -e SMTP_PASS=robin4ever \
    -e \

The settings are all done by environment variables. A complete list is in the Docker Hub:
Of course, it will be up to you to ensure your DNS and server settings are both setup with a FQDN pointing to that docker container. You’ll also need to have an SMTP account for outgoing messages.

  1. Activate the API with Flowroute Once you have a Flowroute account, head over to their Developer Portal and click on the Get API Access button. This will bounce you over to the Flowroute portal where you will enter the URL to the Docker container you setup above:

Cool Utility – Live Server

I just stumbled across one of those “it’s about time” utilities for front-end app development: Live Server. Long story short, you issue the command live-server from your application’s current directory and… well… that’s it. A browser pops open, your web app is loaded, and the lil’ utility watches for changes. Any changes that are made are instantly pushed to the browser.

Installation is ridiculously easy via NPM:

npm install -g live-server Of course, there’s a slew of command line switches and parameters to make even the geekiest geek happy:

--port=NUMBER – select port to use, default: PORT env var or 8080 --host=ADDRESS – select host address to bind to, default: IP env var or (“any address”) --no-browser – suppress automatic web browser launching --browser=BROWSER – specify browser to use instead of system default --quiet | -q – suppress logging --verbose | -V – more logging (logs all requests, shows all listening IPv4 interfaces, etc.) --open=PATH – launch browser to PATH instead of server root --watch=PATH – comma-separated string of paths to exclusively watch for changes (default: watch everything) --ignore=PATH – comma-separated string of paths to ignore (anymatch-compatible definition) --ignorePattern=RGXP – Regular expression of files to ignore (ie .*.jade) (DEPRECATED in favor of --ignore) --middleware=PATH – path to .js file exporting a middleware function to add; can be a name without path nor extension to reference bundled middlewares in middleware folder --entry-file=PATH – serve this file (server root relative) in place of missing files (useful for single page apps) --mount=ROUTE:PATH – serve the paths contents under the defined route (multiple definitions possible) --spa – translate requests from /abc to /#/abc (handy for Single Page Apps) --wait=MILLISECONDS – (default 100ms) wait for all changes, before reloading --htpasswd=PATH – Enables http-auth expecting htpasswd file located at PATH --cors – Enables CORS for any origin (reflects request origin, requests with credentials are supported) --https=PATH – PATH to a HTTPS configuration module --proxy=ROUTE:URL – proxy all requests for ROUTE to URL --help | -h – display terse usage hint and exit --version | -v – display version and exit

If you’re building web-based apps, or even if you’re just starting out in web development, this little gem will save you a tonne of time up front.

Enjoy! =)


Filter Out Docker Noise

Sometimes the smallest lil’ gem makes you feel great. For me, Docker’s --format option is one such gem. As much as I love Docker, for me, their commands’ output are far too verbose and noisy. In fact, the net is filled with complaints about this. However, the --format option makes them perfect… or closer to perfect. Even the noisiest command can be transformed…

… from this …

Before Docker Aliases

… to this …

After Docker Aliases

… in just a few extra keystrokes!

It outputs just the right amount of info to be particularly great for “4-up” or “2-up” arrangements…

Docker’s info for the ps command completely sucks and offers no info on this option. In short, you basically use it to tell Docker what columns to display. For example, with ps you have the following columns to choose from:

  • ID
  • Image
  • Command
  • RunningFor
  • Status
  • Ports
  • Names

So, for the example above, the syntax would be:

docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Ports}}"  

Or, better yet, if you’re on Linux or macOS / OSX, take a few seconds and create aliases for dps and dpsa in your ~/.bash_aliases file by adding these two lines:

alias dps='docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Ports}}"'  
alias dpsa='docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Ports}}"'  

Enjoy… finally! =)

(I’ve added these two aliases to my dotfiles project, if you’re following that project.)


Generating Mongo / Mongoose Models

Having come from the .NET world, I have always loved the ability to whip up a quick model diagram using the SQL Server Diagram Tool. It’s painless to model your data objects, and capture a good chunk of your business, for LOB applications. And, while in that world, I relied upon the CodeSmith Generator to spit out all sorts of documents from my database.

Alas, having moved to Mac, Linux, and MEAN Stack, all this is in the past.

… until now.

DbSchema is really what started me thinking down this line. It’s written in Java and, therefore, is cross-platform. I have used it successfully on all three platforms, to replace the SQL Server Diagram Tool, and it works flawlessly.

Here’s the cool part: unlike the M$ tool, DbSchema stores its data in good ole’ XML. So, of course, I’ve created a few tools to add some awesome sauce to it…

dbschema-parser Long story short, dbschema-parser allows you to walk the data structures using NodeJS. You may navigate from Database, to Schema, to Table, to Column, and back up again, or in any direction.

dbschema-parser-cli Since I want to use the Parser to generate files, I’m gonna need a CLI. That’s what this project brings to thy table.

dbschema-mongoose Under the hood this one is ugly as sin. However, it’s the thang that gives the two projects, above, some coolness. It basically looks at your DbSchema’s data file and spits out the equivalent Mongoose model files.

Side note…

I’m also using Keybaord Maestro, on Mac, and AutoHotkey, on Windows, to help me bang out complex data diagrams with only a few keystrokes. So, that helps a great deal.

Why Create This? In short, there’s nothing stable that provides this. DbSchema is the only tool that comes close to the stability and fluidity of the SQL Server Diagram Tool. And, as for generating models, there’s nothing out there that feeds from an elegant UI. Plus, although there’s a tonne of shtuff with Yarn and Yeoman, nothing feels fully baked.

Anywhoo, I hope this helps someone. It’s ugly. I know. If anyone shows genuine interest in it, I’ll see about extending it.


Force Outlook Data Path

I admit it. I’m really anal when it comes to allowing apps to consume hard drive space whenever and wherever they want. And Outlook is one of the worst at this. The path names make no sense to anyone but their developers and, if you have a ton of mail (like I do), this means a chunk of your system drive is gonna go bye-bye. For this reason, I force Outlook to store my mail files on a completely separate drive.

This trick is also particularly handy for those folks working on a corporate computer. Prevent Outlook from remembering your personal passwords. Then, force your data to be stored on a USB thumb drive that you take with you each day… encrypted, of course.

Okay, so here’s now…

Use the registry editor to created two string keys ForceOSTPath (for IMAP) and ForcePSTPath (for Exchange) in the following path:


For example, if you’re using Outlook 2016, the path would be:


Here’s mine…

Regedit ForceOSTPath

That’s really all there is to it.

Enjoy! =)


Buy This Movie – The Founder

There’s not much else to say. If you’re an entrepreneur, you need to buy The Founder. It’s now available for pre-order on Amazon. This is one of those motivating movies you’ll watch repeatedly; both to energize you and to remind you of what mistakes not to make.

‘Nuf said. =)


Wake Up Gently to the Sound of Nature

I absolutely love the feeling of waking up to birds singing in the cool summer breeze. Sleeping with the windows open, here in the northeastern United States, allows my body to be gently lulled awake as distant birds stretch their wings in search of an early morning snack.

Countless studies have proven the abrupt sound of a typical alarm clock causes you to feel tired, run-down, and may induce headaches. I have avoided these unpleasant feelings for years ensuring I always wake up gently to the sound of nature. When weather does not allow for the windows to remain open, or when I must be awake by a certain time, I rely on special high-quality recordings in lieu of Mother Natuer herself.

The recordings below are each one or two hours in length. Each original recording is accompanied by three others altered to gradually increase their volume (or “fade in”) from 0db (complete silence) to their full volume over time.

How to determine your new alarm time:

  1. Pick a awake time using the time you need to wake up: 8:00 AM
  2. Your waking duration is the amount of time to lull your body awake: 30 minutes
  3. The alarm time is your waking duration subtracked from your awake time: 7:30 AM

How to use the recordings:

  1. Listen to each Sample to find a recording you enjoy;
  2. Download the Original version (used to set volumes);
  3. Download the version with a fade-in time equal to your waking_ duration;
  4. Play the Original version on your alarm clock to find a comfortable full volume level; and,
  5. Set your alarm clock to play the version with the fade at your alarm time (above).

Example: Actual time I must wake up by: 8:00 AM Duration to lull my body awake: 30 minutes Alarm’s time (start playing MP3): 7:30 AM Backup alarm’s time: 8:15 AM (on critical days) Note: On critical days, I generally set a backup alarm, using a separate device, for 10-15 minutes after my awake time. The backup alarm does not use a gradual volume increase. This ensures I’ll be awake even on those days when I’m too tired to hear my alarm clock.

Rememeber to grab the original version! I recommend also using the original version of the selected track to set the volume of your alarm clock or listening device. This will help prevent selecting a volume that is too quiet to actually wake you.

Available Tracks Relaxing Bird Songs in Wood Birds Chirping (64 min total) Original | Sample | 10 min fade-in | 30 min fade-in | 60 min fade-in

Forest Birdsong – Birds Chirping (120 min total) Original | Sample | 10 min fade-in | 30 min fade-in | 60 min fade-in

Meditation Music Relax Mind Body (64 min total) Original | Sample | 10 min fade-in | 30 min fade-in | 60 min fade-in

Please let me know if there are any other sounds or tracks that might help you with this technique. My email address is:


Pattern for Developing Complex Solution with NodeJS within Docker

So many of the examples out there, for both Node and Docker, show simple little applications. They might demonstrate how to create a container. Another might show how to crank up your first NodeJS app. However, I have yet to find one that demonstrates how to use these bag o’ widgets in a real world application.

Hopefully, my mean-docker example, on Github, will help show how to bring it all together. Something within me wants to create a small how-to video series surrounding it, however, there are several good folks out there already tackling the meat of this (check out Derick Bailey’s WatchMeCode for back-end goodness). So, who knows? In the meantime, here’s what this project will give you:

(BTW: Here’s the direct link on GitHub, in case you missed it: mean-docker)

Project Breakdown

Three back-end microservices (for some reason the Node world is referring to them as “APIs”… which annoys the heck out of me) stubbed-out in NodeJS and Express.

The front-end Angular app which calls into the example APIs.

Your example company’s web site. Again, this is just stubbed out.

solution-a & solution-b
Two higher-level solutions containing all of the “good stuff” for Docker & NGINX.

Getting Started

There’s not much to it. Here’s what to do:

  1. Install Git & Docker on your development machine.

  2. Clone the Git repo to your machine: git clone

  3. Navigate into either solution-a or solution-b (currently identical): cd ~/Source/Github/FredLackey/mean-docker/solution-a

  4. Spin up Docker and let’er do it’s magic: docker-compose up

  5. NGINX is listening to a few URLs specifically, so you may want to edit your /etc/hosts or %SYSTEM32%\drivers\etc\hosts file and add the following entries (a copy is in the provided %SOLUTION%/.docker/etc/hosts file):

Working With It

Automated “watchers” are already setup to handle all of the compiling, optimizing, starting, and restarting for you. Simply do your work in the typical %PROJECT%/src/server and/or %PROJECT%/src/client folders and everything else will be taken care of for you.

On a completely clean dev machine, it should take approximately three minutes for an initial build:

Example Running Blocks

If you updated your /etc/hosts or %SYSTEM32%\drivers\etc\hosts file with the names of the servers, you may check the status of each project using any web browser:

Example Project Site

… or …

Example API Test


The goal of this project is to get you started and help demonstrate some of the concepts… getting NGINX to talk to proxy your requests, linking docker containers, automagically detecting changes, etc. That being said, it works for this purpose but it’s not an actual working solution. If you have a need for such a thing, let me know and maybe I can spend some additional time on it.

Enjoy! =)