From: Nicolas Boisselier Date: Fri, 17 Aug 2018 14:24:03 +0000 (+0100) Subject: etc/profile.d/functions X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=e85680ed856e94187b1b1f693b027741a4f73394;p=nb.git etc/profile.d/functions --- diff --git a/etc/profile.d/functions b/etc/profile.d/functions index c4abb4d0..5f781134 100755 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -768,6 +768,10 @@ http_head() { fi } +password_create_alnum() { + password_create "$1" '[:alnum:]' +} + password_create() { local len=${1:-30} #local chars=${2:-'[:alnum:] #$,;.:*@[]()?+=_%-'} diff --git a/lib/lua/nb.lua b/lib/lua/nb.lua index 2cd3c4dc..1f1d52d2 100644 --- a/lib/lua/nb.lua +++ b/lib/lua/nb.lua @@ -343,4 +343,16 @@ function nb:json2html(url,fmt) return html end +function nb:hash_keys_uniq(rows,k) + local uniq = {} + local ret = {} + for _,row in pairs(rows.data) do + if row[k] and row[k] ~= '' and not uniq[row[k]] then + uniq[row[k]] = 1 + ret.insert(row[k]) + end + end + return ret +end + return nb