Our products

We are passionate about building niche multi-platform products that provide real utility to our customers.

Anfield
Keep up to date with Liverpool FC news from across the web.
Domain Bites
Domain name industry news and resources.
Pub Reviews
Find the best pubs near you. Share your thoughts and photos.
Mmmm
Capture your taste and share it with the world.

Blog

We like to blog about software. Our stack, engineering problems, open source developments.. you will find it all discussed here.

Implementing the Paypal PHP SDK

I was recently asked to implement a subscription offering for a client on their web application.

I was initially apprehensive based on the naive assumption that taking payments had to be complicated.

Given that the client offers a single product at a single price and that the subscription is 'digitally delivered', I was essentially looking for a way of implementing a payment process that could be completed in a few clicks.

I am aware of products such as Square and Stripe, and I believe that they have APIs which one can utilise. Given the specification however I felt that these offerings would be overkill (disclosure - I did not actually investigate).

During my time at Uniregistry I had also had the experience of working with more traditional payment processors. Again, I did not want to implement a full checkout process. I was aware that their application processes were complex and that they had significant minimum transaction volumes, and (if my memory serves me correctly) the APIs offered were somewhat complex.

As such I went back to the original payment behemoth - Paypal, and began to investigate their API.

I thought that Paypal's API would be extremely complex and that they would have an arduous application process. Whilst their API might be complex, they provide an extremely well documented PHP SDK as well as detailed example source code.

Implementing the above mentioned specification took a matter of hours. It was simply a case of:

  • Installing the SDK with composer.
  • Creating an application within the developers console.
  • Reading the sample source code.
  • Implementing and adapting the 'PayPal Payments - similar to Express Checkout in Classic APIs' example.
  • Testing the implementation in the Paypal sandbox.
  • Changing a configuration parameter to 'live'.

The one (and only) complexity that I encountered was that when a prospective buyer was checking out, the payment screen would display 'Double Negative Solutions' in the header.

Whilst strictly correct, I wanted to display the clients product name to make it clear to the buyer that everything was in order, and that they were in the correct place.

After a little investigation I discerned that this could be achieved by creating a 'Web experience profile', as demonstrated here. You can also create the profile by executing a CURL request directly to the appropriate endpoint.

This little extension in my requirements allowed further investigation into their offerings..

My personal interactions with Paypal have sometimes been complex - recurring payments, multiple currencies, partial refunds etc. This is why I had assumed that integrating with their API would be tough.
In reality they have created a simple, modular, and well documented API which allows you to utilise as much or as little as you need. Were my client to want to implement more complex payment functionality it would be a step-wise process - implementing things as/when they are needed.

No huge time investment is required to learn and work with the Paypal API, and that makes it great for time constrained developers (all developers).

A brief investigation indicates that PayPal offer Java, PHP, Node, Python, Ruby, and .NET SDKs as well as mobile SDKs for both iOS and Android. Assuming that they are as well written (and documented) as the PHP SDK then implementing Paypal payments on any platform should be an absolute doddle.

Good job Paypal !

Sublime Text 3 Cheat Sheet

One of my favourite pieces of software is Sublime Text 3. It is my text editor of choice, and is well worth the cost given the number of hours I use it each and every day.

I utilise Sublime in a rather simplistic way. It looks fantastic, and its syntax highlighting functionality allows me to follow my code with ease. It also offers a number of customisable shortcuts and keyboard commands to allow you to navigate through my code in an efficient manner. These include:

  • CMD + R which allows you to navigate to a specific function.

  • CMD + P which allows you to navigate to a specific file.

Recently I have been working extensively with JSX. I noticed that my .jsx files did not have any syntax highlighting.

Fortunately Sublime offers 'Package Control' which allows you to easily and quickly install plugins developed by third party developers.

I quickly found the Babel package and installed it within seconds.

Whilst I now had syntax highlighting for .jsx the colors were a little garish. Installing new color schemes is just as easy as installing new packages. Another developer has created a package called ColorSublime which allows you to choose, preview, and install new color schemes instantly.

Other useful tricks

Whilst I was at it I figured I'd investigate (and collate) any other useful tricks I could find for Sublime so as to make my workflow more efficient.

