Old Dogs

I wrote my first line of computer code in 1977, 43 years ago as of today. Back then, when I was 13, a friend and I would go to our local Radio Shack store after school or on the weekend and fool around with the TRS-80 they had on display. We were end users, loading games from the cassette “drive” connected to the machine, but we both had the desire to make the computer do something more. We wanted to make it draw pictures!

A few weeks later, my friend’s father bought a TRS-80 for his son. Victor and I spent the day learning to use it. We immediately sat down and started writing WET code, bugs, and printing it all out on a dot-matrix printer to make sure we had typed it in properly. I remember I went to his house shortly after lunch. By dinner time, after not having left his room for hours, our progress was, well, about what you would expect from two kids who had never done a programming tutorial in their lives (because they didn’t exist) and who were not terribly fond of RTFM.

After all those hours, the only thing we’d managed to make the computer do was draw an outline of a house on the screen and save the instructions on the cassette. IIRC, we were so uninformed about programming that our program consisted of something like: GO TO 1,1; PRINT 1; GO TO 1,2; PRINT 1; GO TO 1,3; PRINT 1, etc. until we’d managed to turn on every pixel in the form of an outline of a house. Needless to say, fourteen years passed before I attempted programming again.

New Tricks

In 1991 I bought a Mac LC with 4MB of RAM and a 20MB hard drive (and a color monitor, which was a novelty at the time). It came with HyperCard (“magic“) and my employer at the time gave me a licensed copy of Macromedia Director 3.1! Although Director could barely run on my low-powered Motorola 68020 processor, my world was changed forever, and for the better.

Over the course of 4 years I produced a bookkeeping system to balance my checkbook in HyperCard, two interactive multimedia games for learning Spanish in Director, and even ventured down the path of trying to write a document versioning system in HyperCard (so students could see how their documents were changed after a teacher’s review – I gave up pretty quickly on that one). And then in 1995 I received a copy of Claris Home Page, and again, my life would never be the same ever after.

Another Old Dog

In 1996 I was asked to build more than a few web sites. I soon realized that Claris Home Page, although it was actually a reasonably good WYSIWYG editor, was not the right tool for interactive sites or sites consisting of more than a few pages. I started hearing about Perl and then soon after, PHP, and this really frightening thing called Linux (and open source – shareware had existed for a while, but licensed open source was still relatively new to me).

In 1998 I created my first interactive web site that included a proper (open source) search engine. I was so fascinated by it I started to participate on the mailing list, trying to help others to understand and make use of it. I even wrote a bunch of classes in PHP that abstracted the ht-://dig interface and published them on phpclasses.org. ht-://dig really was my first experience working on an open source project but all I did was participate on the mailing list, test beta versions, and create a Mac OS X package to facilitate installation. I didn’t submit patches (what we used to call pull requests) and certainly didn’t have any kind of write access to the repo (which was probably in CVS IIRC).

Fast Forward 20 Years

Since those early years I’ve “contributed” to a variety of open and closed source projects including Sequel Pro (financial support and translations), Dreamweaver (I was a beta tester in the late 1990s), BBEdit (PHP Clippings, I’m even in the credits on that one), PHP Documentation, PHP Fusebox (a PHP port of the Cold Fusion Fusebox web application framework), and more, a lot more, more than I can actually remember TBH.

But over all these years I’ve never, ever submitted a pull request, until now!

I’ve been an avid user of wp-cli for years. I’ve been active on and off on the Slack channel and tried to report bugs and suggest changes but never went all the way. A year ago, when I was first experimenting with the wp scaffold plugin-tests command, I discovered an irregularity that I found frustrating, and finally reported it. Months went by with apparently no action on the bug (but the maintainers didn’t close the bug, to their credit). A few weeks ago another user chimed in with signs of similar frustration and I decided it was time to do something about it.

I read some instructions on how to submit a pull request and low and behold, I got some traction. James Nylen reviewed my code and left some suggestions on how it could be improved. I followed his lead and submitted my changes. Then, the principal project maintainer, Alain Schlesser, chimed in with more changes, which I addressed as best I could. This back and forth went on for a few weeks and finally, my pull request has been accepted and merged onto master. My first PR at 55 years young!

Lessons Learned

  1. It really is never too late
  2. Every action paves the way to the future
  3. Go easy on maintainers. It’s often a thankless job, so be sure to thank them along the way.

