Saturday, 28 April 2018

Swift divideWithOverflow doesn't - Update 2

Quite a long time ago I came across an unusual circumstance that crashed Swift int32divideWithOverflowI reported the bug to see the details.

Since then ...divideWithOverflow has morphed into divideReportingOverflow and it fixes the issue in some cases but not quite all yet.

Sunday, 25 February 2018

Installing Watir and Python Selenium on macOS

I have been using Watir on and off for quite a long time, seeing it develop from Watir through Watir-Webdriver and back to Watir. I needed to install its latest incarnation and hit a few problems. The problems were caused more by my impatience in not reading through the notes on the Watir website than anything else.

At the same time, I decided to install the Python Selenium package to try it out. It also didn't work out of the box. Once again, the problem was that I hadn't been sufficiently thorough in reading the instructions.

The main problem with both was the need to install the Firefox and Chrome web drivers and to configure Safari's. After a little trial and error and reading through  the documents, the simplest way came to the surface.

I installed the Firefox and Chrome web drivers using Homebrew: 
    brew install geckodriver
    brew install chromedriver

My Safari installation was already configured to show the Develop menu and I have Allow Remote Automation menu item selected. From the Watir Safari Driver page, I found that I need to run safaridriver once from the command line to give it the proper authorities. I needed to run it from an administrator account:
     sudo /usr/bin/safaridriver

After that both Watir and Python Selenium both will happily load Safari, Firefox and Chrome when run from a macOS user account.

Thursday, 19 October 2017

Overcoming My Pythonaphobia

I've taken a good first step to overcoming my Pythonaphobia. I was given the chance to review the third edition of Practical Programming by Paul Gries, Jennifer Campbell and Jason Montojo published by The Pragmatic Bookshelf.

It is an excellent introductory book aimed primarily at people studying in a university setting. It teaches both Python and solid programming techniques. I feel that it would be an excellent second or third book for somebody whose introduction to programming has been via the Raspberry Pi.

From reading the book, I was able to see some strengths of Python compared with languages with which I am more comfortable. For instance, I really liked doctest and, thanks to Practical Programming, Python's straightforward object model.

I continue to find Python's syntax too fussy. It's indentation, line continuation marks, etc. make it feel somewhat pre-historic: the RPG of the modern age.

Still, thanks to Practical Programming, the seemingly ever growing popularity of Python and it being at the heart of Raspberry Pi, I am encouraged to look a little deeper.

Tuesday, 15 August 2017

Busted or LuaUnit? Answered

I didn't have the time to complete a thorough evaluation of Busted and LuaUnit but have come to the conclusion that I will use Busted. Both Busted and LuaUnit work well and, given Lua's dynamic nature, I found it easy to write tests with them.

I came to my decision after going back to the Stockfetch tests after a gap of two or three months. It was much easier to work out what was being tested from the Busted tests than it was from the LuaUnit ones. It was because of the names that I had given the tests not any failing on LuaUnit's part.

So my choice was not made on a technical basis but because Busted encourages me to write more understandable tests.

I also found, in some cases, Busted's spies, stubs and mocks made for shorter test code than using Lua's flexibility with LuaUnit. On the other hand, LuaUnit tests seem to run much quicker than Busted's. Around ten times faster in my case.

Wednesday, 26 July 2017

Installing Raspbian x86 under Virtual Box on macOS host

I failed in my first attempt to install Raspbian x86 under Virtual Box hosted macOS. The problem was I hadn't enable PAE/NX for the virtual processor. I learnt this from Andrew Cotswold Jam Oakley's excellent instructions

Although written for installing Raspbian on a Windows-hosted Virtual Box, the instructions apply equally to a macOS.

One thing that Andrew's instructions didn't cover was sharing folders between the host and Raspbian. To do this you need to have installed the Virtual Box guest additions as described in Andrew's instructions and then setup the shared folder(s) in the Virtual Box settings for your Raspbian VM. The last thing is to set the correct permissions so that you can access the folders from the VM.

All that is needed is to add yourself to the group which controls the shared folder(s). Assuming your username is pi, you would need to run the following command:

  sudo adduser pi vboxsf

You will find your shared folders in the /media folder. The prefix sf_ will have been added to their names. 

Wednesday, 19 July 2017

Running Rebol under FreeBSD 11


Whilst it has not been updated for a long time, the FreeBSD version of Rebol will run under FreeBSD 11. You do have to install the system libraries that were current when the Rebol FreeBSD version was last updated. FreeBSD has a complete set of "compatibility" libraries. Rebol requires version 6. Here is the command to install them:

pkg install misc/compat6x
 

Sharing Folders between macOS and FreeBSD under Virtual Box

I use VirtualBox to host a number of guest operating systems on a Mac, mainly for testing. I write a few tests for the emerging Red programming language. Although still in the Alpha phase, Red runs under Windows, macOS, Linux and FreeBSD.

Windows and Linux are well supported by VirtualBox and after installing the VirtualBox Guest Additions you can share folders between the host and guest operating systems. (The additions also provide mouse integration, clipboard sharing and other sharing features). This allows me to keep a single copy of the Red git repository and access it from the different virtual machines.

Virtual Box support of FreeBSD is not quite at the level of the others operating systems. Specifically, the guest additions on FreeBSD don't support folder sharing. In the current alpha, the Red GUI is not implemented for FreeBSD. However, I found that there is a simple method to share folders between the macOS host and the FreeBSD guest using NFS. I was able to get it working quickly and reliably, thanks to lionoceros's clear and thorough post on the FreeBSD forums. 

Note: Installing the VirtualBox additions under FreeBSD is straightforward as there is a package available. Be aware that installing the package requires 1GB of disk space. If you plan to install the additions, these instructions should help.