These are listed below.

  • Option + ⌘ + 2 displays two panes side by side.

  • Shift + Option + ⌘ + 2 displays two panes one above the other.

  • ⌘ + Control + Shift + F goes into 'Distraction Free Mode'. This essentially makes Sublime fill the screen, and removes any unnecessary panes etc.

  • Cmd + / comments the selected code.

  • Cmd + Shift + J selects all adjacent lines with the same level of indentation.

  • Cmd + Shift + V pastes the copied code at the level of indentation where your cursor is.

  • Cmd + Ctrl + G selects all instances of whatever you have selected.

  • If you select a CSS properties list and hit F5 it will sort them alphabetically.

  • Ctrl + M takes you to the opening/closing tag counterpart of that positioned where the cursor is.

My packages

To finish off this brief 'cheat sheet' I figured I'd also outline the 'Packages' that I have installed and utilise.

  • Babel (as mentioned above).

  • ColorSublime (as mentioned above).

  • PHPUnit. Yes, there is a plugin for running your unit tests directly from Sublime !

  • Sublime PHP Coverage. Yes, there is a plugin for showing your test coverage inline within Sublime !

  • Sidebar enhancements. Provides additional useful functionality when you right click within the sidebar. For example I regularly use 'Open in Finder'.

  • Emmet. This makes writing your code quicker by proxy of a number of shortcuts (which you have to learn). I have only recently installed this, and need to investigate further.

Conclusion

I have used Sublime Text daily for over three years. It is awesome.

I thought that before I realised the full extent of what it can do. That says a lot about how good it is.

Hopefully this basic overview of useful functionality will make you more efficient when writing code in Sublime (which at this point you should have definitely bought.. :P)

If you have any questions, or know of any other 'must know' shortcuts, please do let me know.

Work less. Work better.

It is understandable that one might view any post advocating working less as an attempted justification for laziness. Within 'software' however I personally feel that it is imperative that one takes a step back and looks at their time investments more pragmatically.

This is a viewpoint shared by Itamar Turner-Trauring, who shares his viewpoint extremely succinctly over at Code Without Rules.

Uniregistry

Rolling back the clock, I was thinking back to my time at Uniregistry and trying to put a finger on exactly what made me leave. The answer was obvious. I was overworked, and it was my own fault.

When I was initially offered the job, it was on a trial basis. Given that I wanted the job, I worked extremely hard to show off my skill set and prove that I was up to the task. It turns out that I was. I got the job, and during my time with the company I was rewarded appropriately.

The problem was that by working 12 hour days, and by working weekends I was joining an inappropriate culture of excessively hard work. Not because hard work is bad, but rather because long hours are mentally and physically exhausting whilst not necessarily being particularly productive.

Yes, the euphoria of resolving an issue that you have been struggling with for hours is fantastic. On the flip side, the stress associated with being unable to resolve such an issue is unbearable. Independent of euphoria, or stress this approach is still inefficient. It is almost always the case that these incredibly tough problems are extremely simple and would be resolved in a matter of minutes after a good nights rest.

Frank Schilling (the CEO of Uniregistry) is an extremely intelligent, and targeted man. He has fantastic ideas, has built a fantastic team, and has created amazing products. I remember heated discussions pertaining to timelines and execution whereby he would be unhappy with how long we had proposed a particular piece of functionality would take to produce. To try and be as appeasing as possible we would provide realistic timelines premised on working long hours. In hindsight this is why I ended up burnt out, generally fatigued, and in the end left my position.

This case was particularly interesting because it was more psychological than anything. For me personally, I never wanted to be the first to leave the office. I didn't want to be perceived by my co-workers as being lazy when in fact leaving 'early' may have simply been realistic. I suspect that my coworkers may have felt similarly.

This certainly isn't a unique situation. I am aware of a number of people working for companies where similar working cultures develop. It is ridiculous - it is tantamount to self harm.

Double Negative

Fast forward to today. I am my own boss, so I can dictate my own working hours. This (unsurprisingly) means that I am able to justify taking time off as needed, and develop working habits that are appropriate to optimal performance.

Having built three significant multi platform products, and numerous other smaller projects it is certainly fair to say that I have been productive. I am however still prone to being generally over optimistic, and to overworking.

Software and programming requires mental capacity. It requires intelligence, and concentration. As such whilst there are some jobs whereby one can work on autopilot for ridiculous amounts of time, I do not believe that software is one of them. Itamar states that in his current position he has negotiated a 35 hour working week. I can absolutely see an argument for working even less than this.