I’m feeling empowered now and you know what they say: a little knowledge is a dangerous thing… If you’re an open source maintainer and you’re reading this now, be prepared. I’m coming your way!

Some months ago I threatened to drop Facebook, Instagram, and others and published a post about my intentions. Now, months later, I realize that I never finished the follow-up (this post) nor had I posted it, so here it is.

I know I sound like a crazy person. I am reminded of an article I read about a computer programmer in the mid-90s that went off grid completely for fear of what computers (and their operators) were able to do. That act has resonated with me ever since, over the past 25 years, and now it’s my turn. However… I’m not as radical. I recognize my desire to be a part of the greater society that surrounds me for all its ills and am willing to cede control over my personal data should that be required, but first, I’m going on a diet.

Brian Acton, one of the creators of WhatsApp, is now recommending people delete their Facebook / WhatsApp accounts. And he’s not alone. Other well informed technology leaders are making similar, grave recommendations and predictions and that, combined with what is happening in the AI world, should have any reasoning adult more than a little concerned.

Over the course of the next two weeks I am going to delete my Instagram, Facebook and WhatsApp accounts and request to be forgotten by those networks. This might not seem like a big deal but in all honesty, these networks, WhatsApp in particular, are at the center of my social life in a very big way.

The decision to drop them from my life has not come on a whim. It is the result of repeated warnings and events that have convinced me that they are not worth the risk. Basically, I do not trust Facebook to not abuse my data, and me by extension. I don’t think Facebook are malicious but AI is rapidly evolving, faster than most companies and people can keep track of and it seems increasingly likely that mistakes will be made.

Choosing to drop tools like WhatsApp is not easy. For example, where I live, school uniforms are no longer available until a new provider is found. Since I know the woman on the board that decides, in part, who to work with, I thought I should send her a WhatsApp to ask if I could make my own t-shirt while we wait for a provider, and then I wondered: what will I do when I no longer have WhatsApp? I can always use SMS (but it turns out phone companies are even worse than Facebook re: client privacy) so I won’t be doing that. And then I thought about it, how important is it that I resolve this right now? In fact, is this really even something that needs a micron of my attention right now? Obviously, the answer is a resounding NO! Chalk one up for the diet.

Since first drafting this post, I’ve dropped Facebook and Instagram but I’ve chosen to hang on to WhatsApp, not because I need everything right now, but because, where I live, literally every single person with a phone has and uses WhatsApp constantly (except my children…) and there is a high likelihood I would miss out on genuinely important things, like friendship, were I to chuck it into the dustbin. For WhatsApp, I’ll reassess at the new year. For now, though, dropping Facebook and Instagram has been GREAT!

WordPress Integration Testing Overview and Issues

Starting almost a year ago I started experimenting with the “official” WordPress plugin testing tools while working on our Ratify plugin. I’m not a glutton for punishment but I do like a good challenge and, for the most part, I wasn’t let down.

The first half of this year we had another, ripe opportunity to work with the testing framework. We were building a custom publishing solution based on WordPress. As a custom solution, we had a few plugins to write that would allow the authors and editors to (more) easily manage their content in addition to tracking your every breath while on their web site. As a team of almost 10 developers at one point, it was crucial that we all knew how to write and run tests.

A big part of my job is developer training. I decided to create a practice plugin that we could use for training developers how to use the framework and write good tests. The plugin would allow you to assign a “countries” taxonomy to any standard or custom post type. We wrote a general description of the plugin and then a series of tests we thought would help us do this as TDD. The view is always better from on high.

Coding Environment and Tools

We use vscode with the following extensions (more, actually, but these are pertinent to this project):

Although I am a life-long BBEdit user (and occasional contributor), there are certain features in vscode that make doing this kind of development a joy (in-editor PHPCS feedback, code completion via Intellisense, multicursor editing in particular). Do note: I’m writing this post using MarsEdit but only because it’s already configured to post to my blog directly.

WP-CLI and Laravel Homestead

We use Laravel Homestead for nearly everything we do here at Secret Source. Yes, we know, Docker is the future, but we like Homestead. Homestead may require a little tweaking to use with WordPress but normally it just works.

We use wp-cli to generate the testing framework / harness (wp scaffold plugin-tests). It works well enough but this is where we start to struggle and I’m going to go into detail here because Josh Pollock was wondering what we were struggling with.

