How does the WPEngine GeoIP service work?

Today WPEngine launched their new GeoIP service, and I was excited to check it out. After doing a presentation on handling Geolocation in WordPress I know it can be a difficult problem to solve at scale, especially with any kind of caching.

The way it works is by having a plugin installed that gives you functions to grab the city, country, and region:

$geo = WPEngine\GeoIp::instance();
echo "Welcome from {$geo->city()}, {$geo->region()}, {$geo->country()}!";

With access to the location in this format, you can start to show specific content or features depending on where the visitor is from.  Someone coming into your store from England?  Show them £ instead of $.  What about Japan?  Default the language to Japanese without asking them.  WPEngine will detect that you’re serving different content for different users, and cache in ‘buckets’ without you having to configure anything.

The service does require a Business level plan or higher, but chances are if you’re serving multiple countries you’d be at that level anyway.

You can view the full FAQ on the new feature.

Discover #HamOnt Podcast

I’m putting together a podcast called the “Discover #HamOnt Podcast,” where I’ll be interviewing a number of groups, businesses and individuals in the #HamOnt area to discover what they’re all about, and why they love it in Hamilton.  I hope those who live, work and play in Hamilton will discover more about the people and businesses around them, along with everyone’s unique perspective on the city.

The podcast page is available at:

discoverhamont.ca

Sign up to be notified when the show launches!

Just because WordPress still supports PHP 5.2 doesn’t mean you have to

WordPress still has a minimum PHP 5.2 requirement, which has many known security issues and reached end-of-life back in 2011. 4 years ago. A lot has changed in PHP and software development in general since then, and while WordPress should perhaps be taking more of a leadership role to push for change, it doesn’t mean we have to wait.

Digging into core, the “WordPress way” might appear to be to use global variables for most of your core objects, and to have large files with logic and HTML output interspersed rather than the logic and view separated.  I can still take the core WordPress pieces and add more reusable, modular and testable code on top of it.

Maybe I want to pull in libraries from Laravel into my plugin or theme?  I can do that.  Add or create a framework to control a more complex theme admin interface rather than a behemoth functions.php file?  No problem.  Use namespaces and variadic functions?  Sure.

Of course that doesn’t mean I should start overriding things like the Template Hierarchy, making it more difficult for developers to jump in and find the views they need to modify, but outside of those standard file conventions, the sky’s the limit.

How to change the WordPress permalink structure to remove dates from the URL

If the content you write isn’t date specific (ie. news), it’s a good idea to remove the date from the URL of your WordPress site.  This is also good if, like me, you don’t blog on a super regular basis and don’t want people to know the awesome content you wrote is actually a few months old.

Switching the permalink structure from /year/month/post-slug to just /post-slug is easy by going to Settings > Permalinks and choosing “Post name”:

Screenshot of WordPress permalink settings

But you don’t want any links to your old URLs to end up generating a 404, negatively affecting SEO.  To fix this you’ll want to add in a redirect into your .htaccess file similar to:

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://yourwebsite.com/$3

Yoast, the makers of the WordPress SEO plugin, also created a handy redirect generator, in case you were using a different permalink structure before or you have WordPress installed in a subfolder (ie. /blog).

How to fix slow sendmail on a Digital Ocean Ubuntu droplet

I recently switched over to Digital Ocean for my main server thanks to Bryan Poetz‘s  suggestion, and was running into an issue where mail was sending but slowly. Turns out there were two problems.

First, I had named the droplet “main” (since it was, you know, the main server), but this really should be a Fully Qualified Domain Name (FQDN) instead. So I renamed the droplet to main.bhconsulting.ca and restarted sendmail. However looking at the mail logs I saw lots of:

unable to qualify my own domain name (main) — using short name

Since it was still using “main” as the server name. Thanks to help from this thread I modified the /etc/hosts file from:

127.0.0.1 localhost
127.0.1.1 main main

to:

127.0.0.1 localhost.localdomain localhost main.bhconsulting.ca
127.0.1.1 main.bhconsulting.ca main

voila, fast sendmail.

Review on Attending EDMBiz 2014

I’ve been a fan of electronic dance music (EDM) for a long time. I decided to attend EDMBiz to learn more about how the industry worked behind the scenes, and if there was a way I could combine my love of the music with some kind of software related product or service.

Overall the conference was well run, and I got a lot out of the speakers and panels – from artists to agents and industry leaders. The expo was a new addition this year and was great to chat with companies developing new technology either specifically targeted at EDM or music and festivals in general. I’ve also since joined the newly formed Association for Electronic Music (AFEM) and looking forward to contributing wherever I can.

Last but not least attending the conference got you VIP access to events at Hakkasan, Surrender, XS and the Cosmopolitan pool with artists like Avicii, Dash Berlin, The Crystal Method and Dada Life. Though some nights I felt like I wanted to sleep from a busy day at the conference, I met even more conference attendees and enjoyed some excellent venues and music. And the conference was smart to start the next days events later (on the last day it didn’t start until 11:30am).

