Author Archives: Robins

[Solved] Nuxt Import qrcodejs2.js / QRCode.js Error: document is not defined

preface

qrcodejs2.js/QRCode.js plug-in is in normal Vue.js project works normally. When you are in nuxt.js when used in the project, there will be an error, because qrcodejs2.js/qrcode.js the plug-in internally uses “browser specific (such as window/document) objects”. When compiled into nuxt.js without these, an error will be generated.

This article will provide you with the way to introduce the plug-in from 0-1, which runs perfectly.

Qrcodejs2.js and QRcode JS can be used.

First step

Download the adapter nuxt.js plug-in core code online.

Step 2

Prepare the file you just downloaded.

Put the QRcode.min.js file into the JS folder under the static static directory of the project (create one if you don’t have one).

Step 3

This step requires you to read the notes carefully, and you must understand why the path is written in this way.

Open the project nuxt.config.js configuration file, add the following code to the head configuration item:

// For now, we are using the local IP address http://192.168.3.5:8001 because we are in a development environment.
// Please replace it when you deploy your project later.
// --------- ---------- ---------- ---------- ---------
// For example, my future website deployment will be: http://www.demo.com
// Then this is how it should be written: http://www.demo.com/js/qrcode.min.js
// [domain + /js/qrcode.min.js]

src: 'http://192.168.3.5:8001/js/qrcode.min.js'

As shown in the following figure, pay attention to the position:

Step 4

At this point, your project can use the plug-in.

Cancel your import Import Code:

Test use

Or the original way of use:

// QRCode The keyword is a wrapped instance of the plugin, you can't change it!
let qrcode = new QRCode(qrcodeImgEl, {
    width: 100,
    height: 100,
    colorDark: '#000000',
    colorLight: '#ffffff',
    correctLevel: QRCode.CorrectLevel.H
})

VScode: How to Solve Pylance Error (pip Library Files Installed)

View Python installation location

Enter in Terminal

where python

View PIP installation library file location

pip show <packagename>

Open vscode and set the library path

