Category Archives: How to Fix

Go: How to Fix plug-in installation failure in vscode of windows system

1.Run go env -w GO111MODULE=on //enable mod   
  Run go env -w GOPROXY=https://goproxy.cn,direct //set proxy
2. Go to GOPATH directory, create src/golang.org/x/ directory, go to src/golang.org/x/ directory
    git clone https://github.com/golang/tools.git
    git clone https://github.com/golang/lint.git
3.Then you can install the go plugin in vscode as prompted (odds are it still won't work)
 So you need to execute the following command in the terminal of %GOPATH%/src directory
    go get -u -v github.com/mdempsky/gocode
    go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
    go get -u -v github.com/ramya-rao-a/go-outline
    go get -u -v github.com/acroca/go-symbols
    go get -u -v golang.org/x/tools/cmd/guru
    go get -u -v golang.org/x/tools/cmd/gorename
    go get -u -v github.com/go-delve/delve/cmd/dlv
    go get -u -v github.com/stamblerre/gocode
    go get -u -v github.com/rogpeppe/godef
    go get -u -v github.com/sqs/goreturns
    go get -u -v golang.org/x/lint/golint
    go get -u -v github.com/cweill/gotests/...
    go get -u -v github.com/fatih/gomodifytags
    go get -u -v github.com/josharian/impl
    go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
    go get -u -v github.com/haya14busa/goplay/cmd/goplay
    go get -u -v github.com/godoctor/godoctor
4.There may still be errors after performing the above steps, just follow the instructions prompted by vscode to fix them.


Note: There may be problems with the following:
    Error: go: cannot find main module; see 'go help modules'
    Solution go env -w GO111MODULE=off
GO111MODULE There are three values: off, on and auto (default).

GO111MODULE=off, no module support, find dependencies from $GOPATH and vendor folders.
GO111MODULE=on, with module support, go ignores the $GOPATH and vendor folders and only downloads dependencies based on go.mod.
GO111MODULE=auto, the go command line will decide whether to enable the modules feature based on the current directory.
There are two scenarios.
	module support is enabled when the project is outside of $GOPATH/src and the project root directory has a go.mod file.
	the project is inside $GOPATH/src and module support is not provided even if the go.mod file exists.

JavaScript removes the number specified in the array

code

Method 1: return a new array
/ / remove all elements in array arr whose values are equal to item. Do not modify the array arr directly, and the result will return a new array
instead**

function clearArrItem(arr,item){
	var arrs=[];
	for(var i = 0;i<arr.length;i++){
		if(arr[i] !== item){
			arrs.push(arr[i])
		}
	}
	return arrs
}
var arrs = [1,2,5,4,2,1,5,2,1,2,5,42,1,4,11,1,1,1,1,11];
console.log(clearArrItem(arrs,1));

**

Method 2: operate in the original array
/ / remove all the elements in the array arr whose values are equal to the item, directly operate on the given arr array, and return the result
to the user**

function clearArrItem2(arr,item){
	var index;
	for(var i = 0;i<arr.length;i++){
		if(arr[i] === item){
			if(arr[i+1] === item){
				arr.splice(i,1);
				i--;
				continue;
			}
			arr.splice(i,1);
		}
	}
	return arr;
}
var arrs = [1,5,6,3,5,4,1,1,1,1,1,1,1,5,8,4,5,1,5,1,5,1,1];
console.log(clearArrItem2(arrs,1));

**

UTF-8 encoding error when starting robotframework ride

Record the error when starting the robot framework ride

start-up ride.py The following error occurred

D:\Program Files(x86)\python\Scripts>python ride.py
Traceback (most recent call last):
  File “D:\Program Files(x86)\python\lib\site-packages\robotide\application\ application.py “, line 70, in OnInit
    self._ find_ robot_ installation()
  File “D:\Program Files(x86)\python\lib\site-packages\robotide\application\ application.py “, line 124, in _ find_ robot_ installation
    str( os.path.dirname (rf_ file), ‘utf-8’))).publish()
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa3 in position 20: invalid start byte
OnInit returned false, exiting…
Error in atexit._ run_ exitfuncs:
wx._ core.wxAssertionError : C++ assertion “GetEventHandler() == this” failed at ..\..\src\common\ wincmn.cpp (478) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

 

 

Check the log. UTF-8 can’t encode 20,

Therefore, we tried the next step application.py The UTF-8 coding form in the file is changed to “GBK”, restart ride.py After that, ride is turned on

Cloning failed using an SSH key for authentication

Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+ Name + time
to retrieve a token. It will be stored in “C”: / users / administrator / appdata / roaming / composer/ auth.json ” for future use by Composer.

Log in to GitHub and open the following link
below https://github.com/settings/tokens
Generate a token
and execute the following code

composer config --global --auth github-oauth.github.com <token>

Correct writing

