Overriding grails.views.default.codec=’html’ config back to ‘none’

To summarize the various levels at which the codec can be applied: Set Config.groovy’s grails.views.default.codec=”html” to get HTML escaping by default on all ${expressions} in the application. Then when you want to default a whole page back to none, use the directive: <%@page defaultCodec=”none” %> or <%@ defaultCodec=”none” %> To disable HTML encoding for one … Read more

javascript – match string against the array of regular expressions

Using a more functional approach, you can implement the match with a one-liner using an array function: ECMAScript 6: const regexList = [/apple/, /pear/]; const text = “banana pear”; const isMatch = regexList.some(rx => rx.test(text)); ECMAScript 5: var regexList = [/apple/, /pear/]; var text = “banana pear”; var isMatch = regexList.some(function(rx) { return rx.test(text); });

Why isn’t “k” incremented in the statement “m = ++i && ++j || ++k” when “++i&&++j” evaluates to true? [duplicate]

You should avoid coding such unreadable code. It is actually parsed as m = (++i && ++j) || ++k; So once j >= 0 the ++j condition is always true, so ++k is not evaluated since && is a short-cutting and then but || is a short-cutting or else (so they may not evaluate their … Read more

JavaScript: split doesn’t work in IE?

you could add the code below to you program and it will work. var split; // Avoid running twice; that would break the `nativeSplit` reference split = split || function (undef) { var nativeSplit = String.prototype.split, compliantExecNpcg = /()??/.exec(“”)[1] === undef, // NPCG: nonparticipating capturing group self; self = function (str, separator, limit) { // … Read more

XPath 1.0 to find if an element’s value is in a list of values

You can check multiple conditions inside the same square brackets: /Location/Addr[State=”TX” or State=”AL” or State=”MA”] Or if you have a really long list, you can create a list of states and use the contains() function. /Location/Addr[contains(‘TX AL MA’, State)] This will work fine for two-letter state abbreviations. If you want to make it more robust … Read more

Regex to remove spaces between ‘[‘ and ‘]’

If brackets are always balanced correctly and if they are never nested, then you can do it: result = subject.replace(/\s+(?=[^[\]]*\])/g, “”); This replaces whitespace characters if and only if there is a ] character ahead in the string with no intervening [ or ] characters. Explanation: \s+ # Match whitespace characters (?= # if it’s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)