Random thoughts & observations

From the mundane to the profound and everything in between here’s what’s rocking our world

Storing and retrieving objects with LocalStorage

Posted: Wednesday 21st October, 2015 - 10:20pm
Author: James Griffiths

The HTML5 Web Storage API provides developers with greater latitude for front-end storage compared to that of cookies, particularly with the localStorage property, making this an excellent choice for managing data within web and mobile applications.

Aside from browser support one issue with using this API is that data saved within localStorage can be of only 2 types: strings or integers.

So where does this leave us with other data types such as Objects and Arrays?


Generating JSON objects dynamically in JavaScript

Posted: Saturday 26th September, 2015 - 10:09pm
Author: James Griffiths

Working with JSON provides front-end developers with many advantages over other data formats, least of which is the fact that it's a subset of the JavaScript language itself.

In this short tutorial we'll take you through dynamically generating a JSON object within JavaScript...


Converting between dates and timestamps in PHP

Posted: Wednesday 23rd September, 2015 - 10:05pm
Author: James Griffiths

There may be occasion, when working in PHP, that you need to convert date related values between date type formats and timestamps.

PHP makes that incredibly easy to accomplish.


Solving JSON encode error Invalid UTF-8 sequence in argument in PHP

Posted: Sunday 20th September, 2015 - 10:02pm
Author: James Griffiths

We've recently been working on some PHP coding to generate JSON output drawn from a variety of MySQL database tables and hit the following error: json_encode(): Invalid UTF-8 sequence in argument.

Solving this was, thankfully, relatively quick and easy...


Understanding the JavaScript revealing module pattern

Posted: Saturday 12th September, 2015 - 9:59pm
Author: James Griffiths

As our JavaScript applications start to become more complex and demanding it makes sense to turn towards using specific design patterns as a way of managing those needs. In this particular article we're going to take a look at one particular design pattern: the revealing module.


JavaScript namespacing and modules

Posted: Saturday 12th September, 2015 - 9:52pm
Author: James Griffiths

As JavaScript has, at the current time of writing, no native support for namespaces we, as developers, have to implement our own approaches/solutions to avoid polluting the global namespace with objects/methods and variables that might conflict with/overwrite one another if we are not careful.

In this article we take you through using namespaces and modules to better manage your code.


Measuring Javascript performance and debugging with browser inspector tools

Posted: Friday 4th September, 2015 - 10:11am
Author: James Griffiths

As JavaScript has become a central pillar of front-end web development, thanks to modern browser support, the tools we need to measure how our scripts are performing have become increasingly important.

In this article we're going to take a look at some of these tools that are available directly within the Google Chrome browser...


Useful PHP Composer functions

Posted: Sunday 30th August, 2015 - 9:43pm
Author: James Griffiths

Thanks, in recent years, to the introduction of Composer managing package dependencies for PHP has become much easier, quicker and far less stressful. The following are some Composer essentials that all PHP developers should be familiar with...


Resolving CORS issues with Ajax requests

Posted: Sunday 26th July, 2015 - 6:41pm
Author: James Griffiths

Ajax makes life as a web developer a lot easier, particularly when used with a framework such as jQuery but, like all development related technologies, there will always be gotchas that can catch you unawares.

One of those is CORS...


Resolving AngularJS executing controller twice issue

Posted: Sunday 28th June, 2015 - 6:35pm
Author: James Griffiths

If you've been developing with AngularJS for some time then you may have unwittingly come across the following issue: your controller is executed twice.

Seems like one of those coding problems that shouldn't exist but fixing this is, thankfully, quite simple...


Increasing MongoDB soft rlimits on Mac OS X

Posted: Monday 18th May, 2015 - 6:30pm
Author: James Griffiths

If you've installed MongoDB on Mac OS X (and this will more than likely be applicable to similar UNIX based systems such as Linux) you may be greeted with the following warning when running the mongo daemon process in your Terminal application:

** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

Looks a little cryptic doesn't it? Let's take a look at what this means and how to fix it...


Resolving MongoDB lock error

Posted: Sunday 17th May, 2015 - 6:26pm
Author: James Griffiths

If you've been exploring the MEAN Stack (MongoDB, ExpressJS, AngularJS and Node.....for those not in the know!) you may have encountered the following problem when attempting to start MongoDB from the command line:

old lock file: /data/db/mongod.lock.  probably means unclean shutdown,
but there are no journal files to recover.
this is likely human error or filesystem corruption.
please make sure that your journal directory is mounted.

Resolving this issue is relatively straightforward...


CSS zebra striping table rows

Posted: Saturday 9th May, 2015 - 6:22pm
Author: James Griffiths

One of the great things about modern browser support for web standards is the amount of really cool things that become so much simpler to do than before.

Case in point: alternating the striping of table rows, lists etc - also known as zebra striping.

With CSS this now becomes almost trivial.

If you're using a pre-processor such as Sass (and if you're not you really should think about investing the time to implement this tool into your development process as it will completely change how you write your CSS....for the better) you can accomplish row striping with the following snippet:

Page 3 of 9