Stuff I'm Up To

Technical Ramblings

Bootstrap-Vue — March 15, 2018


Using Vue.js and building Bootstrap style pages just got easier.

failed to mount component: template or render function not defined. —

failed to mount component: template or render function not defined.

Today I have been mostly smashing my head on the desk trying to figure out Laravel and Vue.js.

I thought I’d try to template an existing Laravel 5.5 project using Vue.js. Try as I might I could not get the template to work. I even stuck with the default example-component trying to get that to work . All I saw was an error reported in the console.

failed to mount component: template or render function not defined.

So I deployed a completely new Laravel project and added the example-component into the welcome page and it worked!

Continue reading

Sweet Christmas – VS Code — March 13, 2018

Sweet Christmas – VS Code

Ok, so I know Microsoft have been making some big steps in the world of Open Source – I confess to giving them little ear time, mainly because EVERYTHING we seem to do at work ends up a licensing battle that Microsoft always win, and by win I mean empty this years budget in one go.

I’ve been using Atom as my editor of choice for some time now and really like it, but someone suggested I checkout Microsoft Visual Studio Code. I am aware of it. It has the same construction as atom – it’s based on Node.js and built using electron, just the same. So I installed it today… and wowsers! It’s impressive. It uses git and picks up the file changes using git status and I’d almost swear it was atom.

It even has extensions for linting! Of course it also has a PowerShell extension – which to be honest I found missing in atom when coding PS in Linux.

But I’m not 100% sold yet. Atom is going to take some beating. But I’m certainly more surprised by code than I thought I would be.

Code v1.2.1 at the time of writing.

PostGIS Import from PHP Session Fails — March 12, 2018

PostGIS Import from PHP Session Fails

When importing a CSV file using Laravel I found that I’d get some strange error messages relating to a called function not matching the parameters that I was sending.

local.ERROR: SQLSTATE[42883]: Undefined function: 7 ERROR: function st_makepoint(numeric, numeric) does not exist
LINE 1: SELECT ST_SetSRID(ST_MakePoint(NEW.x_coordinate, NEW.y_coord...
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

I narrowed it down to the ST_SetSRID() and ST_MakePoint() functions and was 100% sure that they existed in the database, and with the right parameter types. I tried casting the values to double precision and still and the same errors.

The solution turned out to be that the function existed in the public schema NOT the schema I was using!

Continue reading

Axios — February 28, 2018
Laravel 5 – jQuery File Upload — February 22, 2018

Laravel 5 – jQuery File Upload

I needed a mechanism to upload CSV files to my Laravel instance and then process them into a table. The first part was working out how I wanted to upload the files.

I came across blueimp-file-upload which seems pretty popular and capable.

There was no need to go overly fancy. Just a simple form will do as the file will probably be uploaded as a single file. First I had to figure out how to get blueimp into Laravel.

Continue reading

MariaDB Apparmor and No login —

MariaDB Apparmor and No login

As I’ve been messing around with Sphinx I discovered that MariaDB actually includes the SphinxSE plugin out of the box. So I figured I’d ditch my MySQL installation on Debian and go back to the default Debian repository version MariaDB.

$ sudo apt-get remove mysql-server mysql-client

$ sudo apt-get install mariadb-server mariadb-client

This didn’t go to plan. Firstly it failed to run the apt configure scripts for mariadb-server-10.1 so it would not complete the install.

Checking the logs

Feb 21 15:52:29 mypc kernel: [ 323.603758] audit: type=1400 audit(1519228349.780:26): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/etc/mysql/mariadb.conf.d/" pid=5175 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

It goes back to a previous post I made about apparmor and MySQL. This time the problem was because the config file paths/names are different.


Continue reading

The Power of Sphinx — February 21, 2018

The Power of Sphinx

I’ve only really used Sphinx as part of a home project with MySQL. But today found that searching for text in 28 million rows in a PostgreSQL table needs something with a bit more performance that the base SQL server.

Installing Sphinx on Debian is very straight forward if you want the default repository version and not the leading edge version. I saw no reason why not.

$ sudo apt-get install sphinxsearch

Now getting it working takes some fettling of the /etc/sphinxsearch/sphinx.conf file. It doesn’t exist by default so you need to create it either by copying the sphinx.conf.dist file or start fresh.

You also then need to edit the /etc/default/sphinxsearch file and set START=yes.

Continue reading

Fontawesome 5 and Laravel 5 — February 20, 2018

Fontawesome 5 and Laravel 5

This should have been easier, but I must have misunderstood how this works.

After upgrading to Bootstrap 4, for some reason my node_modules didn’t contain fontawesome anymore. I don’t know what I did, but I took it as a sign to upgrade to fontawesome 5.

This was a little tricky to follow at first as it works differently to fontawesome 4.

Install fontawesome, install the libraries you want to use so they can be used in Bootstrap.

$ npm i --save @fortawesome/fontawesome
$ npm i --save @fortawesome/fontawesome-free-solid
$ npm i --save @fortawesome/fontawesome-free-regular
$ npm i --save @fortawesome/fontawesome-free-brands

In your resources/assets/js/bootstrap.js:


Compile it using dev or watch.

$ npm run dev

That’s it. Now you can use the class="fa fa-..." tags as expected. You might find some of your existing fa’s are no longer included free. So checkout the fontawesome site and choose icons to replace them with.



PostgreSQL Copy Data Between Servers —

PostgreSQL Copy Data Between Servers

Our GIS team use a PostgreSQL server with PostGIS. They recently asked if there was any way we could display some data in a simple web form for our users. So a bit of development work was required.

I didn’t want to code against their live system so thought I’d install a local version of PostGIS and copy the data from their database.

The database they wanted to access has 28 million rows – so it’s going to take a while.

Continue reading

Laravel API Token Auth — February 18, 2018
vi – Visual Mode — February 15, 2018

vi – Visual Mode

I’m sure when using a mouse in a text terminal the visual mode of vi/vim is useful, but I can never figure it out. In fact it prevents me from copying from a vi terminal in a window.

To temporarily disable mouse visual mode in a window, so you can copy your text it’s as simple as hold the SHIFT key down whilst selecting text with your mouse. Or you can disable it in that vi session by typing :set mouse-=a

To permanently disable visual mode in your session create or add the following to your ~/.vimrc file

set mouse-=a

If you need to do this for whilst using vi/vim under sudo, you’ll have to add the above into /root/.vimrc.