First month at Kobas

So I’ve been working for roughly a month at Kobas now, I think things have been going very well and I wanted to highlight what I’ve been working on for the last couple of weeks.

For anyone that doesn’t know what Kobas does, it is a hospitality management solution covering; stock control, rotas, HR, EPoS, customer loyalty and much more. It’s actually a very useful piece of software for clients, allowing them to gather lots of data from all areas of their business and providing a cloud interface that outputs that data in fancy reports. After seeing it in action I find it very surprising that not all businesses use this as it can really help you to increase your profits and avoid wasting money unnecessarily.


Anyway, on to what I’ve been doing, I’ve been mainly working on the EPoS (Electronic Point of Sale) side of things, which in layman’s terms are the Kobas tills.

To side-track just a little I think the Kobas tills are so nice to look at and use, here is an example screen from one:

kobas-till

When you take that in comparison to a result from searching EPoS on Google Images (and what most places use):

chip-shop-epos-system

Bit of a difference there right. So unfortunately now I have been burdened with the curse of noticing every single EPoS system every place I go and thinking to myself, “how do they use this shit?”.


Anyway back to what I’m doing, basically I’ve been working on adding the functionality to accept deposits and other payment types to the EPoS. The EPoS accepted cash, card and voucher when I arrived, which was all you would really need basically.

But now with Christmas getting closer venues are going to be taking deposits for bookings and we wanted to be able to handle that within the EPoS itself.

Also with the rise of services like ‘Just Eat’ etc, venues are trying to figure out how to process payments from those services, as it’s not really a cash payment as you don’t have the money in your till and it’s not really a card payments as you haven’t put it through your card machine.

So with that in mind we also decided to create “Other payment types” which allow businesses to just tell us what other payments they want to accept and we are able to quickly add that functionality to the till and have it display in all relevant reports.

Our product manager Daisy Lang has wrote about it in much more detail over here.


Adding the ability to accept deposits and other payment types went well but I did encounter a few difficulties while doing it, for a starter constantly worrying about breaking the tax calculations (and having forgot how UK tax works).

Luckily I found a very edge case unit test wrote by Neil Mukerji (our CTO) and after converting it over to use the new version of the payment objects I was delighted to see it was still passing as expected.

Naturally I then decided to write a bunch more unit & functional tests, I’ve been on the Codeception train lately, after getting introduced to it at the end of my role at UBC and I’m determined to get it set up properly in Kobas so that moving forward refactoring and changing code is much easier ( /less stressful 😛 ). I’m hoping to get all our tests into Codeception shortly and add them into to the Jenkins build for automatic testing on deployment.

Also shockingly (due to not having it in my other roles) there is a whole QA team at Kobas, which has been a total life-saver for me. Actually having someone QA features you’ve added is unbelievably helpful as when you’ve been working on something for so long it’s easy to miss things.

Anyway that’s all I have to talk about for now, I know what I’m doing in the coming months but I’m not going to mention that here, but stay tuned, interesting stuff is coming! 🙂

An honest review of the Surface Pro 3

I bought a Surface Pro 3 in November 2014, I haven’t wrote anything at all about my thoughts on it since purchasing it, I figured it was better to wait until I had actually been using it for a significant amount of time and give it an honest review. A year and a half I figure to be more than enough time. 😛

So this post is going to be structured in the following way, condensed Pro/Cons. for you speed readers and then just my personal thoughts on things I’ve come across while using the device.

Pros

  • Amazingly portable, very light and much easier to use on your lap than a traditional laptop.
  • Can run pretty much all software, Photoshop, Jetbrains products, Office etc all work well.
  • Can run certain games, Hearthstone works great, older games like Warcraft aren’t an issue. Processor heavy games like Starcraft II will work but become extremely laggy when lots of units are out.
  • Touchscreen is very satisfying to use for browsing the web etc.

Cons

  • WiFi is a complete joke. Sometimes after resuming from sleep you won’t have WiFi anymore. I’ve had the WiFi just completely disappear on me and ended up having to wipe & restore the entire device.
  • Overheating is a serious issue, even when running just a browser the surface can become incredibly hot, some people are combating this by having an external fan pointed at the device.
  • The chargers connection to the Surface is pretty much the worst design ever. Unless you constantly make sure it’s not bending in any way whatsoever prepare to replace your charger every 6 months. The chargers are not cheap either!
  • You constantly need to change the scaling of the resolution depending on what you’re running. Coding in an IDE scale up, games scale down. Changing scaling requires logging out and back into Windows, kind of awkward but could be worse.