Issues with the Testing Framework

In general, the testing framework works and I can’t imagine how much effort I would have to put into it to recreate it myself so, kudos to the WordPress team for just producing this. That said, as systems get more complex, it becomes even more important to have a testing framework in your tool belt so, IMHO, more effort should be put into making the framework as easy to use as possible.

Installation and Setup Seems Difficult

The wp-cli scaffolding consists of a few files you’ll need to get the full benefit of the testing framework. It does not include the actual tools or binaries you’ll need. For example, in order to use the framework you need phpunit, and not just any version, but, in our experience, anything higher than 6.5 won’t work. Subversion is also required, so, sudo apt install subversion. I have to believe that these two steps could be encapsulated in a composer.json file but they aren’t, so two additional manual steps are required to get your environment configured.

Initializing the Database Issues

When you install the test scaffolding, it includes a bash script (bin/install-wp-tests.sh) that tries to set up the whole environment, including the database that is used when running the tests. The script, however, could be improved. On more than one occasion I’ve found myself having to manually fiddle with MySQL (deleting tables) and delete all references to WordPress in /tmp/wordpress in order to get the script to run properly. Also, at the end of the script there is a scary MySQL message about including the password on the command line. It can be ignored but there are solutions to minimize this kind of misdirection.

I would start by isolating dependencies as much as possible and including a little more sanity checking and such. Since this is written in bash, I could do it myself, but I have a feeling it should probably be some sort of PHP script, maybe even installable via composer?

There is no Way to Test Plugin Installation

As far as I can tell… the framework doesn’t allow you to test the installation hooks (installation seems to be bypassed during bootstrapping). As (bad) luck would have it, our practice plugin has a very specific requirement that it not proceed under certain circumstances, but we’re unable to automate this test.

Issues with (Vscode and) PHPCS

I’m not a big fan of vscode but it does have some very compelling features including a PHP CodeSniffer extension that helps you write properly formatted code and code, in theory, is less complex. This is a feature I really want as I need all the help I can get!

There are really two issues:

  1. The WordPress plugin test scaffolding comes with a different set of code sniffs (not sure what they are called) than the WordPress core, which is reasonable, but if you don’t know how to phpcs in general, this is going to take a fair amount of investigation to figure out, as was our case.
  2. The vscode phpcs extension has a per project installation option (if you don’t mind installing phpcs via npm) but getting vscode to find the binary can be tricky and then configuring phpcs to look at the right sniffs can be even harder. We managed to get it set up and working, mostly, but if you’re looking to learn how, I suggest you look at the wprig.io github repo for an example of how to do it.

Difficulty Defining Tests

Writing good tests for TDD is an art, plain and simple. If you ever find someone who is genuinely good at it, latch on to her and don’t let go. Learn as much as you can from her, and if you’re her supervisor, give her the freedom (and time) she needs to practice her art.

The very first test we wrote for our practice project turned out to be untestable using the WordPress testing framework. For the curious, we wanted to the plugin to fail to install gracefully if a taxonomy named “countries” already existed. Due to how the test harness is invoked, the plugin skips the normal installation processes, which is when we were planning on testing for the existence of said taxonomy. I won’t detail the time it took us to figure this out but I will say it was not insignificant and there was little documentation around this subject. We just read the bootstrapping code.

The second test makes some assumptions about what the environment will contain, what data will be available in the environment. This is fine but it means that we have to do a fair amount of mocking or even creating of data prior to running the test to be able to test things. This not a huge problem so long as the tests are relatively short. It seems to me that there ought to be a more direct, and faster way of testing this aspect but I haven’t found one yet.

The Future

Thanks to other, motivated WordPressers the future still looks kind of bright for WordPress and testing. My plan is to get this kinks resolved in the next couple of weeks. I will be publishing our sample plugin eventually so follow me on Twitter if you’re interested in seeing the final result.

I have two children about to enter puberty. They already have phones (no SIM cards though). They are already generating a digital tail. Google already has dozens or hundreds of recordings of their voices as they use the voice search regularly. I created G Suite accounts for them so I could control what they were doing online but I now regret, somewhat, having done that.

In thinking about my own habits, experimenting with AI, and the details the big social networks have on me and my children, I feel compelled to try to take some control over things. So, I’m going on a diet…

