Development, General, PHP, Web Development

Config Migration

TLDR; I made a thing for migrating my configuration files, I like it, and it’s available for use here:

As the technology world settles into the ‘DevOps’ era and begins passing it out to other areas (looking at you, marketing automation), I figured I’d share one of my deployment “pet peeves” and solutions.  Further embracing my love of disclaimers, keep in mind that this is my own cockamamie solution, and I’m just as likely to be wrong as right.

The Problem

It seems there’s a bit of a gap in many companies’s deployment systems.  Numerous jobs I’ve held in recent years have worked hard to put various types of automation in place, but for whatever reason there wasn’t a lot of thought lent to automating configuration files during deployment.

In almost every case where this was possibly a concern, it was either expected that the system would gracefully fail when new configuration values were missing, or it would be left up to some poor release engineer to figure out which configuration property was missing and thus causing the newest in a long series of catastrophic upgrade failures.

Either way, expensive blocks of time were wasted or only protected because of extremely dedicated and entrenched individuals.  Is this a huge time-sink for release engineers?  Obviously that depends, but at the least this is hardly a ‘DevOps-y’ approach to things…

My Solution

With this in mind, I did what I do best/most-often, which is to create a solution before searching for something else that did the job.  My simplistic solution was two-fold:

  1. Restrict my settings files to be non-nested JSON strings
  2. Build a simplistic migration instruction set that allowed me to add, change, rename, and remove settings properties

#1 was mostly influenced by the infamous web.config files used by IIS/ASP.NET.  I love IIS and ASP.NET, but working through web.config files always felt to me like trying to navigate that corridor of horrors from Indiana Jones and the Last Crusade.

That’s gonna be a whole lotta nope from me…

#2 is equal parts ego (thinking that I know better than everyone before me) and a strong desire to mimic the same sort of process used with database migration utilities, such as RoundhousE.

The result of this was a system based around files, named <OLDVERSION>-<NEWVERSION>.cfg (eg, ‘3-4.cfg’) that contained instructions similar to this:

coreVersion[str] + 0.1.0
siteName = A Site
database_host > dbHost
emailFrom -

This file would do the following things, in order:

  1. Add a new setting, coreVersion, of type string with the value ‘0.1.0’
  2. Change the value of the siteName setting to be ‘A Site’
  3. Rename the database_host setting to be called dbHost
  4. Remove the emailFrom setting
  5. Update the configVersion setting to now be the integer 4 (was 3)

I’d already been in the habit of using a script to manage my configuration files (keeps me from having to worry about the format of the file itself), so all I had to do was insert this migration system onto the beginning of that script.  This means I can now run my typical ‘version’ update call and feel confident that any new fields added to my setup script will be present:

php ./scripts/configure.php --non-interactive --PcoreVersion=

In Conclusion

After all of this jibber-jabber, this is ultimately a simple problem to which I’ve given a simple solution.  I’m sure there are other (better?) ways to handle this sort of thing, but until I find them I’ll be using this to alleviate at least one other thing in my CI/CD pipeline.

Just to make sure I’m remembering to share, I’ve published a PHP version of this system on my GitHub for your amusement.  I’ll probably throw this (or at least some version of it) into one of my many-splendoured frameworks at some point, but for now I think I’ll move on and get back to some actual work.  Enjoy!

– Andy

Read More
Development, Fitness, General, Self

Build Body

Since I started working from home, I’ve noticed that I’m quickly sliding back into a sedentary lifestyle.  I’ve purchased and haphazardly assembled a sit/stand desk that I enjoy greatly, but there is of course always the desire to do JUST a bit more.

Once upon a time, I had dreamt up a system to use while playing MMORPG’s wherein a person would enter the level their character had just achieved and be presented with a quick workout to perform as celebration (punishment?) for the effort.  It was at the very least amusing to my friends and I, and that’s about all the motivation I need to attempt anything.

