laravel Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()

原因是没有开启openssl扩展。

不过,在windows环境下还有一个需要注意的,就是php.ini文件中extension_dir需要修改为绝对路径,

如下:

extension_dir="C:\phpstudy_pro\Extensions\php\php7.4.3nts\ext"
Go语言教程之边写边学:数据结构与算法:Floyd–Warshall多源最短路径

Floyd-Warshall算法(英语:Floyd-Warshall algorithm),中文亦称弗洛伊德算法,是解决任意两点间的最短路径的一种算法,可以正确处理有向图或负权(但不可存在负权回路)的最短路径问题,同时也被用于计算有向图的传递闭包。Floyd-Warshall算法的时间复杂度为O(N3),空间复杂度为O(N2),因时间复杂度比较高,不适合计算大量数据。

示例代码:

package main
 
import (
    "fmt"
    "math"
)
 
type graph struct {
    to int
    wt float64
}
 
func floydWarshall(g [][]graph) [][]float64 {
    dist := make([][]float64, len(g))
    for i := range dist {
        di := make([]float64, len(g))
        for j := range di {
            di[j] = math.Inf(1)
        }
        di[i] = 0
        dist[i] = di
    }
    for u, graphs := range g {
        for _, v := range graphs {
            dist[u][v.to] = v.wt
        }
    }
    for k, dk := range dist {
        for _, di := range dist {
            for j, dij := range di {
                if d := di[k] + dk[j]; dij > d {
                    di[j] = d
                }
            }
        }
    }
    return dist
}
 
func main() {
    gra := [][]graph{        
        1: {{2, 3}, {3, 8},{5, -4}},
        2: {{4, 1}, {5, 7}},
        3: {{2, 4}},
		4: {{1, 2}, {3, -5}},
		5: {{4, 6}},
    }
		
    dist := floydWarshall(gra)
	//dist[][] will be the output matrix that will finally
    //have the shortest distances between every pair of vertices
    for _, d := range dist {
        fmt.Printf("%4g\n", d)
    }
}

输出:

[   0 +Inf +Inf +Inf +Inf +Inf]
[+Inf    0    1   -3    2   -4]
[+Inf    3    0   -4    1   -1]
[+Inf    7    4    0    5    3]
[+Inf    2   -1   -5    0   -2]
[+Inf    8    5    1    6    0]
CORS是如何实现的

CORS的实现主要通过以下步骤:

  1. 浏览器发出CORS请求,在头信息中添加一个Origin字段,用来说明请求来自哪个源。
  2. 服务器根据这个值,决定是否同意这次请求。如果服务器许可,则服务器返回的响应中会多出Access-Control-字段。
  3. 如果需要发送cookies,则需要服务器指定Access-Control-Allow-Credentials字段,需要在ajax请求中打开withCredentials属性。
php imagck读取pdf错误:attempt to perform an operation not allowed by the security policy PDF

这是ImageMagic中有权限配置文件,需要修改PDF相关的读写权限。

# 打开policy.xml文件

sudo nano /etc/ImageMagick-6/policy.xml

# 修改PDF相关权限,由none改为read|write

<policy domain="coder" rights="none" pattern="PDF" />

# 改为

<policy domain="coder" rights="read|write" pattern="PDF" />

 

linux 创建mysql用户以及同名数据库并授权的shell脚本
#!/bin/bash

username="wp_$1"
password=$2

mysql -uroot -e "CREATE USER '${username}'@'%' IDENTIFIED BY '${password}'"

mysql -uroot -e "CREATE DATABASE IF NOT EXISTS ${username}"

mysql -uroot -e "GRANT ALL PRIVILEGES ON ${username}.* TO ${username}@'%'"

mysql -uroot -e "FLUSH PRIVILEGES"

 

以上命令中省略了 -p部分。为了安全在mysql配置文件中[client]下配置user和password即可。

linux shell脚本生成一个指定内容的php文件
#!/bin/bash

# 定义PHP文件内容
php_content='<?php echo "Hello, World!"; ?>'

# 定义要生成的PHP文件名
php_file_name="hello.php"

# 创建并写入PHP文件
echo "$php_content" > "$php_file_name"

# 检查是否成功创建PHP文件
if [ $? -eq 0 ]; then
  echo "PHP文件生成成功!"
else
  echo "生成PHP文件失败。"
fi
linux bash中生成随机字符串

在Linux Bash中,可以使用以下脚本生成随机字符串:

bash#!/bin/bash

# 生成随机字符串的长度
length=10

# 生成随机字符串
rand_str=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $length | head -n 1)

# 输出随机字符串
echo $rand_str

这个脚本会从 /dev/urandom 中获取随机数据,使用 tr 命令过滤出只包含大小写字母和数字的字符,然后使用 fold 命令将字符截断到指定长度,最后使用 head 命令只取第一行作为随机字符串。你可以根据需要修改脚本以生成不同长度的随机字符串。

linux bash shell文件错误:xxx.sh: line 2: $‘\r‘: command not found

出现这种问题是因为windows下的文件换行用的是\r\n 而linux系统用的是\n,如果win下的文档上传到linux,每行的结尾都会出现一个M(M是ctrl+v,ctrl+m)

 

vim xxx.sh #编辑查看 处理的文件
set ff=unix #设置文件格式
:wq #保存

  • 当前日期:
  • 北京时间:
  • 时间戳:
  • 今年的第:17周
  • 我的 IP:3.149.241.32
农历
五行
冲煞
彭祖
方位
吉神
凶神
极简任务管理 help
+ 0 0 0
Task Idea Collect