Automating the Mundane

So many of the processes, that we perform in the business of software development, are unnecessary, repetitive, mind-numbing, and mundane. Whenever I find myself with the freedom to do so, I focus my skills on automating the mundane.

I would like to think that, in the course of my work, I regularly achieve something similar to this “Automatically manage signing” option in the Apple Xcode IDE:

Before this option was introduced, a developer would be unable to build anything, not even a throw-away prototype, without first dealing with key/certificate/device management headaches.

These processes are nothing more than wastes of time and barriers to creativity. That they can be automated with the checking of a box is a tell: We need not waste our time with this anymore. Yet we surround ourselves with processes, regularly sacrificing potentially prosperous IP at the altar of “due process.”

What a waste.

Business plans, even those most optimistic, should be calling out the wasteful processes that we pay for in the form of unrealized potential. Every deliberative step, that stands in the way of progress and blocks creativity, should be automated, simplified, or altogether eliminated.

When I was in the IT Management business, I created an automated network printer setup program that made printing a test page obsolete. We received awards and accolades from customers, who no longer had to pay their employees to go through that process (or pay for all that paper, ink, and electricity). Yet we continued to encounter the occasional IT professional that preferred to manually go through the printer setup algorithm, somehow wanting or needing to see that “Congratulations” page pop out.

Take a look at the processes that plague your workplace. Honestly ask yourself how much of it all is really necessary to keep repeating. When you are ready to have the mundane automated, I hope you will look me up: It’s what I’m here for.

Fixing Connection Problems with self-hosted MySQL Server Daemon

Problem 0

When running mysqld on a VirtualBox guest OS of Ubuntu Linux, connection was being refused.


Fixed by changing the bind-address value to in mysqld.cnf

Command (edit as root with nano):

user@ubuntu:/etc/mysql/mysql.conf.d$ sudo nano mysqld.cnf




bind-address		=

Problem 1

The next problem was error 1130 (access denied).


Fixed this by enabling password authentication:

user@ubuntu:~$ sudo mysql -u root -p -h localhost -P 3306
Enter password: 


mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'password';
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Symfony Entity Creation

Create an Entity:

(an auto-generated ‘id’ column will be added for you)

php bin/console make:entity

Make sure the namespace path matches the file path:

namespace App\Controller\Utility; // file is at /src/Controller/Utility

Make sure ORM Mapping is in use:

use Doctrine\ORM\Mapping as ORM;

Create a Migration:

php bin/console make:migration

Execute the Migration:

php bin/console doctrine:migrations:migrate

Not so Swift

When tasked with the job of replacing buggy Swift code with release-quality Objective-C (mostly because I am more familiar with the latter), I find myself wondering why Swift is so popular.

Consider the following pair of code lines. The top line is Objective-C and the line below it is the equivalent operation in Swift (the operation pictured is the common task of pulling some user data from local device storage):

The similarities in the two versions of the operation are highlighted.

When I look at the Swift equivalent, I see a slightly re-arranged version of the operation that was specified in Objective-C.

Persistent Service Daemon Processes

In order to start up a service (such as an Unframed Architecture TCP/IP server daemon), a shell script, regularly run by the cron system, can be used to make it start up whenever the service goes down, regardless of the underlying cause. You will need to use sudo for editing the crontab file and making the script executable.

Create a shell script for restarting the ‘daemon’ service if it is found to not be running (script path is “/usr/sbin/daemon-p.bash”):


# find a process name that starts with '/' and 
# explicitly matches 'daemon' and 
# is at the end of the string ('$'):
ps ax | grep '/daemon$' | sed -e 's/.*grep.*//' | grep '/daemon$' 
if (( "$?" != 0 )) ; then
	echo "restarting daemon at $(date)" >> /tmp/daemon-p.log
	nohup /usr/sbin/daemon > /dev/null 2>&1 &
	ps ax | grep '/daemon$' | sed -e 's/.*grep.*//' | grep '/daemon$' 
	if (( "$?" == 0 )) ; then
		echo "restart successful at $(date)" >> /tmp/daemon-p.log
		echo "restart failed at $(date)" >> /tmp/daemon-p.log