So in the same vein, let’s just dive right in!  I’ll call this “Build Body” and hope the Beach Body people don’t find a reason to be unhappy with me.

The System

The table should be self-explanatory, but just in case you’re a person who wants the bullet-points:

  • Wait until a build has completed
  • Tally all exercises based on the build results
    • If you had a build with 2 commits and no failures, you would do:
      • 9 pushups (5 for build + 2 * 2 for commits)
      • 20 crunches (10 for build + 5 * 2 for commits)
      • 20 air squats (10 for build + 5 * 2 for commits)
      • 20 jumping jacks (10 for build + 5 * 2 for commits)
    • If you had a build with 1 commit and a failure with 2 tests failing, you would do:
      • 30 pushups (5 for build + 2 * 1 for commits + 15 for failed build + 4 * 2 for test failures)
      • 65 crunches (10 for build + 5 * 1 for commits + 30 for failed build + 10 * 2 for test failures)
      • 65 air squats (10 for build + 5 * 1 for commits + 30 for failed build + 10 * 2 for test failures)
      • 65 jumping jacks (10 for build + 5 * 1 for commits + 30 for failed build + 10 * 2 for test failures)
      • 18 burpees (10 for failed build + 4 * 2 for test failures)
  • Perform exercises to the best of your ability
  • Decide to never fail a build again

In Conclusion

Obviously the usual disclaimers about strenuous activity apply.  Probably don’t attempt this without consulting someone who is a trained medical professional.  Definitely don’t force other people to do this, that would make you a psychopath.

Will this end up in me being healthier?  I can’t speak for anyone else, but for me I actually suspect it’s more likely I’ll just find a new way of injuring myself.

Aren’t you just showing off how fit you are?  If you’re willing to assume I’m capable of keeping up with those build exercises, I’m willing to let you believe I’m showing off.

Now if you’ll excuse me, I have to go rewrite my entire CI/CD pipeline so that it can never fail…

– Andy

PS – Because why wouldn’t I, here’s a simple calculator for the build workouts:

Read More
Development, General, JavaScript, Mobile Development, PHP, Self, Weekend Projects

Weekend Projects Gone Awry, Part 3

Things will be a little different this time. With the two previous entries in this series, I was recapping work on a new idea/project and had to relay information about the project. This time, however, I’m simply extending Part 1 into the mobile arena and trying out some “new” technologies. That disclaimer done…here we go!


A Recap: SlimSocial

SlimSocial is the fledgling social network devoted to making “being social” more difficult. The key limiter was that a person can only post once per day, in theory cutting down on the useless chatter that happens constantly.


Going Mobile

After pushing out SlimSocial, several of my good (aka misguided) friends decided to latch onto the idea and enjoyed the concept. It didn’t take very long for the first “can you make it work on my phone” request to come through, and after the fourth or fifth in a row I begrudgingly admitted that I could probably look into making a set of apps. I made sure to stress to each person that it was a lot of work and unlikely to be something I’d complete for months.

So of course, I started on it a couple days later when I’d finished working on Part 2.


Executing (aka Enter Cordova & AngularJS)

Last year at Microsoft’s //Build conference, they made a pretty big deal about their new cross-platform features in Visual Studio. I’d avoided it, as my past work with cross-platform mobile development via Marmalade proved to be tiresome and less than smooth, but I decided I had an opportunity to give the whole package a shot.

One of the other things I’ve been avoiding has been the concept of SPA (Single Page Application) frameworks (Angular, React, Riot, etc). Generally speaking, I find the whole idea to be a quick way to ask for trouble with performance, and they just seemed like trouble to learn.

So there it was. I felt I had the opportunity to learn two new things, and I took that opportunity. After finishing the game engine for Part 2, I continued streaming on Twitch while I fumbled my way through learning both AngularJS and Cordova at the same time within Visual Studio 2015. In the end, I’d say I managed to dump an obscene amount of my free time into this extension of SlimSocial, but on account of forgetting to track my time we’ll just put the estimate around 80 hours.