If you love EDM and want to see how it’s run, and enjoy some great events, definitely check out EDMBiz in 2015.

How to Protect Yourself When Having Custom Software Developed

I was recently brought in to assess a site that was developed.  Though it was supposed to have been custom written to fit the needs of the business, it turns out the local company simply purchased a pre-written (originally from 2004) piece of software but tried to pass it off as custom developed by changing the copyright.  Legal action likely pending.

Custom software rather than very old, off-the-shelf software can still suffer from poorly architected and difficult to maintain code, and regardless of how well architected the code might be it still needs to be maintained over time.  Even if you’re non-technical there are still steps you can and should take to mitigate the risk as much as possible and to maintain full control over the work you’re paying for.

Ensure They Can’t Subcontract The Work

Make sure the contract has a clause where the work cannot be subcontracted without your authorization.  You’re hiring that developer or firm not someone else of their choosing, yet still paying their rates.

References

These are difficult to verify, as you pretty much need to know them or they have a decent public presence to have earned trust through a referral.  But it doesn’t mean you shouldn’t try.

Ensure the Software Is Custom or Built on a Framework With an Appropriate License

There should be a clause that it’s custom in your contract, or based on an open source project with an appropriate license.  Software like WordPress is licensed under GPL, which means there’s technically no restrictions on sharing the code that’s developed on top of it.  If you have sensitive business processes you don’t want to expose, you’ll want to make sure you trust the developer or have another framework chosen.

Agile or Weekly Billing Instead of Fixed-Cost With a Large Deposit

Using a developer who offers weekly billing means you get to control how things are going and if you’re not happy with the direction, you can stop at any time.  Major components can and will take more than a week, but this is still much better than a large fixed-cost project where you’re locked in after giving a 50% deposit and cannot change the direction when you learn more about the needs of your business.

Weekly Meetings

Even if you’re not working with a developer that offers agile development or weekly billing, weekly meetings ensure you can review progress, verify priorities, and answer any questions they have.

3rd Party Audit

Bring in a 3rd party developer like myself who can audit the code at various stages of development, and even interview or work with your developer about their current and future plans to architect the system.  Tell the developer you’ll be doing this and if they have a problem with it, this may be a sign that they don’t want you finding something they’re trying to hide.

Ensure You Have Backups That the Developer Can’t Access

If you are paying for the software, you should have full control of hosting and backups.  In addition, some backups need to be set up that the developer can’t access in case of a dispute.  Keep incremental backups over a period of time of code and your data.

Though the hosting may not set something like this up for you as part of the package, they should be able to guide you through.  Before you sign up for hosting ask the hosting company if having separate backups is a possibility.  If not, you should find another hosting company, at least during development.  You may need to spring for more expensive but fully managed solutions where you can get the support you need by phone or email.

Paying Too Little

If you think you’ll get Etsy or Youtube custom created for the equivalent of a week’s worth of work, you’re mistaken.  If you’re getting the software developed on the cheap as an MVP with the realization you’ll likely need to throw it away later after you’ve proved there’s demand for your idea, this might work.  Otherwise you’re fooling yourself.

Ultimately you’re responsible for the outcome but I hope these tips can help prevent you from paying a lot of money for software that no one but the original developers will maintain.  If you have any questions feel free to leave a comment or get in touch, and I’ll be adding more detail on some of the points above in future posts.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

HackerNest Construct Hackathon 2014

The HackerNest Construct Hackathon took place a couple weeks back, and myself, Garth Gutenberg, Connie Leung and Tom Pepper competed as Team ISIS.  The whole event was super well organized, and we got a chance to play with the soon to be released Kiwi Move.

Our idea was to create a cookie aid app where with the Kiwi Move strapped to your arm would guide you through a recipe and alert you if you were doing things wrong.  After some technical hiccups we were able to get the data flowing from the device, and started training it to recognize when I was whisking, chopping, sifting, and even kneading, to eventually end up with some delicious Challah bread.

Screen Shot 2014-03-15 at 8.57.35 AM

The app detected how many of each motion was done and, if you stopped doing the motion, provided some gentle words of encouragement.

I like puns.
I like puns.

You also didn’t have to click the Next button to advance – since your hands might be messy whilst cooking, once you had done the motions for that step you simply shake your hand slightly to continue.

The user interface turned out amazing with the use of a jQuery knob and Zerb foundation as a base and Connie and Tom’s design skills.  The demo worked perfectly (live demos always work perfectly, right?) and nicely showed the difference between chopping and sifting.

Though our commit messages aren’t as amusing as Cat Burton’s and co’s Children’s Ward game created during a Game Jam hackathon, the code for our project can be found on Github.

All and all a great experience and was awesome to hack on a technology we normally wouldn’t have the chance to.  A big thank you to the Ryerson Digital Media Zone for hosting and all the work of the volunteers!  Check out the rest of the submissions from the event.