Using LIMIT with GROUP_CONCAT in MariaDB 10.3.3+

Prior to version 10.3.3 of MariaDB it was not possible to use LIMIT in a GROUP_CONCAT query. So in cases you wanted to select the first n elements of a GROUP_CONCAT query you had to make use of SUBSTRING_INDEX.``` CREATE TABLE t1 (id BIGINT NOT NULL AUTO_INCREMENT, email VARCHAR(255), PRIMARY KEY(id)); INSERT INTO t1 (email) VALUES (‘email’), (‘test2@email.com’), (‘test1@email.com’); To select the first element you would execute the following query: SELECT SUBSTRING_INDEX(GROUP_CONCAT(email SEPARATOR ‘::'), ‘::’, n) FROM t1;

Shortcut for excluding null and empty strings in MariaDB

Up until now when given the table below and working with MariaDB:CREATE TABLE t1 (id BIGINT NOT NULL AUTO\_INCREMENT, email VARCHAR(255) NULL, PRIMARY KEY(id)); INSERT INTO t1 (email) VALUES (''), (' '), ('test@email.com'), (NULL);I would use the following SELECT query in order to eliminate both empty strings and NULL values from the result set:SELECT email FROM t1 WHERE email <> '' AND email IS NOT NULL;However, this can be shortened to the more succinct:SELECT email FROM t1 WHERE email > '';To explain, empty strings of any length are equal:MariaDB \[(none)\]> SELECT '' = ' '; +--------------+ | '' = ' ' | +--------------+ | 1 | +--------------+ 1 row in set (0.

Searching for objects in large datasets

Groovy provides a number of useful methods for working with Lists. One that use all the time for searching for objects in a list is the find method. Looking under the hood you will find that is uses a linear search via the classic for loop to find the matching object. [java] public static T find(T[] self, @ClosureParams(FirstParam.Component.class) Closure condition) { BooleanClosureWrapper bcw = new BooleanClosureWrapper(condition); for (T element : self) { if (bcw.

Vuejs using MDBootstrap's custom input with Vee-validate

The vee-validate directive is used as follows: [html] {{ errors.first(‘email) }}[/html] Essentially, vee-validate creates an array of validation errors via the ErrorBag wrapper class and you can access that array in your template and javascript. MDBoostrap provides a custom input component, and according to the docs , for it to work with v-model, the inside the component should: Bind the value attribute to a value prop - (check) you can pass in a value prop On input, emit its own custom input event with the new value - (check) it has a custom event called ‘input’ fired whenever the @change and @input events occur on the nested input tag So combining the two you can change the html to this: [html] <md-input v-validate="‘required|email’" name=“email” label=“Email” icon=“envelope” :value=“email” @input=“email = $event” /> {{ errors.

Grails Spring Security Rest Custom Authentication Failure Response

The grails spring security rest plugin only returns a 401 status code for failed authentication. This creates a problem because you do not know the specific reason for failure and are forced to show the user a generic error message. The issue can be solved by overriding RestAuthenticationFailureHandler and registering your own implementation as a bean in resources.groovy. Grails plugins compile first allowing you to override classes as needed. In particular you override this method:

Vue.js watch changes to an array of objects

Vue.js provides the watch option for responding to changes in data. By default, when working with an array of objects, a watch object’s handler function is only triggered by mutations to the array itself and not the values of the object properties. Turning to the docs, in order to detect nested value changes in objects you need to set the watch object’s deep property to true as shown below:vm.$watch('todos', callback, { deep: true });This is Illustrated with this simple codepen example.