Stuff I'm Up To

Technical Ramblings

Axios — February 28, 2018

Axios

Laravel have bundled Axios in with their framework. I didn’t know what this was at first and didn’t use it. But once I figured out what it was for I tried to make a gradual change in coding to start using it.

The simplest way I can describe it is as a promise based replacement for jQuery $.ajax() for XHR submissions.

Continue reading

Advertisements
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.

name="/etc/mysql/mariadb.conf.d/

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:

require('@fortawesome/fontawesome');
require('@fortawesome/fontawesome-free-solid');
require('@fortawesome/fontawesome-free-regular');
require(‘@fortawesome/fontawesome-free-brands’);

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.

References

https://fontawesome.com/icons?d=gallery&m=free

 

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.

bootstrap-tagsinput — February 12, 2018

bootstrap-tagsinput

I’ve got a work project that fills in a database field with multiple comma separated values and thought using the bootstrap-tagsinput script would fit very well. Only I managed to misinterpret the instructions and made a bit of a hole to dig myself out of.

The big mistake I made was to add a data-role="tagsinput" attribute to my HTML. This was a bad mistake because I then tried to configure it using JavaScript – setting the tagClass and typeahead options. It worked, but nothing like I was expecting. I couldn’t reference it by it’s id selector using $('#selector') in the script and ended up using $('.boostrap-tagsinput > input') Which can’t be right.

Continue reading

Bootstrap Tags Input and Typeahead — February 8, 2018
Synology DSM 6.1.5-15254 Upgrade — February 7, 2018

Synology DSM 6.1.5-15254 Upgrade

Following this upgrade I accepted to install I spent the evening cursing.

The system started up and services were accessible as usual, but I couldn’t login to the admin Web UI. It just came up with a red box message:

"System is getting ready. Please log in later."

This went on for several hours. I could access an SSH terminal and check the logs and gather data, but I couldn’t figure out why it wouldn’t let me in. Everytime I tried it generated a syslog entry:

DiskStation login.cgi: login.cpp:211 System is not ready

I checked running services, restarting them and nothing. Disable Google authentication, still no joy.

2018-02-06T20:09:38+00:00 DiskStation synopkgctl: SYSTEM: Last message 'resource_api.cpp:163' repeated 1 times, suppressed by syslog-ng on DiskStation
2018-02-06T20:09:38+00:00 DiskStation synopkgctl: resource_api.cpp:163 Acquire web-config for DownloadStation when 0x0000 (done)
2018-02-06T20:09:40+00:00 DiskStation kernel: [ 100.904432] init: pkg-WebStation-userdir main process (11584) terminated with status 1
2018-02-06T20:09:42+00:00 DiskStation synoiscsiep: iscsi_stop_all.cpp:89 Successfully stopped iSCSI service.
2018-02-06T20:09:44+00:00 DiskStation synoiscsiep: iscsi_start_all.cpp:101 Successfully started iSCSI service.
2018-02-06T20:12:51+00:00 DiskStation login.cgi: login.cpp:211 System is not ready
2018-02-06T20:24:05+00:00 DiskStation synomkflvd: synoidx_system.cpp:36 [NOTICE] system is not ready? start anyway.
2018-02-06T20:24:05+00:00 DiskStation synomkthumbd: synoidx_system.cpp:36 [NOTICE] system is not ready? start anyway.
2018-02-06T20:24:10+00:00 DiskStation synoindexd: synoidx_system.cpp:36 [NOTICE] system is not ready? start anyway.
2018-02-06T21:03:24+00:00 DiskStation login.cgi: login.cpp:211 System is not ready

So I gave up on it and thought I’d revisit it today.

Then I received this email at about 3pm today.

Dear user,

DiskStation has finished checking the consistency on system volume (Root). The system is now ready for use.

Sincerely,
Synology DiskStation

and now I can logon like nothing happened.

Update

Today it’s been 6 days since I upgraded to DSM 6.1.6-15266 and I’ve not been able to logon because of the same symptoms. More googling ensued until I came across this comment by delapaco on a similar post here: https://www.supportmyidea.com/cant-login-synology-dsm-system-getting-ready-please-log-later/

So I ran the first two steps and was finally able to successfully login!

$ sudo synobootseq --set-boot-done
$ sudo synobootseq --is-ready
Boot done

But following a reboot it needed this process repeating so I could logon. Very strange. So I’m probably going to have to report this to Synology and see if there’s a fox for it.

 

PHP7.2 and MSSQL Drivers — February 5, 2018

PHP7.2 and MSSQL Drivers

I upgraded to PHP v7.2 on my Debian Buster/Sid today. Not a problem until I realised I’d broken my Microsoft SQL Drivers.

The real reason for my update from v7.0 to v7.2 was down to a problem I suffered with some Laravel console commands I was working on. When I ran a CLI based command php artisan group:command, which is a command I’m writing that uses a model from an MSSQL server. It would come up with an error message:

In Connection.php line 664:
                                                                               
  could not find driver (SQL: select top 1 * from [vwContract] order by [Ref]  
   asc)                                                                        
                                                                               
In Connector.php line 67:
                         
  could not find driver  

Continue reading