Scratchpad: Getting Started With Docker

We are starting a project at work that looks like it’s going to involve Docker. This post will be a scratchpad for collecting useful links and reference material

Introduction

Best Practices

Advertisements

Linux Mint running in software rendering mode

I wanted to try running Linux Mint as a VM in Oracle VirtualBox. I created a new VM using the standard settings (only increasing the memory from the default of 768 MB to 2048 MB and disk size from 8 GB to 20 GB (the actual file size on my physical disk is allocated dynamically, so I’m not too worried)). I pointed it at the Mint ISO I’d downloaded and started it up. A few seconds later, I was at the desktop (running as a Live CD). Everything was looking good, except for this message towards the top-right:

Running in software rendering mode

Cinnamon is currently running without video hardware acceleration and, as a result, you may observe much higher than normal CPU usage.

There could be a problem with your drivers or some other issue. For the best experience, it is recommended that you only use this mode for troubleshooting purposes.

The message makes it sound like some sort of driver problem. Since it’s running as a LiveCD at this stage and hasn’t actually been installed yet, I thought that might be the reason, so I went ahead and installed it.

The message didn’t go away.

I spent a while trying to update drivers.

The message still didn’t go away.

The Fix

The fix is to install (the latest) Guest Additions and enable 3D acceleration:

Install (the latest) Guest Additions

  1. With the VM running, click on Devices on the VM container menu
  2. Click the option “Insert Guest Additions CD image…”
  3. When the warning box appears asking if you’re sure you want to run the software, select “Run”
  4. Enter the super user password as required
  5. A terminal window will warn you that you already appear to have a version installed and are you sure you want to continue installing this. Enter “yes”
  6. When it’s finished, press enter to close the terminal window

Enable 3D Acceleration

  1. Shutdown the VM
  2. In the main VirtualBox window, right-click on the VM and go to Settings
  3. Under the Display section, turn on “Enable 3D acceleration”

Version Details

  • Oracle VirtualBox 5.0.26
  • Host: Windows 10
  • Guest: Linux Mint 18 “Sarah” Cinnamon Edition

Android Tablet Not Syncing Google Contacts

I finally bought a tablet for myself a couple of weeks ago. Nothing fancy, but I just wanted something cheap with a big screen, mostly for reading and browsing the web etc. In the end, I went for an IT 10″ Quad Core tablet running Android 4.4.2. I knew it wasn’t going to be top of the range, but it sounded just right for the money.

I haven’t had an Android device before, but it was pretty easy to get going. Pretty much as soon as I logged into Google, the GMail and Calendar apps automatically pulled all my details and “just worked”. A good start…

When I started to write an email though, I was a bit surprised to find that it didn’t seem to have any of my contacts. I looked at the list of applications, but couldn’t find anything that sounded like an address book or a contacts list. In the settings, under my Google account, there were check boxes to sync different data types, such as Calendar, Chrome, Gmail, but not Contacts (there was People, but that didn’t seem to do what I needed).

I’ve eventually figured out how to get it working…

I must be clear: I am not an Android expert and I am not recommending anyone to follow these steps. This is just what I’ve done and it appears to have worked for me. Your mileage may vary – follow these steps at your own risk!! As Firefox’s “about:config” page warns: “Here be dragons!!Continue reading

Oracle VirtualBox Error: VT-x/AMD-V hardware acceleration

I’m running Windows 10 on my home PC, but occasionally use Oracle VirtualBox to run a Linux VM. Recently when I tried to start the VM, I got this error:

 VirtualBox – Error

VT-x/AMD-V hardware acceleration is not available on your system. Your 64-bit guest will fail to detect a 64-bit CPU and will not be able to boot.

Screenshot of the error message when Oracle VirtualBox can't detect a 64-bit CPU

Oracle VirtualBox warning that the VM won’t boot

And sure enough, if I press “Continue”, the VM just displays the following when it tries to boot:

This kernel requires an x86-64 CPU, but only detected an i686 CPU.

Unable to boot – please use a kernel appropriate for your CPU.