When programming there are two things that have become patently apparent to me. Firstly my efficiency and productivity are obviously improved before lunch. Secondly, at the end of the day I have significantly more occurrences of the infamous 'why on earth won't this insert simple thing work !'.

As stated by Dan Abramov:

"If you’re debugging a problem late in the evening, drop it and sleep on it. Sleep deprivation makes it far too easy to miss typos and other simple mistakes."

I would extend this. As well as sleep deprivation causing you to miss typos, having been staring at a screen for the 10 previous hours has the same effect. As it happens, Itamar has dedicated a whole post to this: Go Home Already.

Going forward, it is clear to me that I need to get my programming done in the mornings, and be prepared to take breaks/leave it until the morning. It is a simple case of learning from experience.

Were I to still work for Uniregistry (or any other software company for that matter), I would be intrigued as to how the conversation would go down were I to propose only working mornings. On the face of things it looks like pure laziness, but taking a step back it is simply honest, and pragmatic.
As a company owner myself (now), I would certainly prefer for my employees to be realistic and up front with me. I am 100% certain that as long as you have good employees who you can trust to manage themselves appropriately then productivity will increase.

At the end of the day it comes down to two words: Realistic expectations.

What others say..

Having written this post, I wanted to investigate further what others have to say on this topic/'idea'. It turns out.. quite a lot.

This post from back in 2012 outlines the history of the 40 hour work week.

One quotation which resonated with me was the following:

"That output does not rise or fall in direct proportion to the number of hours worked is a lesson that seemingly has to be relearned each generation."

To me, it is not so much that each generation needs to 'relearn' this. As in my case, I am well aware of my reduced performance but for idealogical reasons choose to overwork. We need to listen to our bodies.

The previously mentioned post as well as this article from the Guardian pertain to working in general, not just the software industry. The latter refers to doctors who I agree should absolutely not be overworking - they are potentially responsible for peoples lives !

Whilst not (normally) effecting human life, the software that we build is oftentimes widely used and wide reaching. There are software tools used by millions of users daily/hourly which are responsible for extremely important systems, and account for millions of dollars of economic output.

It turns out that the 'literature' on the topic matches up with my own thought processes, whilst also referencing research which proves my sentiments.

The wise boss would let his workers manage themselves (within reason) to optimise output and efficiency.

I hope my boss does.

Automatically updating your self hosted Ghost install

Ghost version 0.9.0 has just been released, introducing awesome new functionality such as scheduled posting (which I am utilisng to post this :)). This is fantastic news, but I run three different self hosted ghost blogs and I only just updated to 0.8.1.

Whilst updating Ghost isn't exactly that difficult, it still takes time. Time which I sadly do not have. As an engineer it struck me as being somewhat ridiculous that I hadn't already written some sort of script to manage the upgrading of these various blogs. In fact, I am even more bemused that someone else hasn't done it either (seemingly).

The title is not strictly correct in that this is not actually automatic. It still requires you to execute the script, and to update multiple blogs you will need to modify it to take arguments. That said, it is a start. Something to get you thinking.

Pub Reviews and Mmmm have complex build scripts which checkout the latest versions of the source code, build the applications, run the test suites etc. Obviously nothing that complex is needed here, but given my experience with ssh, rsync and shell scripts more generally, I pieced together a simple script to update a Ghost blog on an external server from my Mac Book.

The code is embedded below:

Using it

There are a few considerations to note to correctly utilise this script.

  • It is based on the official Ghost upgrade document. Ghost could fundamentally change in the future (although it is unlikely) meaning that different files need to be updated.

  • To use the script you need to download the version of Ghost that you want to update to, and place it in a directory which you specify as the STAGEDIR variable.

  • This is a bare bones script. It has no saferty checks, and doesn't perform backups of your blog content. Make sure that you enter you enter your host/user details correctly, and be sure to backup your data prior to utilising this script.

  • My blogs are run utilising forever such that they don't go offline when I close my terminal.

  • I remove the node_modules directory completely, clean the npm cache, and do a fresh install of the various dependencies because I was encountering a number of dependency based issues when I did not do so.

  • You need to set up passwordless (key based) authentication for SSH connections to your external server. You don't need to do this - you can modify the code as you see fit, but in the interest of making it as quick and painless as possible it is something to consider. This answer on StackOverflow outlines how one can do this.

Thats it

Hopefully this is of use to you, and saves you a few vital moments every once in a while. If you have any questions, comments, or suggestions, let me know below.