[Solved] configure: error: C++ preprocessor “/lib/cpp” fails sanity check

configure: error: C++ preprocessor “/lib/cpp” fails sanity check

The root of the problem is the lack of necessary C++ libraries.

If it is a CentOS system, run the following command to solve:

   yum install glibc-headers
  
   yum install gcc-c++ 

In Ubuntu system, run the command:

   apt-get install build-essential 
 
   apt-get install g++

Mac installs the php Swoole extension and appears Enable openssl support, require openssl library or fatal error:’openssl/ssl.h’ file not found

When installing php Swoole extend Mac Enable openssl support, require openssl libraryor fatal error: 'openssl/ssl.h' file not foundwhen specifying the opensslpath just fine

./configure --with-openssl-dir=/usr/local/opt/openssl@1.1 --enable-http2 --with-php-config=/Applications/MAMP/bin/php/php7.4.2/bin/php-config

The OpenSSL installed by brew is by default /usr/local/Cellar/openss/version, and I will report fatal error: 'openssl/ssl.h' file not foundan error after using it . Probably my openssl installation path is in/usr/local/opt/[email protected]

Golang timer function executes a function every few minutes

Delay calling AfterFunc

go function()
 
 
func function() {
	// TODO Specific logic
 
	// executed every 5 minutes, recursively calling itself
	time.AfterFunc(5*time.Minute, function)
}

Tickers

package main

import "time"
import "fmt"

func main() {

    // The mechanism of a punter and a timer is somewhat similar: a channel is used to send data. </span
    // Here we use the built-in `range` on this channel to iterate over the values every
    // The value sent once in 500ms.
    ticker := time.NewTicker(time.Millisecond * 500)
    go func() {
        for t := range ticker.C {
            fmt.Println("Tick at", t)
        }
    }()

    // The punctuator can be stopped in the same way as the timer. </span
    // Once a punctuation is stopped, it will no longer be able to receive values from its channel. 
    // We will stop this punter after 1600ms of running.
    time.Sleep(time.Millisecond * 1600)
    ticker.Stop()
    fmt.Println("Ticker stopped")
}

When we run this program, the dotter will do 3 times before we stop it.

go run tickers.go
Tick at 2012-09-23 11:29:56.487625 -0700 PDT
Tick at 2012-09-23 11:29:56.988063 -0700 PDT
Tick at 2012-09-23 11:29:57.488076 -0700 PDT
Ticker stopped

PHP solves the problem that composer exceeds the memory size Allowed memory size

Preface

Today, when I used composer to update and install the expansion pack, it reported that the memory size was exceeded

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/Rule2Literals.php on li
ne 53

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.

Solution

First execute the composer help command to obtain the composer installation directory

composer -h

Results of the

D:\php_work\fund-admin>composer -h
Usage:
  help [options] [--] [<command_name>]

Arguments:
  command                        The command to execute
  command_name                   The command name [default: "help"]

Options:
      --xml                      To output help as XML
      --format=FORMAT            The output format (txt, xml, json, or md) [default: "txt"]
      --raw                      To output raw command help
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  The help command displays help for a given command:

    php C:\ProgramData\ComposerSetup\bin\composer.phar help list

  You can also output the help in other formats by using the --format option:

    php C:\ProgramData\ComposerSetup\bin\composer.phar help --format=xml list

  To display the list of available commands, please use the list command.

I can see C:\ProgramData\ComposerSetup\bin\composer.pharmy composer installation directory

At this time, the installation extension command is modified to

# php -d memory_limit=-1 php program set memory unlimited
# C:\ProgramData\ComposerSetup\bin\composer.phar composer install url
# require dcat/laravel-admin:"2.*" -vvv Loading expansion packs
php -d memory_limit=-1 C:\ProgramData\ComposerSetup\bin\composer.phar require dcat/laravel-admin:"2.*" -vvv

[Solved] cnpm: Cannot load the file C:\Users\Raytine\AppData\Roaming\npm\cnpm.ps1 because running scripts is prohibited on this system

Solution:

1. Enter Windos PowerShell in the search box in the system

2. Click “Run as Administrator”

3. Enter “set-ExecutionPolicy RemoteSigned” and press Enter

4. According to the prompt, enter A and press Enter

5. Return to cnpm -v again to execute successfully.

Not only cnpm commands, including pnpm, yarn and other commands, if such an error is reported when executed, it can be solved by this method. The premise is that if you use the npm command to install these CLI command tools, they must be installed in the global environment to take effect.

[Solved] websocket: the client is not using the websocket protocol: ‘upgrade’ token not found in ‘Connection’ head

Error analysis

websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' head

WebSocketThis problem occurs when the reverse proxy or load balancer is not delivering the request correctly.

solution

Nginx plus the following analysis

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade

Apache plus the following analysis

 <Location /ws>
     ProxyPass ws://localhost:8000
     ProxyPassReverse ws://localhost:8000/
 </Location>

How to Solve MYSQL Error: Failed to start MySQL 8.0 database server

the reason

It appears in the mysql error log: The innodb_system data file’ibdata1′ must be writable, literally: ibdata1 must be writable

Check the log and report an error, the folder has no write permission

cat /var/log/mysqld.log

solve

Find file path

find / -name ibdata1

Grant folder permissions

chmod -R 777 /var/lib/mysql
chown mysql:mysql -R /var/lib/mysql

Start MySQL

systemctl start mysqld.service
// CHECK MySQL STATUS
systemctl status mysqld.service

Golang: How to determine structure whether it is empty

Preface

Using any programming language will encounter the problem of nullification, so how does Golang determine the nullability of a custom structure type?

In fact, the empty structure is not a simple comparison with nil. Please look at the following two methods:

package main

import (
	"fmt"
	"reflect"
)

type A struct {
	name string
	age  int
}

func (a A) IsEmpty() bool {
	return reflect.DeepEqual(a, A{})
}

func main() {
	var a A

	if a == (A{}) { // Brackets cannot be removed
		fmt.Println("a == A{} empty")
	}

	if a.IsEmpty() {
		fmt.Println("reflect deep is empty")
	}
}