If you’re reading this and are expecting me to begin expounding the merits of both Cordova and Angular, you should probably stop reading now.


Tech Notes

Now…I can be pretty opinionated. I’m aware it may be a bit of a character flaw, but it’s part of me so you’ll either learn to ignore it or you’ll go away. Learning two new technologies at the same time goes against some hard-learned lessons for me, but it’s not as though I intend for SlimSocial to ever be a serious time-sink (I understand that it has become one, but we’re talking intentions here).

Cordova seems like a pretty promising bit of technology. It’s not as though it’s a new piece of technology, I remember PhoneGap and others being around nearly 4-5 years ago, but it’s not the sort of thing I like to use on account of much of my mobile work having very specific performance requirements that can’t be achieved by wrapping an app within an app (which is basically how Cordova works).

That said, it’s not perfect. Some of the workflow can be aggravating, and figuring out how to configure things on the different machines, while not bad, is far from perfect. Even so, I imagine whenever I have projects in the future that don’t need me to squeeze every ounce of clock speed I can out of a phone I’ll be turning again to Cordova and its VS 2015 integrations.

And then there’s Angular… I can’t tell you how many times I’ve been told I need to learn Angular/React/Riot/Backbone/Knockout/Whatever. It’s borderline ridiculous how many frameworks there are that achieve more or less the same thing. Angular’s learning curve is pretty fascinating as well, starting off shallow when you look at the tutorials, and then taking a curve so steep that it feels similar to running into a wall head-first.

Angular calls itself “Superheroic” on their website, which is a pretty vague thing. Does it work? Sure. Does it do so in a way that’s easy to grep? Not at all. You have to learn intricacies of the entire framework in order to do even marginally complex actions for your app. You also need to grapple with incomplete and/or insufficient documentation when trying to learn said intricacies, basically relying on Bing or Google to show you the dark corners of StackOverflow where your answers lie.

I’ll try out Angular and one of the other frameworks for another project or two, just to be sure I’m giving it a fair shot, but thus far my decision to stay away from these libraries is feeling pretty justified.


Conclusion & Reveal

Once again with SlimSocial, I had hoped to make my prototype over the course of a weekend. This estimate was built off of my experience with doing prototype mobile development natively, and thanks to the learning curves of both Cordova and Angular I was about as far from correct as could possibly be (which is the reason I have a personal rule to not learn new technologies for business critical projects).

Adding onto this, there is a problem with distribution. In order for me to properly make this app available to individuals who aren’t interested in testing, I’ll be shelling out some serious dough to Apple and Microsoft (and subjecting myself to the chaos that is the Android build process). I’m not sure how willing I am to do that for SlimSocial. However, when the day comes that I do renew my Apple and Microsoft developer accounts, I’ll probably publish this immediately. Until then, enjoy some screenshots of the app working on my Windows 10 desktop.

home feed
friends profile


– Andy

Read More
C/C++, C#, Development, Game Development, General, Weekend Projects

Weekend Projects Gone Awry, Part 2


The Idea: Outmoded

A friend visited me recently in Boston, and while we were being typical lazy gentlemen, the prospect of developing a game together at this year’s Global Game Jam (GGJ) surfaced. Though lately I’ve found it hard to be interested in anything to do with games or game development, but we agreed we’d like to make something without “graphics” that simply ran in the console. And so it was, that I created a project called “Outmoded.”



The first revision of Outmoded was done over two days while at the Barker Engineering Library in MIT. I chose C# so that I could finish the work in a few hours, and I’d estimate a total effort of about 5 hours was put into the project. The system worked within acceptable constraints and only had problems if you found yourself clearing the entire screen repeatedly for animation effects.

