Played the Game and Lost

I played the game and lost
I put my toes across the line
I played the game and lost
victory totally wasn’t mine

I gave it a try, I did my best
but the dice weren’t rolling my way
I was alone then and I’m alone now
and that’s how it’s gonna stay

I thought my grace and my skills
were fully demonstrated
now I’m sitting on the sidelines
realizing that I’m deeply hated
crawl into a bottle and get heavily sedated
because I … played the game and lost

I played the game and lost
my pigskin hit the turf
I played the game and lost
i should have stuck to using Nerf

turns out, that easy first down
was merely a deception
you could see my disappointed frown
when it led to an interception
now the mascot is farting
in my general direction
because I … played the game and lost

I played the game and lost
I thought i had a base to steal
I played the game and lost
I never got the contract deal

I thought that bringing it home
was sure to get me winning
but all those curve-ball pitches
took me out of every inning
got knocked into the dugout
and my helmet flew off spinning
because I … played the game and lost

I played the game and lost
I’m dashed upon the rocks
I played the game and lost
now I’m in the penalty box

(interlude)

I hit the ice with my stick high
and my teeth packed with dip
I didn’t hear period buzzer
’till I smashed my lower lip

I thought that making that goal
was well within my power
the clock was counting down
I had minutes instead of hours
the buzzer sounded
and I had to hit the showers
because I … played the game and lost

(finalé)

Internet of Things

they put my toaster on the internet
so I can watch it burn on-line
my wine cooler’s web page tells me
if the wine’s before its time

the smart vacuum cleaner tells me when I missed a spot
and so does the mower, this is some kind of plot
the dishwasher unfriends me if I don’t pre-wash
the toilet bowl tweets when I forget to flush
my car gives my parking a 2-star rating
my air mattress sends a text when it needs inflating
the refrigerator calls me when it needs more food
the floorboards blog about it when they come unglued
the roof offers up content featuring buckets when it leaks
the bird feeder has a pill-count showing all the empty beaks
the driveway writes an article about how to shovel snow
and the yard writes comments about leaves I need to blow
the machine sends me an email when my wash is done
but it still cant tell me where my other sock has gone

my digital assistant called the ambulance when I fell to the floor
the trash can asked me to empty it on my way out the door
the lawn wondered if I’d be back to water it today
as the paramedics lifted me and hauled me away

now the bedpan is buzzing
as it needs to be changed
the nurse says that they have WiFi
and access can be arranged

when they found me unresponsive,
there is one symptom that was showing:
from my cold, dead hands fell my tablet
with its inbox overflowing.

Antisocial Networking

I’ve got an online girlfriend
Who is, quite possibly, a man
I manipulate my image
To give myself a tan

Earned a quarter of a penny in ad revenue today
Spent a quarter of a thousand to get people to press “play”
My instructional video, showing how to grow a tree,
Is interrupted by ads for a pill that treats E. D.

Warriors buying injustice
Snowflakes buying tweets
Leaders buying followers
Boxers buying beats

Hashtags link me to the site where they all flip the bird
Tried to write a sonnet but it had an extra word
Picture of my new house, picture of my meal
Looks like I am doing well, but none of it is real

I buy myself some “likes”
The scrolling never ends
I buy myself some Astroturf
I buy myself some “friends”

Antisocial Networking, we all make virtual friends
Antisocial Networking, where the “feeding” never ends

Antisocial Networking, got to loosen up your belt
Antisocial Networking, where the “snowflakes” go to melt

Sucking all the humanity out of humanity
Sucking all the humanity out of humanity

Antisocial Networking, an echo chamber for lies
Antisocial Networking, everybody in disguise

Antisocial Networking, where the devil is in the detail:
Antisocial Networking is just the latest tool for retail.

Flipping the Bird

Flipping the bird
See how far it flies
Flipping the bird
Inaudible to the wise

Make a bold statement
Call out for action
Rethink your position
Make a retraction

Flipping the bird
This one’s drawing flies
Flipping the bird
The bots are in disguise

Calling out injustice
From a platform built on greed
Protesting inequality
From a comfort with no need

Stupid is what stupid does
Banal is what discourse was
Having a truncated conversation
About the fate of every nation
Sucking all the oxygen out of the room
Hammering out the epitaph on your own tomb

Flipping the bird
It’s time to come to terms
Flipping the bird
This one’s feeding worms

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.

Solution

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

Command (edit as root with nano):

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

Edit:

[mysqld]

...

bind-address		= 0.0.0.0

Problem 1

The next problem was error 1130 (access denied).

Solution

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)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
user@ubuntu:~$ 

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”):

#!/bin/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
	else
		echo "restart failed at $(date)" >> /tmp/daemon-p.log
	fi
fi

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$'

Returns:

(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

Debugging

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):

/etc/init.d/progname

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 0.0.0.0:6666 0.0.0.0:* LISTEN 12818/progname

Example init.d script:

(Modified from: /etc/init.d/skeleton on local system)
#!/bin/sh
# 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
fi
### BEGIN INIT INFO
# 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.
### END INIT INFO

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

DESC="progname"
DAEMON=/usr/sbin/progname