Well that’s the basic pro and cons down, now lets get into why I actually bought the Surface and my personal feelings on it.

I bought the Surface because I needed a semi-powerful laptop that I could bring back and forth to work, having never owned a tablet the idea of the Surface appealed to me, being both a laptop and a tablet. I wasn’t looking for a gaming laptop, but a laptop that could at least play some games. Mainly I needed a laptop that would allow me to do programming, wherever and whenever.

Success wise, portability worked out as expected. But I will say you really have to consider when buying the Surface for that reason how often are you going to be using it in that fashion.  When I actually use the device on a table, I always get the feeling that I would be better of using an actual laptop. I do however find the tablet aspects of it nice, just being able to disconnect the keyboard and have a powerful tablet for browsing the internet or playing touchscreen games is very nice.

Failure wise, I have no idea what the WiFi’s problem is half the time, it’s extremely frustrating to have to deal with it disappearing completely. I’ve tried a bunch of solutions on Google and there really isn’t any set answer to it, sometimes simple fixes will work, other times you have to wipe and restore the Surface completely. It’s without a doubt the biggest downfall of this device. The power cable is also a real nuisance to deal with as mentioned above. Another point is like every other device the battery gets worse over time and since there is no way of replacing the battery in the Surface your only solution is to buy another one. 🙁

So overall I would rate the Surface 30/42. I’m not entirely satisfied with it and I certainly will not be buying another one. I think it would be more suited to journalists or perhaps artists who would make more use of the pen.

If I could time travel and talk to myself before I bought it I would be telling myself to either buy a Lenovo or a MacBook instead.

Goodbye Vancouver, Hello London

img_20150623_130149.jpgSo I have left beautiful British Columbia and I’m back in Europe, in London of all places. I’ve gone full circle it seems! 😛

I’m not going to bother going into the details of why I left Vancouver, but in short, you can’t extend a “two year working holiday” visa. Which totally sucks as after two years I had really set myself up over there.

So after many many goodbyes and cramming in as much touristy things as possible in the last couple of weeks I set sail back to London. Getting the cheapest possible flight which had two stopovers; Toronto (11 hours), Saint Johns (2 hours).

E20160519_094857.jpgleven hours didn’t seem so bad to me when I was looking at the ticket however after my flight from Vancouver -> Toronto staying in the airport for anything over an hour did not seem appealing. So I got the train from the airport into the city. Unfortunately I hadn’t gotten any sleep during my flight at all so I was pretty exhausted and not so much in the mood to really explore Toronto. I spent about three hours just wandering about picking different places to sit down and rest, eventually giving up and going back to the airport to try sleep (no luck with that).

Saint Johns was uneventful, pretty much just had enough time to go and grab a cigarette outside and then re-do security before my flight. The flight from Saint Johns -> London seemed to take forever, again I got no sleep. I think I’m going to start drugging myself before long-haul flights in future, although I think that might make the stop-overs a bit more difficult 😛

But anyway, now I’m in London. Exchanging my money from CAD to GBP was very depressing, outside of that though re-exploring London has been a lot of fun!

snapchat-6610402657155137563.jpgI’ve got a double room in a flat for now, getting my own place initially just seemed like a terrible idea money wise. It’s nothing special but it will do for now.

This week is going to be the CV and interview game, I have a couple of interviews lined up already and I’m going to apply to a bunch more jobs. I’m really not looking forward to going through the technical interview process all over again, it’s exhausting and very demoralizing at times. But it just unfortunately has to be done.

So if anyone reading this is in London and hiring do reach out to me, I can’t imagine it will take too long to find a job here however as there are many opportunities.

So that’s the personal update for now, there will likely be some more technical posts incoming in the near future.

Free SSL Certificates with LetsEncrypt and Ajenti-v

So this is going to be a very quick post on how to use LetsEncrypt SSL certificates on your Ajenti-v setup. Ajenti-v will probably be supporting this natively at some point, there is an open issue on their Github here. But in the meantime you can just follow these steps to start using LetsEncrypt now.

Step 1. Install LetsEncrypt.

You can click this link and head to ‘Getting Started’  or you can just run these commands to install LetsEncrypt in the folder of your choice:

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt

So now LetsEncrypt is installed, LetsEncrypt doesn’t yet support nGinx and since that’s what I’m using I’ll assume that’s what you’re using, the automatic function won’t work for us so we will have to use the ‘certonly’ option. Run the following command and follow the steps.

service nginx stop
./letsencrypt-auto certonly 

Now you should get a message like:

Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/yourdomain.com/fullchain.pem.

You can now restart nginx by running:

service nginx start