However, as the GGJ drew gloser, Alex asked if it wouldn’t be more performant to build the system in C++. Anyone who knows me well knows that I have an addictive relationship with C++, so ultimately it took very little for him to convince me this was the obviously correct path for the project. I created an experimental branch, scrapped the code, and got to work.

Over a couple work sessions I rewrote everything and had a simplistic proof of concept working on both Windows and certain flavors of Linux/BSD/OSX.


Tech Notes

As it turns out, moving to C++ was potentially a final nail in the coffin for the GGJ collaboration. Though I got to relearn things I hadn’t used in well over a decade (potentially closer to 15 years), makefiles were never a strong suit and OS X appears to have some fascinating ideas on development, which is no surprise to anyone who has used XCode. Also, there was a lot of struggling with Clang as the compiler on Linux, eventually forcing me to revert to g++ in order to get the makefile working.

This was excellent practice for some upcoming cross-platform C++ work I’ll be doing before the summer, and I’ll be very thankful for the rust removal this work provided. There’s a very obvious advantage for using Windows as a development environment, I was much more productive/effective there than on Linux.


Conclusion & Reveal

The GGJ theme, “Ritual”, seemed like a great opportunity to build an interesting yet simple game, but the fatigue of debugging the engine’s production proved too much of a negative for some of the team. Thus we have opted to bury the project and explore other avenues. What does that mean for Outmoded? Not much, frankly. I’ll probably fix the remaining bugs if they aren’t too troublesome and maybe add a frame feature, but I’ve gone well past the amount of time I intended to pour into this trivial thing.


– Andy

Read More
Development, General, JavaScript, PHP, Self, Web Development, Weekend Projects

Weekend Projects Gone Awry, Part 1

Lately I’ve been spending a lot of time at home, which has produced an odd side effect.  It seems the more time I am left alone, the more I get stuck on ideas without real merit.  Generally speaking, these are passing thoughts at best, but sometimes one takes root and seems dedicated to obstructing real productive thought.

In past years, I’ve simply bided my time until the thought eventually passed.  The more recent thoughts, however, don’t seem to be following the pattern.  Whether because of changes in my personal life, or the ongoing process of maturing, I find myself having to invent new methods for clearing my mind.  And so we find ourselves here, dear reader, where I will attempt to quickly bring these concepts to life and subject you to the process.


The Idea: SlimSocial

At heart I am most comfortable playing the role of an introvert.  As such, the world of social networking is irksome to say the least.  Don’t get me wrong, I have met many great friends thanks to the internet, but I also think they talk too much at times.  With that in mind, I’d like to introduce you to “SlimSocial,” my solution to social-overload on the internet.



Instead of allowing everyone to talk so much, I wanted to create a simple network that limited the number of posts someone could make per day.  Initially, I’d envisioned limiting everyone to one post per day, and most of my prototype work has been done with that in mind.  If I were to put more work into the system, it would be more appropriate to generate a system on top of the “likes” and “dislikes” a person accumulates.

Speaking of likes/dislikes, since I’m robbing people of the ability to flood the network with their idle musings, I certainly can’t take away their ability to show support or disdain for their fellow network members.  Still, I couldn’t quite re-use the terminology of sites like Facebook, Reddit, etc.  I spent a while racking my brain on what to call this feature, and eventually got a helping hand from Jordan.  He took the “Slim” in the title a bit more anatomically, and suggested the system use weight loss or gain to represent likes and dislikes, respectively.  Imagining the confusion this could cause, I quickly jumped on the idea and the chance to further solidify the network’s uselessness.


Tech Notes

There aren’t really any interesting tech notes for this project, except to say that there aren’t any interesting tech notes.  What I mean by that is that I decided to forego utilizing any frameworks outside of jQuery and Boostrap on the UI.  This was the first PHP project I’ve done in years without my framework (N2F) save for a game to keep tallies of annoying phrases on phone calls I did for a friend over the course of 2 hours.  The whole experience was…enlightening.  I can now say I know what parts of my framework are the crucial ones that really do save me lots of work.  Beyond that, I might say I got to practice a little more with build/release automation in TeamCity, but that was less a goal for the project than it was a result of my server outage.