Make the script executable:

chmod +x /usr/sbin/daemon-p.bash

Edit the crontab file using nano (or your favorite editor):

EDITOR=nano crontab -e

Add the following line to the end of the crontab file (will run the ‘daemon-p.bash’ script every minute):

*/1 * * * * /usr/sbin/daemon-p.bash

(see CronHowTo for other temporal options)

Run the following command to start your service daemon:

nohup /usr/sbin/daemon > /dev/null 2>&1 &

Run the following command to get the PID of your service daemon:

ps ax | grep '/daemon$' | sed -e 's/.*grep.*//' | grep '/daemon$'


(PID) ?        S      0:00 /usr/sbin/daemon

Run the following command simulate the service daemon going down:

kill (PID)

Wait until the next minute (on the system clock) elapses, and test for your service daemon coming back to life:

ps ax | grep '/daemon$' | sed -e 's/.*grep.*//' | grep '/daemon$'

Returns (when the service daemon has restarted):

(PID) ?        S      0:00 /usr/sbin/daemon


View the log file (produced by the script) to see the history:

cat /tmp/daemon-p.log

Returns something like this:

restarting daemon at Tue Jun  5 15:26:01 MDT 2018
restart successful at Tue Jun  5 15:26:01 MDT 2018

If the process detection phase of the script seems to be failing, shunt its output to the log file by modifying the lines that detect the process:

ps ax | grep '/daemon$' | sed -e 's/.*grep.*//' | grep '/daemon$' >> /tmp/daemon-p.log

Automatic Service Daemon Startup

In order to start up a service (such as an Unframed Architecture TCP/IP server daemon), the init.d system can be used to make it start up whenever the system starts up.

Copy the service program file to the binary folder (use sudo if not root):

cp progname /usr/sbin/progname

Create a script in the init.d folder (example at the end of this post):


Give the script executable permission:

chmod 755 /etc/init.d/progname

Change directory to the init.d folder:

cd /etc/init.d

Add the service to the startup list with low priority:

update-rc.d progname defaults 97 03

Restart the system; check to see if the daemon is running:

ps -A --sort cmd

To manually start the service:

service progname start

In this case, progname is a TCP/IP service daemon (listening on port 6666), so this command will display the status:

sudo netstat -lpn |grep :6666

Returns (where 12818 is the PID):

tcp 0 0* LISTEN 12818/progname

Example init.d script:

(Modified from: /etc/init.d/skeleton on local system)
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.  This example start a
#                    single forking daemon capable of writing a pid
#                    file.  To get other behavoirs, implemend
#                    do_start(), do_stop() or other functions to
#                    override the defaults in /lib/init/init-d-script.

# Author: Someone Somewhere (
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.


SSH on Linux

Install SSH Server software (use sudo if not root):

apt-get install openssh-server

Create SSH key folder under the user’s home folder:

mkdir /home/username/.ssh

Set permissions on the folder:

chmod 700 /home/username/.ssh

Change directory to the folder:

cd /home/username/.ssh

Generate the SSH key pair:

ssh-keygen -t rsa

Launch SSH Session (password only mode):

ssh username@ip.or.internet.address

Since the public key is on the remote system, you could launch SSH session using the private key:

ssh -i ./id_rsa username@ip.or.internet.address

Launch, Monitor, and Terminate Linux Daemons

If you have a daemon listening on port 6666,

connector = 
  (struct sockaddr*)&client, 

the following commands will be helpful for managing it.


nohup ./daemon > /dev/null 2>&1 &

Monitor (use sudo if not root):

netstat -lpn |grep :6666

Above call returns (note the returned PID):

tcp 0 0* LISTEN PID/daemon


kill -9 PID