composer config --global --auth github-oauth.github.com 441be92d716e*****853ec70ffa

Then read the error message in the newspaper

C:/Users/Administrator/AppData/Roaming/Composer/auth.jso

Is there any change in the following file? If so, there will be no problem,

error C4996: ‘inet_addr‘: Use inet_pton() or InetPton() instead or define _WINSOCK_D

[questions]

Vs2015 appears when writing socket client. (this is the second time I have encountered this problem. Last time vs2017, I must remember it to facilitate myself to check in the future: P)

SOCKADDR_ IN ClientAddr;
ClientAddr.sin_ family = AF_ INET;
ClientAddr.sin_ addr.S_ un.S_ addr = inet_ addr(“127.0.0.1”);
ClientAddr.sin_ Port = htons (port);
error c4996: ‘INET_ addr’: Use inet_ pton() or InetPton() instead or define _ WINSOCK_ DEPRECATED_ NO_ WARNINGS to disable deprecated API warnings

[reason]

In the version after vs2013, INET is added_ New functions such as Pton () and inetpton () are used for IP address conversion between “dotted decimal” and “binary integer”, and can handle IPv4 and IPv6. And INET_ Addr is an old function. Higher version vs uses a new function by default when compiling, so this error will be reported.

[solution 1]

Replace INET with the new function suggested_ Addr function.

[solution 2]

Modify the vs configuration and tell it I want the old function

1. Modification method: Item – & gt; attribute – & gt; C / C + + – & gt; general – & gt; SDL check, change “yes” to “no”.
2. Property page of file_ CRT_ SECURE_ NO_ “Warnings” plus
– – –
copyright notice: This is CSDN blogger Rani_ The original article of “ZZ” follows CC 4.0 by-sa copyright agreement. Please attach the link of original source and this statement.
Link to the original text: https://blog.csdn.net/weixin_ 42731241/article/details/96143934

Troubleshooting of ROS rosdep init / update

Problem description
operating system: ubuntu16.04/ubuntu18.04/ubuntu20.04
ROS version: kinetic / melodic / noetic
recently, I was learning how to install and use orb-slam2. During the compilation process, I found that the rosdep command is needed under ROS

sudo rosdep init

The following error is reported:

ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

Gu Yue bloggers have sorted out this problem, but according to the current network environment, there are still problems.
Reference article:
1 https://www.guyuehome.com/12640
https://blog.csdn.net/JanKin_ BY/article/details/105509383