Conclusion & Reveal

I had hoped to make the prototype for this project over the course of a weekend.  The mockup took about an hour after I found a template, but the remainder of the work was broken up due to said server outage, the holidays, and of course my day job.  I’d estimate I spent 4 full days of work (32 hours) on the project to get it to where it sits today.  The prototype is essentially complete, and though there is obviously more work to do, it is time to move on…or so I hope.


– Andy

Read More
Development, Powershell

Powershell, Oh Powershell

At my job we use Powershell a lot.  I’ve always known that PS was a pretty powerful beast (you can have it compile C# for you on the fly to build more complex commands…that aint bad!), but as I’ve spent more time with it on an almost daily basis I have come to love it for a lot of different reasons.

As I fall harder for Powershell, I’ve decided to start hosting some of my scripts and modifications to scripts for others to use.  Follow the link below and I’ve included some simple instructions.  If you have any question (or suggestions), let me know!


– Andy

Read More
C#, Design Patterns, Development, General

The Repository Pattern

[UPDATE: 01/30/2014] I have been informed by a friend that common terms for these two types of repositories are ‘generic’ and ‘specific’. As a result, I have updated the post to use this terminology instead of what I’d chosen (monolithic and disparate).

Having finally found myself being introduced to the finer points of computer science at my new job, I am enjoying the foray into a touch of philosophical programming discussion. This will be (hopefully) the first in a haphazard series of posts outlining my own thoughts on those discussions. Full disclaimer, I am still pretty new to correct terminology and thus likely to fumble with their use…I’m not sorry, but I also don’t mind being corrected.

Repository (As I Learned)
When I first learned of the Repository pattern, I was shown an approach to encapsulating access to data entities that simply removed the business layer from having to touch queries. You provided an object that wrapped around your entity and thus made it so there was only one place to go when it came to add/edit/delete methods used by the rest of your code. A simplified example of this might look like this:


It’s simple, and it tends to significantly clean up your business logic if you’re the kind of person who just tosses their queries hither and tither. One coworker seems to have coined the term ‘monolithic repository’ when trying to describe this approach, and I’ll be using the word ‘monolithic’ moving forward. Apologies to anyone who thinks they came up with it first. The common way to refer to this approach seems to be calling it a ‘specific repository’, so we will be referring to this hereafter as ‘specific’.

IRepository and IUnitOfWork
At work we are beginning to implement what I have been told is a “pure” version of the repository pattern. As it was explained to me, there are really two patterns, the first being the Repository and the second being the UnitOfWork. To simplify what I was told, you would say that a Repository provides access to a set of data and UnitOfWork writes any changes to the set of data to their source.

In order to accomplish this we’re using a bit of dependency injection (DI) along with two interfaces:


We also have a Repository<T> class and IUnitOfWork<T> class which are used by the DI to satisfy the requirements a class may have. The implementations can be found pretty easily with a web search, so I hope you don’t mind me skipping them for now. For the sake of this post, I will be referring to this approach as ‘disparate’. The common way of referring to this approach is to use the terminology ‘generic repository’, so we’ll use that from here on out.

Bridging the Gap
The specific approach provides repository objects which are fairly customized for entity interactions. Initially the generic approach does not, but there is a fairly easy way to overcome that in C# using extension methods:


Since we are using DI in our system, we know that we will always be initially referencing the repository dependencies by their interface, IRepository<T>. With this in mind, we can easily create an extension method for all sub-classes of the interface giving them access to the FindUsersByEmail() method, just as we had implemented with the specific approach.

The specific approach can easily be rearranged to reflect the basic UnitOfWork separation from the Find/Add/Remove methods, so I won’t waste the space showing the simple movement of the Db.SaveChanges() call into its own method.

Fight! (And Conclusion)
Ok so there isn’t really a fight here, at least not from my perspective. Both approaches afford the ability to swap out sub-classes and instead use mock data storage (probably through a List<T> or similar) for building unit tests. Both approaches encourage users to keep their business logic devoid of direct queries to the data layer (assuming you use something similar to the extension methods above to provide custom entity-specific methods for the generic repositories). It almost feels as if the choice between the two comes down to a personal preference, since with either I can easily implement the behavior of its counterpart.

Still, the times that I have discussed this with my coworkers I got the sense that there was a natural desire to side one way or the other. Purists seem to prefer generic while pragmatists mostly side with specific.

One of the reasons I wanted to write this post is to see if anyone could show reasons one approach is truly better than the other. Do they perform differently to an extent worth citing? Are they easier to implement than the other? Do they save significant effort? I certainly can’t say. My only thought is that it would be much more difficult to adapt the generic approach to a data access system which doesn’t rely on in-memory storage of change sets (perhaps direct SQL).

Regardless of the result of any argument, it’s at least been fun grilling coworkers. Here’s hoping this is just the beginning of the study of the ‘finer points’ in programming.


– Andy

Read More
C/C++, Development, iOS, Marmalade, Uncategorized

Small Automations

I’ve been doing a lot of work recently with Marmalade on some mobile applications. In the process, I’ve slowly fallen out of love with the build process that Marmalade provides, mostly as a result of the signing process required to publish iOS builds. I won’t weigh in on where the blame should rest for this ire of productivity, but I might as well share one of the tiny things I did to make things go ever-so-slightly faster.

We use TestFlight internally for build test distribution, so the process for distributing each build to the testers looks thus:

  1. Write code, watch code fail, fix code
  2. Test locally with emulator and USB connected devices
  3. Build on GCC ARM Release to launch the Marmalade Deployment Tool and package for both iOS and Android
  4. Launch Marmalade iPhone Re-Signer to Re-Sign the IPA for your selected provisioning profile
  5. Remember you have to move the base certificates into the deployment folder when the Re-Signer tells you it failed
  6. Let loose mumble of vulgarity OR Pull out small patch of hair to imprint that this is bad behavior
  7. Find the certificates and copy them to the deployment folder with the IPA
  8. Run Re-Signer again
  9. Upload builds to TestFlight

The process isn’t hard, by any reckoning, but there were…undesired consequences for some of the team members.

You'd think he'd have learned eventually...

You’d think he’d have learned eventually…


Obviously, something had to change. I weighed my options quickly and simply created a BATCH file to take care of launching the iPhone Re-Signer. Instead of simply launching it, the BATCH attempts to copy the required certificates into the deployment folder before launch. I haven’t had a chance to make it configurable for multiple projects, but I’ll just update the code here whenever I do have that time. Hope it helps someone!


cd \Tattoo\Clients\PlateShare\Apps\PlateShare\build_plateshare_vc11\deployments\iPhone\iphone\release

mkdir certificates
cd certificates

xcopy "D:\Marmalade\6.3\s3e\deploy\plugins\iphone\certificates\Apple Root CA.cer" /y
xcopy "D:\Marmalade\6.3\s3e\deploy\plugins\iphone\certificates\AppleWWDRCA.cer" /y
xcopy "D:\Marmalade\6.3\s3e\deploy\plugins\iphone\certificates\developer_identity.cer" /y
xcopy "D:\Marmalade\6.3\s3e\deploy\plugins\iphone\certificates\developer_identity.key" /y
xcopy "D:\Marmalade\6.3\s3e\deploy\plugins\iphone\certificates\distribution_identity.cer" /y
xcopy "D:\Marmalade\6.3\s3e\deploy\plugins\iphone\certificates\distribution_identity.key" /y

start D:\Marmalade\6.3\tools\IPhoneSigner\IPhoneSigner.exe


– Andy

Read More