Blog
-
Steps to Better Code
I was recently reading an old article by Joel Spolsky where he outlines what he's coined as the Spolsky Test; a twelve-step test that helps gauge the kind of quality you can expect from your development team. Even though it's 15 years old now, the majority of it still holds true and makes a lot of sense but, as with anything digital, there are a few things that could be updated a little, and some…
-
Installing Node.js on Linux
If you're running Linux, and are in any way interested in using Node.js, then your first port of call would by the package manager used by your distro (apt on Debian and Ubuntu, or Yum on Fedora/RedHat.) The problem is, even if you're running a completely bleeding-edge distro, your Node version will probably be quite out of date. So what are your options? A bit of research gave me several options: Using…
-
CodeSniffer – The PHP Coding Standards Tool
A couple of years ago I implemented a coding standards guide for PHP development at TMW, as I'd noticed that they only had a document that was focused on .Net and Windows. The guide outlined mostly common sense practices, such as avoiding certain unsafe language functions, and how to best indent and document your code. Just over a year ago I made this document public on the TMW GitHub account, and…
-
Labour of Love: Building a Framework
At the start of this year (2015) I embarked upon a small personal challenge which I'd set myself: could I build a PHP MVC framework in a week? I had a fairly quiet schedule at the time, and I believed it was possible, so I began. Now, I have had quite a few years experience using various frameworks, so I had a rough idea about how I wanted to go about structuring my own: Basic request router…
-
Accessible Cross Reference Tables
This article was originally posted on the TMW Tech Blog on the 30th of Jan 2015 but I've amended the prose slightly here I've recently rebuilt this website, mainly in order to move it off of the old CodeIgniter framework to Laravel, and take advantage of the modern features of PHP. The rebuild has given me a great opportunity to go through a lot of the content on the site and re-write it, and one…
-
Getting Discrete Values from a Potentiometer
If you've ever worked with potentiometers in your Arduino sketches, then you might have tried to use them to get discrete values, and if you had, you will have noticed that when the potentiometer is right on the cusp between two of your set value areas that the input appears to fluctuate wildly because it can't settle on one value, and there's a little noise on the line. This problem is compounded…
-
Writing a Better Profanity Filter in PHP
When you accept user-generated content on your website, you will, at one point of another, see content that you really wish you hadn't. This could be Joe Bloggs cursing at your article, or John Smith throwing out every insult imaginable in an attempt to goad you or your websites visitors. Usually in these situations you have a couple of options, full moderation or content filtering. It's the latter…
-
Communicating Between PHP and an Arduino with Sockets
This article was originally posted on the TMW Tech Blog on the 29th of Jan 2015 but I've amended the prose slightly here Initially, I put this together as a way to quickly demonstrate to colleagues the socket capabilities of PHP, as it's a common misconception to believe it's not good at real time communications, and that it can only follow a request-response model. I decided that this would also…
-
Using XML as a source document for other formats
At TMW I produced a PHP coding standards document, as there were only such documents available for .Net and the front-end coding technologies. Initially, this was only available on the internal wiki, but there was a need to then add it to the TMW Tech Blog, which used Markdown format. Not wanting to maintain two sets of documentation, and noticing a possible need for other formats in the future, I…
-
Using brace expansion to create nested directory structures
When setting up a new project it's often required to set up the same old directory structures. You could do this manually, but where's the fun in that? You can do this much more quickly in the terminal with brace expansion. Consider the following directory structure: project_dir www img js css logs This entire directory structure can…