Unable to include gundb SEA for gun.user()? - gun

How to properly initiate the gundb.user() chain?
already tried this but cant make it worked.
let Gun = require('gun');
require('gun/sea');
and
let Gun = require('gun');
require(path.join(__dirname, '../node_modules/gun/sea.js'));
but I am still getting this on npm start

I think if you use 9.998, that will fix it.

Related

pdfjs error : The API version "2.16.105" does not match the Worker version "3.1.34".'

when I try to using pdfjs in vue for review PDFfile, I get this error, has anyone can tell me how to solve that
here is my code:
const pdfjsLib = require('pdfjs-dist/legacy/build/pdf.js')
pdfjsLib.GlobalWorkerOptions.workerSrc =
'https://mozilla.github.io/pdf.js/build/pdf.worker.js'
pdfjsLib
.getDocument("../assets/pdf/活動切結書.pdf'")
.promise.then((doc) => {
console.log(doc)
})
https://support.neat.com/neatapp/error-the-api-version-does-not-match-the-worker-version
I find this solve, that say clear your cookie, and I follow it, but doesn't solve my error
The only thing that helped me was replacing the link:
<script src="~/js/libs/pdf.js"></script>
to
<script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
P.S. I must complete my answer. Having dealt with the error myself, I can say: your 'pdfjs-dist/legacy/build/pdf.js' points to the downloaded library in the project folder, and the second 'https://mozilla.github.io/pdf.js/build/pdf.worker.js' points to the library on the network and their versions differ. It is required to equalize them.

way to use 'lowdb' in 'express'

Recently, I am trying to make a web page using express, and I am trying to manage login session information and bulletin board data through lowdb.
But when I try to generate and run the code that requires lowdb and controls lowdb,
There is a error with the require syntax with the err_code 'ERR_REQUIRE_ESM'.
When I googled it, it said that it was a syntax compatibility problem between commonjs and ESM, so do I have to convert all other codes to ESM because of one lowdb?
The code below is the code I made to control lowdb.
var low = require('lowdb');
var FileSync = require('lowdb/adapters/FileSync');
var adapter = new FileSync('db.json');
var db = low(adapter);
db.defaults({users:[], topics:[]}).write();
module.exports = db;
I don't want to convert the whole code to ESM because of lowdb, I want to use lowdb through commonjs. Or is there any other good way to handle local db via json file like lowdb?
Use lowdb#1.0.0 and it will work.
npm i lowdb#1.0.0

How to make insult command(discord.py)

i'm making an insult command,its making a JSONDecode Error
any solution...
#client.command(pass_context=True)
async def insult(ctx):
async with aiohttp.ClientSession() as session:
request = await session.get('https://evilinsult.com/generate_insult.php?lang=en&type=json')
insultjson = await request.json(content_type='text/html')
await ctx.send(url=insultjson['insult'])
The problem is most probably the link. Instead of &, just use &.
Plus, they seem to have a plain text option too - replace type=json with type=text in the same link and you should be able to use it without having to deal with JSON at all. Check out evilinsult.com's GitHub repo
Also, please always paste your exact errors - it helps us give you a better answer.

DokuWiki LDAP can't see any groups

We have just changed our domain after protracted name change (the name actually happened two years ago!) and our DokuWiki installation has stopped being able to see any groups and memberships.
The config has been updated to reflect the new server and DCs and login is working correctly, it is only the groups that aren't working.
$conf['auth']['ldap']['server'] = 'ldap://MYDC.mydomain.co.uk:389';
$conf['auth']['ldap']['binddn'] = '%{user}#mydomain.co.uk';
$conf['auth']['ldap']['usertree'] = 'dc=mydomain,dc=co,dc=uk';
$conf['auth']['ldap']['userfilter'] = '(userPrincipalName=%{user}#mydomain.co.uk)';
$conf['auth']['ldap']['mapping']['name'] = 'displayname';
$conf['auth']['ldap']['mapping']['grps'] = 'array(\'memberof\' => \'/CN=(.+?),/i\')';
$conf['auth']['ldap']['grouptree'] = 'dc=mydomain,dc=co,dc=uk';
$conf['auth']['ldap']['groupfilter'] = '(&(cn=*)(Member=%{dn})(objectClass=group))';
$conf['auth']['ldap']['referrals'] = '0';
$conf['auth']['ldap']['version'] = '3';
$conf['auth']['ldap']['debug'] = 1;
Obviously I have edited the doain name there, but for the life of me I can't see what's wrong here, It all worked fine yesterday on the old domain.
I should also state that this is an old version of DokuWiki that for various reasons I can't actually update.
The debug line gives me a "ldap search: success" line, but if I add "?do=check" onto any url within the system I get "You are part of the groups"...... and nothing, it can't see any groups.
It's a massive pain as we have a pretty intricate ACL setup for the site, so it's not like I can just throw it open to all.
If anyone has any suggestions, no matter how obvious, please pass them on.
Solved it by changing the dokuwiki authentication plugin that was used, the 'authad' is more simple to use and just works with what I'm doing.
As a side bonus it also means that I have finally been able to get the install upgraded to the current version.

Chef Data Bags and dynamic variable passing

I am trying to figure out a way to get the below code work; I have tried various methods but the chef-client run breaks at the 3rd line.
lsf = "#{node[:env]}"+"_ls"
dsf = "#{node[:env]}"+"_ds"
dsTemplateBag = data_bag_item('configTemplates', "#{dsf}")
lcTemplateBag = data_bag_item('configTemplates', "#{lsf}")
However on another test recipe I was able to successfully get the following working:
env = "test"
dsTemplateBag = data_bag_item('configTemplates', "#{env}")
I am quite new to Chef and please can someone advise me on how to get this working ?
After a little bit debugging I realised there was a typo preventing the data bag to be properly used; hence issue.
dsTemplateBag = data_bag_item('configTemplates', "#{node[:env]}_ls")
this worked for me. And as Tensibai suggested in the above comment mixing concatenation and interpolation is not a good practice (I was desperate to make it work! In my defense).