I didn’t understand why I was getting this – my PC was physically the same as it was last time I’d run it, and I the only thing that was different about the VM was that I’d updated VirtualBox  to the latest version, but it couldn’t have been caused by that could it?

I found out that no, it wasn’t.

The one thing that had changed on my PC a few weeks ago was that I’d updated the BIOS. One of the settings in it is called:

BIOS Features –> Intel Virtualization Technology

This was set to “Disabled”. As soon as I changed it to “Enabled”, my VM started working again.

Oracle Unit Testing

I’m wanting to start doing some unit testing for PL/SQL code I’m contributing to an Oracle database. Most of the existing code is big, unwieldly and entirely unsuitable for unit testing, but I’m hoping that if I can make a start testing new code, then at least that’s something (and who knows, we may be able to refactor some of the old code given enough time!).

In the past, I’ve had some success with utPLSQL. It looks to be a standard xUnit framework, so should be familiar to anyone who’s used anything like JUnit. The biggest problem is that it’s pretty much been abandoned. It still exists on Sourceforge, but other than a few people posting things like bug reports, nothing much has happened for a good few years! It’s a pity, because it works well and has pretty good documentation (even if a few of the links are out of date and no longer work), but could probably just do with a few tweaks to fix a couple of minor bugs. Looking round, it sounds like it’s still the best of what’s available for free.

Has anyone had any experience of unit testing Oracle PL/SQL? Have you used utPLSQL and/or anything else?

Update: Since this post was first published, I have been added as an administrator of the utPLSQL project (since August 2013). Please feel free to drop by!!

Update 2: I stepped down from the utPLSQL project in June 2016. My role at work had changed again, and I no longer used it. There were other people with more time and enthusiasm for moving the project on, so having migrated the project to its new home on GitHub, it was sensible for me to step aside and let them run with it. I wish them the best of luck 🙂

Management

A man in a hot air balloon realised he was lost. He reduced altitude and spotted a woman below. He descended a bit more and shouted, “Excuse me, can you help me? I promised a friend I would meet him an hour ago but I don’t know where I am.”

The woman below replied, “You’re in a hot air balloon hovering approximately 30 feet above the ground. You’re between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude.”

“You must be in Information Technology,” said the balloonist. “I am,” replied the woman, “how did you know?”

“Well,” answered the balloonist, “everything you told me is probably technically correct, but I’ve no idea what to make of your information and the fact is, I’m still lost. Frankly, you’ve not been much help at all. If anything, you’ve delayed my trip.”

The woman below responded, “You must be in Management.”

“I am,” replied the balloonist, “but how did you know?”

“Well,” said the woman, “you don’t know where you are or where you’re going. You have risen to where you are, due to a large quantity of hot air. You made a promise, which you’ve no idea how to keep, and you expect people beneath you to solve your problems. The fact is you are in exactly the same position you were in before we met, but now, somehow, it’s my fault.”

Device Manager: SABKUTIL

I’ve been helping some friends fix their computer and I ended up looking in Device Manager. Everything looked OK so I turned on “Show Hidden Devices”. A new list appeared called “Non-Plug and Play Drivers”. In there, there was an item called “SABKUTIL” with a yellow exclamation mark. Looking at the properties didn’t give much away as to what it was, other than the fact that the driver couldn’t be found (hence the exclamation mark).

I didn’t recognise this device so turned to Google. I wasn’t particularly worried about it being malicious, I was more curious about what it was and why it was in an error state. I eventually found a page on bleepingcomputer.com which suggests the device is related to something called “Super Ad Blocker”. Sure enough, when I went to “C:\Program Files\SuperAdBlocker.com\Super Ad Blocker“, the file “SABKUTIL.sys” was missing. I searched the hard drive just in case it was somewhere else, but I couldn’t find it. It looked like this program had been installed once, but had since been removed. For some reason, the driver file had gone, but the device entry had been left! I therefore deleted this device, since it was no longer required and the actual driver itself no longer existed.