Now that we have the cert, it’s time to see how we fit this into Ajenti. Open up the websites tab of Ajenti and open whatever website you’ve decided to do this for, hit the SSL tab and you will get this window:

ajenti-certs

So the first box get’s filled in with what the wizard returned to us:

/etc/letsencrypt/live/yourdomain.com/fullchain.pem

The second box gets filled in with the certificates private key:

/etc/letsencrypt/live/yourdomain.com/privkey.pem

Now Ajenti knows what certificate to use it’s time to turn SSL on, lets get the Advanced configuration out of the way first:

ajenti-advanced-cert

 

The ‘Custom top level configuration’ you see will automatically redirect users accessing your website on http:// to the https:// domain.

Lastly we just need to change the website port from the default 80 to SSL’s 443:

ajenti-ssl-ports

Apply changes, and check to make sure your website is still redirecting. Easy peasy! 🙂

Easy Caching with StashPHP

So short post this time, I swear I’m not dead, just busy!

Frequently with PHP you are going to need to cache things, mostly expensive SQL queries, but also data you aren’t going to want to be inserting into the database on every page hit, for instance website statistics.

With PHP we have a few options to achieve this;

  1. Caching with the file system.
    •  Upsides:
      • Works well with the Opcode cache
      • Usually the fastest method of caching for small or medium websites
    • Downsides:
      • Clearing the cache can be a lot slower as you will have to recursively search through path’s and delete.
  2. Caching with SqlLite
    1. Upsides:
      • Can be substantially faster than a full-blown RDBMS
      • All data is stored in a normal file in the host’s file system.
    2. Downsides:
      • Can only support one writer at a time, which can cause high file system latency, which is inconvenient if there are many clients trying to access it simultaneously.
  3. Caching with APC
    1. Upsides:
      • Makes PHP faster for you through the so called opcode caching.
      • No special configuration required.
    2. Downsides:
      • Practically none
  4. Caching with Memcached
    1. Upsides:
      • Allows machines to pool their memory together as one large memory cache, perfect for large websites.
      • Cross platform and cross RDBMS
    2. Downsides:
      • Stores data in the RAM, not ideal for small systems
      • Is considered to be a volatile in-memory key/value store
  5. Caching with Redis
    1. Upsides:
      1. Can act like memcached as a key/value store however it’s really a data structure server.
      2. Persistence to disk, by default.
      3. Values up to 512MB in size
      4. Built in clustering
      5. Extremely fast at everything
    2. Downsides:
      1. The more objects you put in it, the more memory its going to use.

So as you can see there are a bunch of different systems that handle caching in arguably better or worse ways depending on how big your website is. Putting a small website on Redis is probably overkill,  you might already have set up a RDBMS solution and now not want to change to a key value store etc.

This is where StashPHP comes in, you basically use the StashPHP library to cache things like so:

First you setup the driver to use, lets just use File System for the moment:

<?php
// Create Driver with default options
$driver = new Stash\Driver\FileSystem();
$driver->setOptions(array());

// Inject the driver into a new Pool object.
$pool = new Stash\Pool($driver);

Now you can setup your by wrapping the following code around your code:

<?php

// Get a cache item.
$item = $pool->getItem('path/to/item');

// Attempt to get the data
$data = $item->get();

// Check to see if the data was a miss.
if($item->isMiss())
{
    // Let other processes know that this one is rebuilding the data.
    $item->lock();

    // Run intensive code
    $data = codeThatTakesALongTime();

    // Store the expensive to generate data.
    $item->set($data);
}

// Continue as normal.
useDataForStuff($data);

Now rather than later on when you decide to add another cache, rather than needing to go rewrite all your caching calls etc. you can just change the setup of the drivers like so:

<?php
$subDrivers = array();
$subDrivers[] = new Stash\Driver\Apc();
$subDrivers[] = new Stash\Driver\FileSystem();
$subDrivers[] = new Stash\Driver\Memcached();

$options = array('drivers' => $subDrivers);
$driver = new Stash\Driver\Composite($options);

$pool = new Stash\Pool($driver);

Presto, we’ve just avoided a nightmare!

How I’m tracking time

So lately I’ve been trying to manage my time better, with countless personal projects and legacy applications to support I find not properly tracking what I’m doing to surprisingly be more of a waste of time than tracking my time, even when you take in the time lost by tracking said time.

Firstly, I already use Trello for organizing my tasks across bigger projects,  I’m pretty sure most people do, it’s one of the best task management tools for things that are just general planning rather than bugs. For managing bugs I’m using JIRA or Github Issues depending on if the project is open source or not. I’m generally trying to do as much open source as possible lately. For more general tasks I’m using Todoist, which I recommend checking out if you haven’t, it has a very clean and simple interface.