Yes, that’s right: I’m going to give up the Facebook habit. I’m going to go back to a time when my time (and data) was mine. A time when if I was bored, I would read a book, write an email, or write a blog post! A time when I didn’t have to worry what kind of evil machinations were taking place behind the curtain that would come back to bite me, or my children, 10 years down the line.

The main reason I’m calling this a diet is because I am not giving up everything. I will continue to use Twitter and Google products, G Suite and Google search in particular, but will make Firefox my new, default browser. I will continue to try to use DuckDuckGo as my main search engine.

Dropping Facebook will be easy and a pleasure. They’ve provided me with all the tools I need to retain all of my content, rescind our agreement and delete all of my info from their databases. And I have to thank legislative pressure (or the threat of it) for making all of that possible.
Dropping “Insta” will be easy. I haven’t posted anything, only liked a few things… Really dislike the UI…

Dropping WhatsApp will be a bit of a challenge. I live in a world where everyone uses WhatsApp, except one person I know who still has a Nokia phone. Friends, touting Telegram’s open source client insist it is the solution, but they failed to notice (or care) that all of your data actually lives on servers in St. Petersburg (Russia, not Florida), and the Telegram team don’t seem to have a headquarters and instead, travel from country to country looking for one that will allow all of them to live and work there. Their location as of this writing: Dubai. This does not inspire a lot of confidence that my personal communications are really mine.

About a year ago, maybe more, I came across Keybase. At the time it didn’t impress me much as a desktop app. I wasn’t even sure what it was intended for. Now, however, it’s looking pretty awesome and will be, for the foreseeable future, my WhatsApp replacement. I’m actually really looking forward to using it.

Also, like any diet, I’m not going to drop the big three at once but rather, in a scaled fashion. Instagram will be the first to go as it is utterly unimportant in my life. One week later, Facebook, and the week after that, WhatsApp. Along the way I may drop one or two other services I never (or rarely use) but those three are the ones that worry me the most and I’m really, really looking forward to being Zuckerberg free!

And finally, as with any diet, none of this would be possible without the support of my life-long partner (my wife). She has agreed to use Keybase to communicate with me and the burden of participating in all the WhatsApp groups (school groups mostly) will fall on her, until I can convince them all to drop WhatsApp and use Keybase instead!

Interested in joining me? Follow me on Twitter or Keybase and share your experiences dropping the garbage.

After searching a rather long time and not finding anything, I decided to publish my own list of URLs as a plain text file, one URL per line.

As I do development, I sometimes need plain text files of test data. I can find Lipsum galore, placeholder photos of Bill Murry, lists of words, plain text files of varying sizes, even a place to dispose of your data (yes, trash can as a service), but I’ll be damned if I can find a single text file full of URLs. So I made my own plain text file of URLs. I hope you find this useful 🙂

You know the problem… “We’d like users to be able to authenticate using Facebook so they don’t have to create an account on our system.”

Here at Secret Source Ltd we do lots and lots of WordPress development and lately, nearly every project has required some sort of Facebook integration, the ability to log in with your Facebook account in particular. Fortunately there are multiple plugins to help you with that. We’re quite fond of the Nextend Facebook Connect plugin as it is very easy to configure and includes clear instructions on how to create a Facebook app and get everything working like a charm.

For me, though, there has always been one particular point of pain that none of these plugins have figured out how to work around: unless you want to be responsible for a Facebook app for your client’s logins, your client needs to give you THEIR Facebook credentials so you can login AS THEM to create and configure the Facebook login app.

However, I recently figured out a way around this. I know I may be late to the party but I’ve been unable to find this approach documented anywhere, or maybe I just didn’t search hard enough.

The approach is as follows:

  1. Log in to the Facebook Developer portal as yourself.
  2. Create a new app and configure it for your client, using their logo, domain, and everything.
  3. Go to Roles -> Administrators -> Add Administrators and add your client as an administrator. Note that you and your client do not need to be friends in order for you to add them, but you will need to know either their Facebook ID or Facebook “username”.

Once your client accepts your invitation to be an administrator, they can then go to the Roles tab and remove YOU from the list of administrators. The app is now THEIRS and your job is done! Note that if needed, the client can always add you back as an administrator.

This, to me, seems like a very reasonable way to have set this up and I can, for once, say I am quite happy with Facebook’s developer tools.