How We Solve Problems: Inception

As any good developer, I’m constantly trying to keep up with the latest and greatest, as well as brush up on the oldies and goodies of the skills I leverage daily. As a full-stack developer, I tend to study in cycles, switching between “front-end” and “back-end” skills. In June I presented some thoughts on typography at To prepare I focused quite a bit on design principles. To balance that out, I decided to up my analytical skills and focus next on reviewing design patterns.

“In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.”


Some of the top minds in the world have worked out, not only the best way to solve various problems that repeat themselves, but also how to quantify that.

This idea made me curious regarding how this approach can, and has, been applied outside of the world of Computer Science.

An example: Memory Leaks. A memory leak occurs when a programmer, or a language, uses the computer’s memory but neglects to free up again the resources it used.

When your computer sees that it’s running out of resources it starts to borrow memory from other processes that are running in the background, but it can’t return those resources because of the rogue program wastefully using them. Consequently, the computer has fewer resources to run the programs it runs and slows to a halt.

This is what happens with most forms of limited resources, whether financial, stress, emotional, or focus.

People spend money, sometimes it seems like a good idea at the time, but we don’t always reclaim those resources when we’re done, or when we decide it wasn’t a very good idea. We end up throwing good money after bad; either to justify the original decision, or because we don’t have the ability, energy, or know-how to go back and reclaim the wasted resources.

Can techniques developed to find memory leaks be applied to financial management? Can garbage collection be applied to stress management?

I am a strong believer if we have a skill in one area of our life, that skill spills over into other areas of our life…. and developers solve problems all day long. I decided to write a series of articles about how developers solve problems, outside of code.

I was inspired by Advice from Strangers, to explore this in the form of a series of articles. I developed a Google Form to dig deeper and begin research:

This form is designed to trigger the results as much as it is designed to collect examples of them. Some of you have graciously given your time to answer these. If you haven’t yet, I’d be grateful.

I’d love to get the widest range of perspectives as possible, so if you can think of any creative developers who might have something interesting to say on this topic please pass this on to them.

All final answers in by August 10th please so I can bring them into the articles.

