Latest entries about CSS, JavaScript, PHP & all things web development!

How to test react js components using enzyme, mocha & Babel

July 30, 2016

React js components are well designed with testing in mind – it’s just a simple matter of leveraging the right testing tools for your needs. For this how to guide, we’re going to use an established BDD test suite: Mocha, chai, sinon, jsdom, and a library specifically targeted for react js – enzyme. Following true […]

Module parse failed error with webpack & babel-loader

I had a frustrating error recently when running webpack to compile my code using the webpack loader, babel-loader. My error in the console was similar to the following: Module parse failed: /directory/file.js Unexpected token (line number) You may need an appropriate loader to handle this file type There were many StackOverflow questions, but none quite […]

How to debug PHP with PHPStorm & MAMP

July 8, 2016

I struggled immensely one evening to find a tutorial out there that worked for me, on how to debug PHP applications running over MAMP, using the PHP Storm IDE. After absorbing bits and pieces from other guides, what really made it click for me, was reading the official xdebug documentation, where they provide a diagram […]

How to setup table schema with Laravel migration

May 8, 2016

A great feature of Laravel is the ability to create table schemas through their migration mechanism, which acts like version control for your database. It provides an audit trail, and an opportunity to use their rollback system should you ever need to. I found the whole process a little odd to begin with, so I […]

Get the rendered PHP blade template content – Laravel 5

April 27, 2016

There was a scenario I recently encountered, whereby it was especially useful to retrieve the rendered contents of the PHP blade template in Laravel 5, before simply returning it to the browser. I wanted access to the HTML view as a string, that I could further manipulate myself, before returning it to the browser. Let’s […]

Testing JavaScript w/ jsdom, mocha, chai & sinon

April 14, 2016

You’re going to learn how to test your plain JavaScript application, making use of some of the most popular and established JavaScript testing libraries there are right now (jsdom, mocha, chai & sinon). This is going to be a fairly lengthy article, so grab a drink and be prepared to get stuck in by grabbing […]

HTML5 doctype keyboard shortcut in WebStorm

April 12, 2016

When creating a new HTML document, more specifically, HTML5, there can be that sluggish feeling as you go to create the page: Getting the boilerplate/skeleton of the HTML structure out of the way. You’ll need something like this HTML before you can begin: This mundane task (although a nice memory test…) can be almost completely eliminated […]

Dynamically reference WordPress site URL in JavaScript

April 8, 2016

During my WordPress development, I often find myself in need of the WP home or blog URL from within the JavaScript code. You can easily enough hardcode this to something like (assuming the WP site is at the root directory): Or maybe your WP site is within a sub-folder, so you replace ‘/somePage’ with ‘/wpsite/somePage’. This […]

How to upgrade WordPress & plugins with SFTP & SSH2

July 5, 2015

This guide will show you how to configure WordPress updates through the WP admin panel via SFTP. This provides a secure way to upgrade the WordPress version, update & install plugins, all via the WP backend GUI. You will need: A user with SSH access to the server (I’ll be using Ubuntu 14.04) The above user to have […]

Conditionally assign value to variable in bash

June 26, 2015

My example: A bash script that accepts one argument. If the argument isn’t provided, then set a default value. This is the kind of conditional assignment I wanted to avoid: There’s nothing bad with this, I just felt it was a more verbose outcome than what I had in mind. I wanted something that more […]