2022年9月8日

linux删除session文件

摘要: #!/bin/sh find /var/lib/php5 -type f -mtime +2 -exec rm -f {} \; -type f是指定文件类型为普通文件。 -mtime +2是指修改时间距离现在2天的文件。 -2是指修改时间距离现在不足2天的文件 -exec rm -f指执行删除匹配 阅读全文

posted @ 2022-09-08 10:08 小馬過河﹎ 阅读(98) 评论(0) 推荐(0)

php过滤回车/换行符

摘要: 不推荐 str_replace(PHP_EOL, '', $str); 推荐 preg_replace("/[\r\n]+/", '', $str); trim()函数也可以过滤所有两边的空格和特殊字符 \trim($str); 阅读全文

posted @ 2022-09-08 10:05 小馬過河﹎ 阅读(82) 评论(0) 推荐(0)

记一次curl无返回值的调试

摘要: 问题 php curl 执行post发现无返回值 调试 直接输出后发现是乱码 curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); 解决 核心代码 $output = mb_convert_encoding($output, 'UTF-8', 'UTF-8 阅读全文

posted @ 2022-09-08 09:52 小馬過河﹎ 阅读(902) 评论(0) 推荐(0)

CentOS 扩容系统盘&挂载数据盘

摘要: 系统盘扩容 yum install -y cloud-utils-growpart growpart /dev/vda 1 xfs_growfs / 宝塔面板挂载数据盘 yum install wget -y && wget -O auto_disk.sh http://download.bt.cn 阅读全文

posted @ 2022-09-08 09:47 小馬過河﹎ 阅读(18) 评论(0) 推荐(0)

2022年9月7日

从数组中获取随机元素

摘要: JavaScript const sample = arr => arr[Math.floor(Math.random() * arr.length)] Examples sample([3, 7, 9, 11]) // 9 阅读全文

posted @ 2022-09-07 11:02 小馬過河﹎ 阅读(13) 评论(0) 推荐(0)

计算两个或多个数字的平均值

摘要: JavaScript const avg = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length Examples avg(...[1, 2, 3]) // 2 avg(1, 2, 3) // 2 阅读全文

posted @ 2022-09-07 10:55 小馬過河﹎ 阅读(37) 评论(0) 推荐(0)

从数组中删除虚假值

摘要: 过滤掉虚假值:false, null, 0, "", undefined, NaN JavaScript const compact = arr => arr.filter(Boolean) Examples compact([0, 1, false, 2, '', 3, 'a', 'e' * 23 阅读全文

posted @ 2022-09-07 10:31 小馬過河﹎ 阅读(14) 评论(0) 推荐(0)

计算两个或多个数字/数组的总和

摘要: JavaScript const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0) Examples sum(1, 2, 3, 4) // 10 sum(...[1, 2, 3, 4]) // 10 阅读全文

posted @ 2022-09-07 10:18 小馬過河﹎ 阅读(22) 评论(0) 推荐(0)

统计数组中某个值出现的次数

摘要: JavaScript const countOccurrences = (arr, val) => arr.reduce((a, v) => (v val ? a + 1 : a), 0) Examples countOccurrences([1, 1, 2, 1, 2, 3], 1) // 3 阅读全文

posted @ 2022-09-07 10:15 小馬過河﹎ 阅读(31) 评论(0) 推荐(0)

获取2个数组的交集

摘要: JavaScript const intersection = (a, b) => { const s = new Set(b) return [...new Set(a)].filter(x => s.has(x)) } Examples intersection([1, 2, 3], [4, 3 阅读全文

posted @ 2022-09-07 10:09 小馬過河﹎ 阅读(15) 评论(0) 推荐(0)

导航

点击右上角即可分享
微信分享提示