Interested in getting updates about this project? Sign up here or email “Hell Yeah” to developersguide (at) this domain.

    How to use JSONP (AJAX to SSL) in WordPress, an EASIER way

    I’ve already written about How to use JSONP in WordPress Development. I explain how it works, and why you would use it there.

    At work we work with several domains and I’ve had to use quite a bit of JSONP, I’ve rethought how to use it, and made this micro-framework to make it a LOT easier. Mostly, I wrote this to solve the problem that I’m using a lot of AJAX, and don’t want the overhead of the .ajax call each time.

    There are a lot of values you need to set when making a JSONP call in general, and specifically with WordPress, this greases those wheels.

    The paradigm is all you do is execute:

    wp_jsonp("wp_jsonp", "getStuff", {variable: "hello world"}, getStuff);

    and the rest is taken care of on the JS side. I wrote it to be agnostic of the server-side processing as well, this gives you the benefit of a pseudo factory design pattern with your switch statement.

    You can download the whole repo to peruse or play with if you like, I made some gists for easy embedding.

    This is the guts of the operation, I created this javascript object that handles everything, you past the ajax event, method, parameters and a callback function. The plugin takes care of the nitty gritty details that are a pain to remember for getting jsonp to work.

    It’s well commented, so read through and feel free to ask questions in the comments if you have any.

    Here’s the example, you might say, wait a minute, don’t you get a callback from jQuery already? Sure, good luck using it. It’s a little funny ignoring that, but hey, this works nicely.

    Maybe I’m overthinking / over-complicating things, I don’t know, once it’s set up you can move really quickly, isn’t that the point of a framework?

    Just one important note: make sure to validate the hell out of things because you’re giving that JS function a LOT of power.

    I’d love to hear your thoughts, if you have suggestions for improving it, by all means, please comment below!

      Why we need to avoid taboos

      “At the great religious metropolis of Hierapolis on the Euphrates pigs were neither sacrificed nor eaten, and if a man touched a pig he was unclean for the rest of the day. Some people said this was because the pigs were unclean; others said it was because the pigs were sacred. This difference of opinion points to a hazy state of religious thought in which the ideas of sanctity and uncleanness are not yet sharply distinguished, both being blent in a sort of vaporous solution to which we give the name of taboo.”

      – Sir James George Frazer, The Golden Bough

      Frazer posits that the source of pig being forbidden in the Middle East in ancient times was due to its sanctity, via the worship of Attis and Adonis, rather than its uncleanliness. Throughout The Golden Bough Frazer brings numerous examples of how an animal, or object, or place went from being sacred to being profane due to its taboo status.

      Whether you accept the thesis of the pig, this idea is found elsewhere. From one generation to the next, once something became forbidden, the reason for its being forbidden got lost.

      I grew up with a story about a woman who wanted to get the recipe for her mother-in-law’s pot roast. One thing that puzzled her about the instructions was where that she was told that she needed to cut off the ends of the pot roast, or else it wouldn’t be kosher. When she found the source of this custom, she discovered that the pan, in which the originator of the recipe used to roast her pot-roast, was too small. But because her mother-in-law hadn’t asked why, she thought it was a necessity.

      I was taught this story as an example of the importance of questioning things that don’t make sense to you. When people avoid something, and it becomes taboo, the reason they avoid it gets lost, because they don’t transfer that knowledge.

      I’m concerned about how it’s no longer acceptable to discuss things that make people uncomfortable. I’m afraid that if we cannot talk about these things,  we are giving up our power to work through them and find real solutions. Whether it’s religion, race, or body image, it’s toxic to make discussion itself taboo. If we cannot talk about something, it means that we will lose the very reason why the issue is important.

      Case in point, how many people who were so adamantly supporting the confederate flag knew that its popularity rose in the 50s and 60s in direct reaction to integration?

      When we don’t talk about things, their knowledge gets lost.

        WPNYC: Typography – What You Should Not Do

        I had the privilege of giving at talk on typography at the New York WordPress Meetup. The video has been posted to, I hope you enjoy!

        Note: This talk’s focus is on choosing fonts, not typesetting. There are some mis-uses of quotes and dashes here. Mostly due to bad habits developed as a result of their incompatibility with code.

          How I Rea[r]d – Audible has changed everything

          We all make resolutions as the new year comes around. Most don’t last a month, but half way through, mine seems to have stuck (tfoo tfoo) and I’ve been reading a book a week since January.

          Over the past few years I’ve discovered that while I’m coding I am most productive when I listen to things. When I’m working on something that takes a lot of brain power that tends to be Bach or Mozart, a little less brain needed — Led Zeppelin or The Beatles. However, two thirds of the time I’m doing things I’ve done ten times before, it takes expertise, but not much brain power. That’s when I listened to podcasts.

          TWO Free Books on Audible

          About a year and a half ago I decided to try Audible instead of podcasts, I had just finished the back log of This Week in Startups and my day was feeling empty.

          I rarely listen to podcasts now, I still have my few favorites, but I’ve been eating up all the books I’ve been missing, and discovering so many more I never knew I’d been missing. During my commute, during workouts and at work. I am a fanboy and am grateful.

          Check out my reading list, I’ll keep adding to it as the year goes on.

          I’ve decided to share my list now, because I’ve been feeling more and more a need to discuss what I’ve read. So if something jumps out at you on the list, leave a comment, or email me directly. I’d love to discuss.

          Note: since I am reading with my ears (rea[r]ding) I’m also considering literary audio performances and courses as a complete book. You may disagree that listening isn’t really reading, it’s not quite as it is passive. But the outcome is the same, I’ve consumed the literary work in it’s entirety.

            Typography, how to choose fonts for your site – WPNYC

            In this talk I covered what you should consider, and avoid, when choosing fonts for your site.

            Note: There are captions below the slides when it is in slideshow mode. For expedience, I resisted the temptation to mess with the caption styling.

            Also note: This talk’s focus is on choosing fonts, not typesetting. There are some mis-uses of quotes and dashes here. Mostly due to bad habits developed as a result of their incompatibility with code.

              Web Typography – A quick and dirty guide to Enqueuing Fonts in WordPress.

              This coming Tuesday I will be speaking at WPNYC, the official New York City WordPress Meetup, on the topic of WordPress and Typography.

              Having started out as a front-end developer, I have always been inspired by beautiful typography used properly. I will post my slides once the recording of the talk goes live, but for now, in preparation, I thought it would be nice to post something about how to actually use typefaces on your site that are not available by default.

              In my talk I will cover this topic as well as a provide a few tips on what to avoid when choosing and implementing your type choices.

              What’s available?

              We are living in a wonderful age of type. There are hundreds of thousands of fonts available online. Which should you choose? I’ll cover a little of that on Tuesday, but for now, I’ll leave it up to you. Here are, IMHO, the three most accessible options where you can find some interesting choices:

              1. TypeKit – Now owned by Adobe, a truly rich and easy to use platform. proudly uses TypeKit fonts. Free account allows two fonts, which is just fine for most any creative designer to utilize.
              2. – While it’s a pretty site, navigation is clearly focused on being unfriendly towards people wanting to try the service before they buy. Here is the buried link to the free fonts.
              3. Google fonts – It got a lot of negative reviews at the beginning because, honestly, they weren’t very discerning. However, since then a lot of money and effort has been put into getting some quality fonts available.

              Notable mention: Font Squirrel, they don’t host font files, but it’s a great resource for finding affordable quality fonts. Their Webfont Generator is great for helping you find the ideal “bulletproof @font-face syntax“.

              Simply add the above into your stylesheet and you’re good to go using: body { font-family: corbert-regular<span class="pl-pds">', sans-serif; </span> }

              A note on “free” fonts

              “Free” often means you’re paying in some other manner. “Free” fonts are often knockoff fonts of well crafted classics. Why should you care? Because if you’re going through the trouble of caring about details to the level of which typeface you want to show your content through, you should care about the quality of that typeface.

              Alternatively, a free font may be designed by an amateur designer, who then releases it because it’s not quite professional yet.

              What’s missing? A lot goes into the crafting of a quality font.

              • Italics, aren’t simply a font tilted, and bold isn’t simply a stroke added to the font. If you’re okay with doing that, JUST STOP READING NOW. LEAVE. SERIOUSLY.
              • Kerning, each letter fits differently with each letter pair, a quality font will have the pairings programming in. Interestingly, pairings are effected by font-size as well.
              • Overall quality, cheap knockoffs and novices won’t take scaling, or details properly into consideration.

              Is “free” EVER OK? Yes. Over the past few years Google and Adobe have been commissioning fonts for open source projects. While Google Fonts once was a bastion of amateurism, it now has some high-quality complete font families. As with software, the open-source community has come to the rescue.

              How do I do it?

              Each of the above tools have their own way to create a collection of fonts, and all have great walk-throughs. Once you generate one replace the above code / paths with your custom generated one. Don’t forget to comment out, or remove what you’re not using.

              Now you just use the fonts as you would any other in your stylesheet.

              body { font-family: 'Josefin Sans', sans-serif; }

              Note: enqueue_script() by default will add the script to the head of your site. If the font provider states that you need to enqueue your script in the footer of your site WordPress has you covered:

              wp_enqueue_script( 'add_my_font', '//', array(), 20150613, true ); 

              That “true” at the end will place the script into your site’s footer.


                How to recursively make a directory (folder) with PHP

                When I need to generate or save files in a web application it’s important that I keep all the files in an orderly fashion.

                Sometimes I think that there’s a fine line between impressionistic and messy.
                Lady Gaga

                Here’s the go-to code I use to generate the directory structure.

                You can find more solution on this StackOverflow thread.

                How it works

                is_dir() is a native PHP function that will say if a relative path is given is a directory or not. If the path doesn’t exist, it will return false.

                || – is the OR operator in PHP. If the path is a directory exists the function will return without moving over to the second part, because we’re saying do this OR that.

                mkdir() is a native PHP function that will create a directory at the path location that is given.

                The parameter $path is the path where the directory should be created.

                The parameter $permissions is the chmod() settings of directory being created.

                The ‘true’ creates the directory recursively. This means that you only need to create the path, and you don’t need to make sure the whole path exists. It will fill in the gaps.

                Why not just use mkdir() by itself?

                You can, but if you do, and the directory already exists, it will send out an error to the log. Nothing terrible with that, I just like keeping things clean.

                  Don’t be TOO clever with your UX designs – Why I cancelled my Coin

                  Edit: After reviewing Plastic, I decided to go with them. First and foremost, their security isn’t over-thinking things. Second, their card actually recharges, so you won’t have to buy a new one after a year+.

                  * * *

                  I was excited when Coin announced their campaign. I love technology, and this is a great example of innovation being used to make life easier. I have several credit cards, it’s good for your credit score, and keeping track of them is a pain and risky. I’d rather keep them safely at home and use secure device out in the wild.

                  When I first received the notification to download the app I set it up. I had a little trouble setting up the Tap Code. I had a little musical training growing up, but that was a long time ago, and I never got around to learning Morse Code. I finally entered a code that was acceptable, but how do you write that down?

                  Months later I saw that Coin was starting to ship so I tried to sign into my app to see when mine would come. I’d been waiting for it for a while and was excited.

                  Tap Code: Damn. What was it again?


                  I went to reset it, had trouble getting something complicated enough that was acceptable. Again. This time I tried noting it down in 1Password with dashes and dots.

                  Later that day I decided to try signing in again. Even with the dashes and dots I couldn’t sign into the app.

                  I applaud them for trying something new, but at that point I was starting to get concerned about ever being able to use my Coin. So I looked through the app, no there is no alternative to using the Tap Code.

                  At that point I wrote to them asking them if there are plans for an alternative for people like me who can’t seem to get their innovative password alternative working. The email I received in response, I felt, was patronizing. It explained how to set up the Tap Code, and made me feel like an idiot. I’ll give them the benefit of the doubt, maybe they’ve had a bunch of people who couldn’t set it up, maybe due to my frustration I was reading into the tone of the email. The person clearly didn’t read my complaint and sent me an answer explaining what they thought I was asking about.

                  Maybe I should learn Morse Code, but that wasn’t even the issue, I couldn’t get it working even after I had written down my code. I responded asking if they have plans integrating an alternative for people like me, and no they didn’t . So I requested a refund.

                  With innovations, it’s important to make sure they work well, if you want people to use them. If your innovation is truly unique and different, It’s also important to make sure there are alternatives, if you want your users to be comfortable enough to try your innovation out.

                  Even Apple had a password fallback when they first implemented the fingerprint reader. Now the password fallback is gone, but that was there for the first year+, until they ironed out all the details.

                  In addition to being concerned about being able to use my coin at all, I was just as concerned about their approach to UX. I’m not an average user, and I couldn’t use their technology effectively. If they’re not responsive nor thoughtful about THIS innovation, what other aspects of their system and security are they NOT thinking through?

                  At least I got my money back, but I’m disappointed. I wanted to use their tech.

                  I don’t know how many people they testing this concept with. I couldn’t find many articles about the security benefits of tap codes over pins. Historically Tap Codes are interesting, but they’re for communicating, not for identity. I think it’s a real shame that their approach is bullheaded and unthoughtful.

                    If you feel that this site is running snappier, you’re probably right.

                    I went to 3 meetups this week:, WPNYC, and Web Performance NY.

                    At two of them people mentioned Percona. So I thought I’d check it out. Digital Ocean has a great tutorial if you’d like to check it out: How To Install a Fresh Percona Server or Replace MySQL. I got stuck for a bit, but found a solution deep in the comments of a StackOverflow answer. It turns out that when I removed MySQL to install Percona it removed the php5-mysql module.

                    Before installing it commando on my personal site, I tried it first in my dev box at work and got a 5x improvement in speed.

                    This is not a scientific experiment, I implemented two other improvements as well:

                    • Switched from W3 Total Cache to WP Super Cache.
                    • Expanded my Digital Ocean instance as Percona recommends 1GB RAM.

                    Hope this helps you’re reading experience at my digital home.