So with all that in mind I set out to find an application that could potentially work with all of the above as well as give me time tracking. Handily enough I found Toggl, which is completely free until you want to export invoices etc, which I don’t really have a need for right now.

Toggl just takes all the hassle out of time tracking, after installing it’s browser plugin Toggl integrates with most task tools. Github issues, JIRA, Trello, and Todoist just to name a few.

So not only do they make it really easy, but how they actually output your data is really handy also:

toggl

 

I recommend you all to give it a try and let me know how you find it..

Another one for any of you programmers is WakaTime:

Wakatime Screenshot

Wakatime allows you to install a plugin in your IDE of choice, pretty much all are supported, it basically reports on what programming languages your spending the most time using. Their graphs aren’t as pretty as Toggl’s but I still enjoy them! 🙂

 

The Perfect Web Server – Nginx, Ajenti, Ubuntu

 

ajenti-dashboard

I’ve done a lot of installing of web servers over the last while, some of which have been effortless, others a thorn in my side. I’ve decided to compile a guide for my latest server setup that I’ve fallen in love with;

First a breakdown of what we’ll be installing today;

Nginx: (pronounced Engine X) is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly,predictable amounts of memory under load.
Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from Nginx’s high-performance and small memory footprint. Nginx scales in all directions: from the smallest VPS all the way up to clusters of servers.

Ajenti: “The admin panel your servers deserve.” Easily extensible using Python. Plugin development is fast and pleasant with rich APIs. Includes lots of plugins for system and software configuration, monitoring and management.

Ajenti V: A plugin for Ajenti that makes website setup easy – including app servers, database, and routing.

Ubuntu: If you don’t know what Ubuntu is we’re in trouble.

Now I’m going to take a leap of faith and assume you can either install Ubuntu yourself or figure out how to get a server with it already. A DigitalOcean droplet works perfectly here. So lets log in as root and run all this:

You should now be able to log in to your Ajenti control panel at https://yourserver.com:8000 with:

username: root
password: admin

 

Now that’s done you’ll notice if you open /etc/nginx/nginx.conf that files inside /etc/nginx/conf.d/ are loaded before any other .conf files, this is where you should put any additional configuration for Nginx. However if you are just configuring a specific domain or website you should just put the configuration in the Ajenti  website configuration’s advanced section.

That’s all folks! 🙂

Being a PHP Developer in 2015

This is just some thoughts on being a PHP developer in 2015;

A standard web project before used to just require you to setup a local web server, and then you’d upload to a standard web host with some worries about PHP versions perhaps but little to no thought required for the server side of things.Frameworks were a new thing, CodeIgniter was (to me at the time) the best thing to happen to PHP,  introducing me to PHP MVC patterns, easily integrated vendor libraries (I never got into Zend Framework) and Twig.

Now a web project involves using programs such as Composer, Bower and Grunt just to manage project dependencies. Then you have PHP & JS frameworks like Symfony, Laravel,  AngularJS that have really made life so much easier for us developers. Of course this all comes at a cost of having to put in time into learning all these new frameworks and tools, but the benefits of doing so are just amazing; development time goes way down and you create much better products. I wish I could further go into the benefits of each but they all require posts of their own to really get across their individual uses, I’ll attempt to get to that!

Working with UNIX servers is pretty standard for most web developers now, myself included. I’ve been using DigitalOcean for all my hosting, they really are a great host and I recommend them to anyone searching. Anyway a tool I found lately for server management which I guess is what has caused this post is Ajenti, before this I was using ISPConfig for the aim of being able to manage my servers easier than via ssh, however I found it’s interface pretty clunky and just overall slow, always ending up in ssh. After testing Ajenti in a fresh droplet I changed completely over to it on my other servers, so far it’s been amazing, I’m still using ssh here and there but overall Ajenti has really solved my problem so thanks guys. The install was amazingly simple too I recommend anyone looking for a GUI for their server to check it out.

So there seems to be a lot more to PHP web development now in 2015 than there was just a few years ago, though I personally feel all of it is for the better, making my life easier. It makes me wonder what it will be like in another few years though, whats next? 😀

Apache Localhost Rendering Slowly?

Is your localhost taking longer than expected to load?

A possible quick fix is to edit your httpd.conf file and set ‘ServerName’ to 127.0.0.1:80 . This can make the difference between millisecond load times and crying while Apache tries to load.


# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
ServerName 127.0.0.1:80