From e85680ed856e94187b1b1f693b027741a4f73394 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 17 Aug 2018 15:24:03 +0100 Subject: [PATCH] etc/profile.d/functions --- etc/profile.d/functions | 4 ++++ lib/lua/nb.lua | 12 ++++++++++++ 2 files changed, 16 insertions(+) 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 -- 2.47.3