The root cause is that the network is blocked. If the above articles are not helpful, please refer to the following solutions:
1. Take the computer to the University Campus (the suffix of the university website is edu.cn Use its campus network to use the rosdep command;
2. Try to use mobile hot spots (China Mobile, China Unicom and China Telecom).

Hope it helps!

Centos8 modifying the host name

When you modify the host name, you can directly use the tools provided by the system.  

[[email protected] centos]# hostnamectl
   Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 89bf177f78dc49f6b4954e1e9511e267
           Boot ID: 8f46edc8b7b648f58d5d4c1f3c15cbee
    Virtualization: vmware
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-240.10.1.el8_3.x86_64
      Architecture: x86-64
[[email protected] centos]# sudo hostnamectl set-hostname k8s-slave
[[email protected] centos]# hostnamectl
   Static hostname: k8s-slave
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 89bf177f78dc49f6b4954e1e9511e267
           Boot ID: 8f46edc8b7b648f58d5d4c1f3c15cbee
    Virtualization: vmware
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-240.10.1.el8_3.x86_64
      Architecture: x86-64
[[email protected] centos]# cat /etc/hostname 
k8s-slave
[[email protected] centos]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[[email protected] centos]# vi /etc/hosts
[[email protected] centos]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.187.151  k8s-slave
[[email protected] centos]#

 

“NPM err! Error: eperm: operation not permitted” problem solving

Solution of “NPM err! Error: eperm: operation not permitted”

 

Error occurred when NPM running Vue cli to create project under Windows system

npm ERR! Windows_ NT 10.0.14393
npm ERR! argv “C:\\Program Files\\nodejs\\ node.exe ” “C:\\Program Files\\nodejs\\node_ modules\\npm\\bin\\npm- cli.js ” “uninstall” “express” “-g”
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! path C:\Program Files\nodejs\node_ cache\_ locks
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall mkdir
npm ERR! Error: EPERM: operation not permitted, mkdir ‘C:\Program Files\nodejs\node_ cache\_ locks’
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, mkdir ‘C:\Program Files\nodejs\node_ cache\_ locks’
npm ERR!     at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: ‘EPERM’,
npm ERR!   syscall: ‘mkdir’,
npm ERR!   path: ‘C:\\Program Files\\nodejs\\node_ cache\\_ locks’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\admin\npm- debug.log
 

 

The key point is: operation not permitted.

 

Solution: use Win + X, select the command prompt (administrator), and run the command in it.
 

“ XX.app ”It is damaged and cannot be opened. You should move it to the wastebasket.

    MacOS Mojave 10.14 and the following systems:
    open the terminal.app, enter the following command and enter, enter the power on password and enter
    sudo spctl -- Master disable

    MacOS Catalina 10.15 system:
    open terminal.app, enter the following command and enter, enter the power on password and enter
    sudo xattr - Rd com.apple.quarantine Space software path
    such as Sketch.app
    sudo xattr -rd com.apple.quarantine /Applications/ Sketch.app
    Software path acquisition: drag the software into the “terminal app” to obtain the path

    MacOS Catalina 10.15.4 system:
    if the software exits unexpectedly after updating the 10.15.4 system, you can sign the software according to the following method
    1. Open the “terminal app” and enter the following command:
    Xcode select -- install
    2. Sign the software
    open the terminal tool and enter and execute the following command:
    sudo codesign -- force -- deep -- sign- (application path)

Integration openfeign failed to start

Using the open feign development interface, the direct startup fails, and the following exception is thrown:

nested exception is java.lang.IllegalStateException: No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

The problem is obviously that spring cloud starter loadbalancer is not added, so in the pom.xml Add the following dependencies to:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>

After re importing the dependency, it starts successfully, but the calling interface still reports an error:

java.lang.AbstractMethodError: org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.choose(Ljava/lang/String;Lorg/springframework/cloud/client/loadbalancer/Request;)Lorg/springframework/cloud/client/ServiceInstance;

This is because spring cloud replaces the load balancing component from ribbon to loadbalancer. You need to exclude the ribbon component in spring cloud starter Alibaba Nacos discovery, otherwise loadbalancer will not work.

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
        </exclusion>
    </exclusions>
</dependency>

After re importing the dependency, restart the project and call successfully.

Matlab: Three forms of random number generated (Rand, Randi and Randn)

There are three kinds of library functions about random number generation in MATLAB. Let’s take a look at their forms:
1, Rand (…) 
it is to generate pseudo-random numbers with uniform distribution between 0 and 1 (open-loop, excluding 0 and 1), that is, infinite tests, in which the probability of each number is the same.
its function format is as follows:

 R = rand(N)              % Generate an N×N matrix of random numbers, where each element lies between 0 and 1
 R = rand([M,N,P,...])    % Generate M×N×P×... of matrix random numbers
 R = rand(M,N,P,...)      % As above, the brackets are not required
 R = rand(... , CLASSNAME) % Generate a random number of type CLASSNAME, e.g. 'double' or 'single' 

for example, generate a double type of 5 × 3 evenly distributed random number between 0 and 1:

R = rand(5,3,'double');

similarly, we want to generate 100 data between [a, b], which can be expressed as:

R = a + (b-a).*rand(100,1);

2.randi(…)
Randi (n) is a pseudo-random number evenly distributed among the generated (0, n), and the numbers are all integers, so each number is between 1 and n. It can be expressed in the following ways:

R = randi(iMax)            % Generate a uniformly distributed random number between 1:iMax
R = randi(iMax,m,n) % Generate a uniformly distributed random number between 1:iMax for m×n
R = randi([iMin,iMax],m,n) % Generate a uniformly distributed random number between iMin:iMax for m×n

for example:

R1 = randi(10,5,1); % Generate a 5×1 random number between 1:10
R2 = randi([10,20],2,3); % Generate a 2×3 random number between 10:20

3.randn(… )
sometimes we want to generate random numbers with normal distribution instead of random distribution, so we need to use randn function. The overall probability of the random number generated by it is normal distribution, the mean value is 0, and the variance is 1. That is to say, the probability of 0 in the generated number is the largest, and the more infinite or negative infinite the probability is smaller, but the random number may be all real numbers, but the probability of occurrence is different. Its format is as follows:

R = randn(N)   % Generate N x N normally distributed random numbers
R = randn(M,N) % Generate M×N normally distributed random numbers

for example:

R = randi(3); % Generate 3×3 normally distributed random numbers

4. Stable restart distribution RNG
here, let’s see how to make the random number generated by each program run the same, mainly with the help of the Lang function, and the format is as follows: 1

rng('default');
R = rand(1,5); % Generate a constant 1×5 random number per program run

in addition, there are expressions that generate the same distribution:

s = rng;
R1 = rand(1,5);
rng(s);
R2 = rand(1,5); % R1 and R2 random numbers are the same

Latex: How to Set text Center

Click to view the original link

\centerline

Syntax: \centerline{text}
This is the original TeX command for centering short text.

center environment

Syntax
\begin{center}
First line \\\
second line \\\
\end{center}

The center environment allows multiple rows to be centered.
In the center environment, if the "first line" is too long, it will automatically wrap, and the text of the wrap is still centered, so this is a very common way to do it.