Latest Posts

I’ve been wanting to move away from WordPress for this blog for some time now.  While these days I’ve spent most of my time programming in Python it makes sense to create a website blog in PHP.  Since whether you like it or not it is the dominant language for web hosting platforms.  This will provide flexibility where hosting is concerned.

As far as frameworks are concerned I decided upon Laravel.  Firstly an old friend of mine was singing its praises plus I didn’t want to do it in Zend, which is the framework I’m familiar with.  Zend in my opinion is too big a framework for a blog, it’s more suited to complex enterprise based applications.

Another reason for using Laravel is that I found what looks like a good tutorial.  The steps in these articles will be in part derived from the steps in the tutorial which I’m sure will digress at certain points.  The aim at the end of this project is to replace this blog with the site I build.

For this project I am using my MacBook Pro however these steps should work with little or no alteration on Linux.

Installing Laravel

composer global require "laravel/installer"

Setup paths

Edit ~/.bash_profile

add $HOME/.composer/vendor/bin into the path.Read More

Mocking Java

Oct 15,2017 at 12:57 pm By Ben Hutton

While you can argue for or against Mocking Java (or any other language) it can at times be an advantage.  For example a recent project I have been working on I wanted to test code within the paint() method in Java.  Now to the best of my knowledge you cannot externally run this method as it requires an argument to be passed in that cannot be met normally.

This is where Mocking comes into play.  Whether testing the Graphics library with Java or testing the logic of OS System calls it can be very useful.  It can however get overused largely due to code that is not designed with testing in mind.  At least that’s what I’ve found when trying the TDD approach on an existing non TDD code base.

The mocking library I have been using is Mockito.  You can build this yourself of just go the this link.  Once downloaded you can use it like so:

Configure Mockito in your IDE

For IntelliJ find your Project.iml file and add an entry like the follow:

<orderEntry type="module-library">
 <library name="mockito-all-1.10.19.jar">
 <CLASSES>
 <root url="jar://$MODULE_DIR$/mockito-all-1.10.19.jar!/" />
 </CLASSES>
 <JAVADOC />
 <SOURCES />
 </library>
</orderEntry>

 

For Eclipse you can add it to your Proj....... Read More

AppleScript, KeePassX and OSX

Oct 15,2017 at 12:51 pm By Ben Hutton

While there is no shortage of commercial solutions that will work on OSX I found open source solutions to be wanting. KeePassX while popular (at least is appears that way) works best under Linux. So the goal with this project was to get KeePassX and OSX working well together. To get KeePassX and OSX working well together requires a bit of coding.

I came late to using Password Managers.  I’ve had a history of creating a couple of really strong passwords that I use in multiple places. This has actually served me well however when I heard that LinkedIn had there password database leaked I decided it was time to review this. This was largely due to the realisation that I had the same password for Facebook.

AppleScript, KeePassX and OSX

The main reason I haven’t tried this in the past is largely due to trust. I don’t tend to trust other people with storing my passwords, especially closed source systems. I then did some research and came across KeePassX as probably the best alternative to a commercial solution. There was however a small issue with this. The auto-populated feature doesn’t work on OSX/MacOS. This is a bit of a deal breaker since it is my preferred platform.

After a bit more research into resolving this problem I came across a script written in AppleScript that solves the problem. Well at least it was su....... Read More

For anyone wanting an alternative to PhantomJS for Headless Selenium/Webdriver tests, you may want to have a look into Google’s new Headless Chrome.

Recently I was writing functional integration tests (I use this loosely) for validating deployment scripts.  Previously I had been using PhantomJS however this time I was having issues getting it working.   This is when I discovered the shaky nature of PhantomJS’s future.

After a bit of research I discovered that Google had recently release a headless version of Chrome.  At the time I was writing the tests it was so new that you had to either use the dev release of Chrome, or use Canary Chrome.

The below Python script uses the new Headless Chrome to load this website and assert the site title.  To get this working simply replace “path/to/chrome/binary” with the absolute path of your chrome binary.  In the case of my MacBook I have been using “/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary”.

Simple Python script to get you started

import warnings
import unittest

from selenium import webdriver

class FunctionalTests(unittest.TestCase):

    def setUp(self):
        warnings.filterwarnings("ignore", category=ResourceWarning)
        options = webdriver.ChromeOptions()
        options.binary_location = 'path/to/chrome/binary....... Read More
                        

Magento Cache Fatal Error

Nov 21,2016 at 12:56 pm By Ben Hutton

One thing to take into account when building a Magento based website is performance. The performance is lacking without a cache. You can either do this with the Magento Cache or use something like Varnish. Recently in building a clients site I was having an issue that if you turned on the cache you would end up with a PHP error.

Fatal error: Call to a member function getIdentities() on null in /home/webpage/magento/vendor/magento/module-catalog/Block/Category/View.php on line 177

This was certainly weird as in the past when building WordPress sites a malfunctioning cache would just leave broken elements on the web-page that the visitors see. I certainly didn’t expect to get a PHP error when doing something like turning a cache on.

Test Themes

After doing a few google searches and a few tests of my own it appeared to be theme related. That is if I switch over to the Blank or Luma built in themes everything worked as planned. Since the error itself didn’t give any hints as to where is was, I had to go to plan B. That is start disabling parts of my theme until I worked out what was breaking it. Since the theme at this time is not too complicated it didn’t take that long to pinpoint it down to the “default.xml” file in the layout section of the them. Disabling the block calls one at a time pointed to the footer causing the error.

Remove Unnecessary Code

One thing that developers tend....... Read More

Copyright © 2017 | Ben Hutton