Ctrl+shift+p Open ` preference; Open Settings(JSON)

Add path

"python.analysis.extraPaths":[
	    "/root/miniconda3/lib/python3.9/site-packages",
        "/root/.local/lib/python3.9/site-packages",
        "...."
        ]

[Solved] Python Error: socket.error [Errno 9] Bad file descriptor

To learn Python Network programming, I wrote two small programs on the server and the client according to the book, and found that an error was reported:

Traceback (most recent call last):

File “./tsTserv.py”, line 20, in

data = tcpCliSock.recv(BUFSIZ)

File “/usr/lib/python2.6/socket.py”, line 165, in _dummy

raise error(EBADF, ‘Bad file descriptor’)

socket.error: [Errno 9] Bad file descriptor

The source code of the server side is as follows:

while True:
        print 'waiting for connection...'
        tcpCliSock,addr = tcpSerSock.accept()
        print '...connected from:',addr
        while True:
                data = tcpCliSock.recv(BUFSIZ)
                if not data:
                        break
                tcpCliSock.send('[%s] %s' %(ctime(),data))
        tcpCliSock.close()
tcpSerSock.close()

Solution:

tcpCliSock.close() is placed in the second while loop, causing tcpCliSock to be closed after receiving data once, and this statement should be placed in the outer loop

[Solved] Cannot call sendError() after the response has been committed

Background of error reporting: when working on the open source project “Ruiji takeout”, after writing the interceptor code, when the front-end logs in, the back-end reports an error as follows:

        

 

Solution:

I found that my code, at the very beginning of the method, has unconditionally released any resources, i.e. filterChain.doFilter(request, response); when this line of code, and then continue to write the code to execute the response, it will report the above error. So, just comment out this line of code.

[Solved] Spring-MVC Error: org.springframework.validation.BeanPropertyBindingResult

The error report is as follows:

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘shopOrder’ on field ‘orderTimePay’: rejected value [2019-01-13 12:05:00];

 

Reason & Solution:
SimpleDateFormat is non-thread-safe. It’s OK to get a new SimpleDateFormat() under each thread.

[Solved] D455 Depth Camera Error: keyerror: ‘frame_ device_ t‘

color_t = sens_frame.color_t[self.computespeed_t_type]
KeyError: ‘frame_device_t’
Probably because two values are not manually added in the registry
Enable Metadata: Metadata contains important timestamp information and needs to be enabled manually. Please refer to:

https://dev.intelrealsense.com/docs/compiling-librealsense-for-windows-guide

Modifying the Windows Registry:
For each interface found (Steps 2 and 3) perform
Using Registry Editing tool such as “regedit” navigate to HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses{e5323777-f976-4f5b-9b55-b94699c46e44} branch.
Browse into the subdirectory with the name identical to the Device instance path obtained from the previous step
Expand the entry into #GLOBAL -> Device Parameters
Add DWORD 32bit value named MetadataBufferSizeInKB0 with value 5.
Add an additional DWORD 32bit value named MetadataBufferSizeInKB1 with value 5 for RS400 device zero interface ##?##USB#VID_8086&PID… MI_00…

Repeat the previous step for HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses\{65E8773D-8F56-11D0-A3B9-00A0C9223196} branch

[Solved] Linux WebService Startup Error: BindException: Cannot assign requested address

Linux deploys the WebService service and starts the error bindexception: cannot assign requested address

code

Question

The windows local test is normal. When it is deployed to the Linux server, an error is reported when it is started: BindException: Cannot assign requested address

Cause of problem

There is a problem with the IP in the URL. If Alibaba cloud and other cloud servers are used, you need to check the address of the network card eth0, and then change the IP in the URL to the IP of eth0

if not, check whether the IP of eth0 is configured or not in /etc/hosts. If not, add: IP + hostname
if you do not know the hostname, you can use the hostname command to check. If not, vim /etc/hosts, and then insert the data: IP hostname. Note that there is a space in the middle

Finally, when accessing WebService, the service can be accessed through public IP

[Solved] kafka Startup Error: ERROR Shutdown broker because all log dirs in /…/kafka/logs have failed (kafka.log.LogManager)

Error when starting kafka

 

The problem occurs in the logs file

ERROR Shutdown broker because all log dirs failed: It means that all log files cannot be used, which may be a permission problem

Then enter the logs to view

 

Currently our user is hadoop, and the log files belong to the root user, so it can be solved by modifying the permissions

sudo chown hadoop.hadoop logs -R

 

You can see that the file ownership has been changed to hadoop

try to start kafka

successfully started

[Solved] vue watch Error: Error in callback for watcher “xxx“: “TypeError: Cannot read properties of undefined …

 

1. Question

1. Listening to an object in data, an error is reported. The error is strange: you cannot use the apply method on undefined

1) detailed errors are as follows:

vue.esm.js?9b69:5059 [Vue warn]: Error in callback for watcher "flowCategory": "TypeError: Cannot read properties of undefined (reading 'apply')"

found in

---> <FlowItem> at src/projects/comen/implemenceWorkstation/flowSetting/FlowItem.vue
       <ElTabPane> at packages/tabs/src/tab-pane.vue
         <ElTabs> at packages/tabs/src/tabs.vue
           <View> at src/views/implemenceWorkstation/flowSetting/view.vue
             <Index> at src/layout/index.vue
               <App> at src/App.vue
                 <Root>
warn$2 @ vue.esm.js?9b69:5059
logError @ vue.esm.js?9b69:3728
globalHandleError @ vue.esm.js?9b69:3724
handleError @ vue.esm.js?9b69:3691
invokeWithErrorHandling @ vue.esm.js?9b6

2) the code is as follows:

  watch: {
    flowCategory: {
      hanlder(newval, oldval) {
        console.log('flowCategory', newval, oldval);
      },
      deep: true
    }
  }

2. Solution:

After searching for a long time, I found that I had written the word “handler” incorrectly. I typed it incorrectly and wrote it as “hanlder”, and the IDE did not prompt  &***&;

Change it to the following. That’s all

  watch: {
    flowCategory: {
      handler(newval, oldval) {
        console.log('flowCategory', newval, oldval);
      },
      deep: true
    }
  }

3. Now we finally understand the error reporting: it is to tell us that the handler has a problem. The watch does not know what to do when monitoring changes.

[Solved] No tf data. Actual error: Fixed Frame [world] does not exist

1. No tf data. Actual error: Fixed Frame [world] does not exist

When using rviz to view relevant coordinate information, you may encounter No tf data. Actual error: Fixed Frame [world] does not exist, the main reason is that there is no world coordinate system in the TF tree. The solution is to let rviz know where the world coordinate system is. You can manually publish using the following command

rosrun tf static_transform_publisher 0 0 0 0 0 0 1 map world 5

2. nvalid argument “/world” passed to canTransform argument source_frame in tf2 frame_ids cannot start with a ‘/’ like

After the first problem is solved, another problem may appear Invalid argument "/world" passed to canTransform argument source_frame in tf2 frame_ids cannot start with a '/' like: as shown in the figure:

this problem is mainly because “/ world” is used in the release code and “world” is used in our release It may be good to recompile the code from “/world” to “world”

[Solved] RuntimeError: “unfolded2d_copy“ not implemented for ‘Half‘

report errors

RuntimeError: "unfolded2d_copy" not implemented for 'Half'

reason

Parameters use_half=true passed in by the model, that is, the CPU is reasoned by using fp16 mixed precision calculation. Fp16 is used to speed up the speed, but the pytorch CPU does not support fp16,

Solution:

  1. Add use_half=False.
  2. Modify half() to float().

So that the model can be calculated;

Modification of my error report:


I hope this article is useful to you!

Thank you for your comments!

[Solved] error: invalid operands of types ‘QLabel*‘ and ‘void‘ to binary ‘operator>

Error in QT: invalid operators of types’ qlabel * ‘and’ void ‘to binary’ operator & gt; ‘ Wrong solution.

This kind of error is generally the operation symbol use error

For example:

btnLabel>setFixedSize(menuBtn->width(),menuBtn->height());

Here ‘>’ operation symbol is wrong, changed to ‘->’, it will be OK!

 btnLabel->setFixedSize(menuBtn->width(),menuBtn->height());