This didn’t solve my original problem (I didn’t really expect it to), but it doesn’t seem to have done any harm!

Reality: Accessing SELECT-LISTS From Other Accounts

This week I learnt a useful Reality tip for working with select-lists. If you’ve built a list in one account and want to use it in another, it’s actually really easy to do! You do your GET-LIST as normal, but after the list name, you put the account name that holds the list.

Time for an example. Let’s say you create a list called MYLIST in account ACCA and you want to access it in account ACCB, this is what it would look like:


:LOGTO ACCA

:SELECT PRODUCTS

1,000 Items selected.
>SAVE-LIST MYLIST
[241] 'MYLIST' Cataloged.

:LOGTO ACCB

:GET-LIST MYLIST ACCA

1,000 Items selected.
>

UK Phone Number Validation in CodeIgniter

I was looking for a way to validate UK phone numbers in CodeIgniter (or more generally, PHP) and found this on the CodeIgniter forums. Works a treat!

UK Phone Number Validation (regexp trickle!).

For link independence, I’ve copied the pertinent parts from the above link:

So you’d have in your form controller something like:

//Set rules that require numeric only, min length of 9 and field as required.
$this->form_validation->set_rules('phone', 'Phone Number', 'required|numeric|min_length[9]|callback_uk_phone_check');

Then the callback function is:

/**
    * Super quick UK Phone number checker.
    * Adapted from javascript solution found here:
    * http://www.braemoor.co.uk/software/_private/jstelnumbers.js
    **/
    function uk_phone_check($number)
    {
        $errorarr = array(
            //0 => "Valid UK telephone number",
            //1 => "Telephone number not provided",
            //2 => "Please do not include the country code in the telelphone number",
            //3 => "UK telephone numbers should contain 10 or 11 digits",
            4 => "The telephone number should start with a 0",
            5 => "The telephone number is either invalid or inappropriate"
        );
        
        //Set the error to false, our final bit of logic will check against this
        $telnum_error = false;
        
        // Don't allow country codes to be included (assumes a leading "+")
        //$leading = '/^(\+)[\s]*(.*)$/';
        
        // Check that the first digit is 0
        $first = '/^0[0-9]{9,10}$/';
        
        //Check that the telephone number is valid.
        $valid = '/^(01|02|03|05|070|071|072|073|074|075|07624|077|078|079)[0-9]+$/';
        
        // Array holds the regular expressions for the drama telephone numbers
          // see http://stakeholders.ofcom.org.uk/telecoms/numbering/guidance-tele-no/numbers-for-drama
        $drama = array();

        array_push($drama, '/^(0113|0114|0115|0116|0117|0118|0121|0131|0141|0151|0161)(4960)[0-9]{3}$/',
        '/^02079460[0-9]{3}$/', '/^01914980[0-9]{3}$/','/^02890180[0-9]{3}$/','/^02920180[0-9]{3}$/',
        '/^01632960[0-9]{3}$/','/^07700900[0-9]{3}$/','/^08081570[0-9]{3}$/','/^09098790[0-9]{3}$/',
        '/^03069990[0-9]{3}$/');

        //if (preg_match($leading, $number)) {
            //$telnum_error = 2;
        //} elseif (!preg_match($first, $number)) {
        if (!preg_match($first, $number)) {
            $telnum_error = 4;
        } elseif ( !preg_match($valid, $number) ) {
             $telnum_error = 5;
        } else{        
        
        //Check against the drama numbers
            for ($i=0; $i < count($drama); $i++) {
                if ( preg_match($drama[$i], $number) ) {
                    $telnum_error = 5;
                }
            }
        }

        //See if we've got an error
        if($telnum_error){
            //echo "error >>>>>>>>>>>>>>> " . $errorarr[$telnum_error] . " <<<<<<<<<<<<<<<";
            $this->form_validation->set_message('uk_phone_check', 'The %s number must be a valid UK telephone number<br/><u>' .$number. '</u> --> ' . $errorarr[$telnum_error]);
            return FALSE;
        }else    {
            return TRUE;
        }
    }