首页
📷在线壁纸
🎬娱乐天地
🔖友情链接
更多
📝留言板
Search
1
【javascript】JS-向当前url追加参数
2,345 阅读
2
【PHP】生成随机昵称
2,219 阅读
3
【PHP】判断一个字符串是否属于序列化后的数据
2,024 阅读
4
【css】html+css给文章页,做阅读全文
1,975 阅读
5
【PHP】 设计模式(23种)
1,910 阅读
📂默认分类
💓typecho
🏳️🌈代码改变世界
🍇 mysql
🍈 Winform
🍓 golang
🍉 设计模式
🥝 PHP
🍎 python
🍊 nginx
🍋 网络安全
🍍 javascript
🫑 database
🍭文艺范
🍏mac
AI
LLM
image
audio
yolo
3D
code
登录
Search
标签搜索
php
typecho
代码注释
redis
mysql
go
golang
nginx
thinkphp
docker
gin
linux
curl
html
mamp
算法
短网址
构造函数
webhook
代码片段
依然范儿特西
累计撰写
145
篇文章
累计收到
1
条评论
首页
栏目
📂默认分类
💓typecho
🏳️🌈代码改变世界
🍇 mysql
🍈 Winform
🍓 golang
🍉 设计模式
🥝 PHP
🍎 python
🍊 nginx
🍋 网络安全
🍍 javascript
🫑 database
🍭文艺范
🍏mac
AI
LLM
image
audio
yolo
3D
code
页面
📷在线壁纸
🎬娱乐天地
🔖友情链接
📝留言板
搜索到
145
篇与
的结果
2021-09-13
Mac终端采用mamp的PHP版本运行
查看环境变量,PHP运行的文件位置:which php终端输入,可能,bash_profile 文件并不存在,就创建新文件vi ~/.bash_profile然后把环境变量代码添加到bash_profile脚本里export PATH="/Applications/MAMP/bin/php/php7.2.22/bin:$PATH"执行文件,使起生效source ~/.bash_profile
2021年09月13日
130 阅读
0 评论
1 点赞
2021-09-03
linux 实现每秒执行&间隔 90分钟执行
前言linux crontab 命令,最小的执行时间是一分钟, 如果要在小于一分钟执行。就要换个方法来实现crontab 的延时:原理:通过延时方法 sleep N 来实现每N秒执行。crontab -e 输入以下语句,然后 :wq 保存退出。* * * * * /usr/bin/curl http://www.test.com * * * * * sleep 5; /usr/bin/curl http://www.test.com * * * * * sleep 10; /usr/bin/curl http://www.test.com * * * * * sleep 15; /usr/bin/curl http://www.test.com * * * * * sleep 20; /usr/bin/curl http://www.test.com * * * * * sleep 25; /usr/bin/curl http://www.test.com * * * * * sleep 30; /usr/bin/curl http://www.test.com * * * * * sleep 35; /usr/bin/curl http://www.test.com * * * * * sleep 40; /usr/bin/curl http://www.test.com * * * * * sleep 45; /usr/bin/curl http://www.test.com * * * * * sleep 50; /usr/bin/curl http://www.test.com * * * * * sleep 55; /usr/bin/curl http://www.test.com注意:60必须能整除间隔的秒数(没有余数),例如间隔的秒数是2,4,6,10,12等。如果间隔的秒数太少,例如2秒执行一次,这样就需要在crontab 加入60/2=30条语句。不建议使用此方法,可以使用下面介绍的第二种方法。2 shell 脚本实现原理:在sh使用for语句实现循环指定秒数执行。crontab.sh#!/bin/bash step=2 #间隔的秒数,不能大于60 for (( i = 0; i < 60; i=(i+step) )); do $(php '/home/fdipzone/php/crontab/tolog.php') sleep $step done exit 0 crontab -e 输入以下语句,然后:wq 保存退出。# m h dom mon dow command * * * * * /home/fdipzone/php/crontab/crontab.sh 使用以下命令查看结果tail -f run.log 注意:如果60不能整除间隔的秒数,则需要调整执行的时间。例如需要每7秒执行一次,就需要找到7与60的最小公倍数,7与60的最小公倍数是420(即7分钟)。则 crontab.sh step的值为7,循环结束条件i<420, crontab -e可以输入以下语句来实现# m h dom mon dow command */7 * * * * /home/fdipzone/php/crontab/crontab.sh 举一反三q : 如果需要间隔 90 分钟 执行一次,如何处理?a :把他扩大成 24小时 = 24 * 60 分钟执行次数 = 24*60 / 90 = 16也就是最大可执行 16次每次 sleep 90*60 秒即可实现 每间隔90分钟 执行一次代码实现:#!/bin/bash step=5400 #间隔的秒数 for (( i = 0; i < 16; i=(i+step) )); do $(php '/home/fdipzone/php/crontab/tolog.php') sleep $step done exit 0
2021年09月03日
736 阅读
2 评论
0 点赞
2021-09-01
Golang 获取https证书信息、过期信息
package main import ( "crypto/tls" "fmt" "net/http" ) func main() { tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } client := &http.Client{Transport: tr} seedUrl := "https://richerdyoung.com" resp, err := client.Get(seedUrl) defer resp.Body.Close() if err != nil { fmt.Errorf(seedUrl," 请求失败") panic(err) } //fmt.Println(resp.TLS.PeerCertificates[0]) certInfo:=resp.TLS.PeerCertificates[0] fmt.Println("过期时间:",certInfo.NotAfter) fmt.Println("组织信息:",certInfo.Subject) } 运行结果过期时间: 2021-09-02 07:27:20 +0000 UTC 组织信息: CN=www.richerdyoung.com
2021年09月01日
324 阅读
0 评论
1 点赞
2021-08-27
linux安装homebrew
安装命令/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"常用命令brew list # 查看已经安装的包 brew update # 更新Homebrew自身 brew doctor # 诊断关于Homebrew的问题(Homebrew 有问题时请用它) brew cleanup # 清理老版本软件包或者无用的文件 brew show ${formula} # 查看包信息 brew search ${formula} # 按名称搜索 brew upgrade ${formula} # 升级软件包 brew install ${formula} # 按名称安装 brew uninstall ${formula} # 按名称卸载 brew pin/unpin ${formula} # 锁定或者解锁软件包版本,防止误升级
2021年08月27日
119 阅读
0 评论
1 点赞
2021-08-26
python版本管理工具pyenv
项目地址https://github.com/pyenv/pyenv简介:python的版本管理工具:pyenv,他支持python多版本共存,并可以随时切换。且不会互相影响。centos7 安装pyenv:# 安装依赖 yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y # 安装pyenv包 git clone https://github.com/pyenv/pyenv.git ~/.pyenv # 设置环境变量 vim ~/.bashrc export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" :wq 保存退出!# 刷新配置 source ~/.bashrc # 即是启动语句,重启系统执行这条语句 exec bash查看结果:pyenv -h Usage: pyenv <command> [<args>] Some useful pyenv commands are: commands List all available pyenv commands exec Run an executable with the selected Python version global Set or show the global Python version(s) help Display help for a command hooks List hook scripts for a given pyenv command init Configure the shell environment for pyenv install Install a Python version using python-build local Set or show the local application-specific Python version(s) prefix Display prefix for a Python version rehash Rehash pyenv shims (run this after installing executables) root Display the root directory where versions and shims are kept shell Set or show the shell-specific Python version shims List existing pyenv shims uninstall Uninstall a specific Python version version Show the current Python version(s) and its origin --version Display the version of pyenv version-file Detect the file that sets the current pyenv version version-name Show the current Python version version-origin Explain how the current Python version is set versions List all Python versions available to pyenv whence List all Python versions that contain the given executable which Display the full path to an executable See `pyenv help <command>' for information on a specific command. For full documentation, see: https://github.com/pyenv/pyenv#readme 安装成功~简单的介绍一下常用的命令:pyenv install --list //查看可安装的python版本 pyenv install 3.5.7 //安装python3.5.7 pyenv rehash //更新数据库,在安装 Python 或者其他带有可执行文件的模块之后,需要对数据库进行更新: pyenv versions //查看当前使用的python版本 pyenv global 3.5.7 //切换python全局版本为3.5.7 pyenv uninstall 3.5.7 //卸载已安装的python3.5.7某个目录指定版本[root@richerdyoung.com mnt]# pyenv global system #将当前的全局Python版本还原到之前的版本 [root@richerdyoung.com mnt]# python -V #系统自带的Python版本 Python 2.7.5 [root@richerdyoung.com mnt]# pyenv version #检查 pyenv当前py 版本 system (set by /root/.pyenv/version) [root@richerdyoung.com mnt]# mkdir ops #创建一个测试目录 [root@richerdyoung.com mnt]# cd ops/ [root@richerdyoung.com ops]# pyenv local 3.5.7 #使用local子命令指定当前目录使用3.5.7版本 [root@richerdyoung.com ops]# pyenv local # 确认是否设置成功 3.5.7 [root@richerdyoung.com ops]# python -V #检查当前版本 Python 3.5.7 [root@richerdyoung.com ops]# cd #切换到其他目录 [root@richerdyoung.com ~]# python -V #再次检查Python版本 ops目录下版本为3.5.7 全局为2.7.5 符合预期 Python 2.7.5ps : 当直接执行安装命令时候,国内会报错,error: failed to download Python-3.5.7.tar.zx解决办法:在当前用户目录下 .pyenv/ 目录下创建 cache 目录,将下载好的 Python-3.5.7 的包放在该目录下,就不会去下载Python文件,直接执行安装,而不需要下载,节省下载时间举例: # 我的目录是 /root/.pyenv # 则下载好的python包 存放 ~/.pyenv/cache/Python-3.5.7 ~/.pyenv/cache/Python-3.5.8
2021年08月26日
135 阅读
0 评论
1 点赞
2021-08-11
这56个代码注释让我笑喷了
1/* * Dear Maintainer * * Once you are done trying to ‘optimize’ this routine, * and you have realized what a terrible mistake that was, * please increment the following counter as a warning * to the next guy. * * total_hours_wasted_here = 73 */ 亲爱的维护者 如果尝试对这段程序进行'优化' 并且您已经意识到这是一个多么可怕的错误, 请增加以下计数器的个数用来对后来人进行警告 这里总共浪费的时间= 73 2. //Exception up = new Exception("Something is really wrong."); //throw up; //ha ha 例外=新的异常("确实有问题。") 放弃; //哈哈 3.// When I wrote this, only God and I understood what I was doing // Now, God only knows 当我写下这个的时候,只有上帝和我明白我在做什么 现在,只有上帝知道4.// sometimes I believe compiler ignores all my comments 有时,我会相信编译器会忽略我所有的注释5.// I dedicate all this code, all my work, to my wife, Darlene, // who will have to support me and our three children and // the dog once it gets released into the public. 谨以此代码,献给我的妻子达琳,感谢她一直支持着我,以及我的三个孩子和一条狗。6.// drunk, fix later 喝多了,改天再修7.// Magic. Do not touch. 魔法!不要碰。8.// I'm sorry. 抱歉。9.return 1; # returns 1 返回 1;# 返回 110. Catch (Exception e) { //who cares? } 捕获(异常e) 谁在乎? 11./** * Always returns true. */ public boolean isAvailable() { return false; } 代码返回 false ,注释则始终返回 true12./* * You may think you know what the following code does. * But you dont. Trust me. * Fiddle with it, and youll spend many a sleepless * night cursing the moment you thought youd be clever * enough to "optimize" the code below. * Now close this file and go play with something else. */ 你可能相信你能看懂以下代码, 但是其实绝对不可能,相信我。 一旦你调试了,你绝对会后悔装聪明去尝试优化这段代码。 最好的方式是关闭文件, 去玩点儿你喜欢的东西吧! 13.try { } finally { // should never happen } 绝对不会运行到这里14.const int TEN=10; // As if the value of 10 will fluctuate... 好像 10 的值会波动... 15.// This code sucks, you know it and I know it. // Move on and call me an idiot later. 这段代码的确很烂,我知道你也知道, 先不要骂我,请先接着往下看16.// If this comment is removed the program will blow up 如果删了此处注释,程序就炸了 17.// I am not responsible of this code. // They made me write it, against my will. 我不负责这个代码 他们强迫我写,违背了我的意愿。18./* Please work */ 请工作19. // no comments for you // it was hard to write // so it should be hard to read 没有注释, 很难写, 所以它应该很难阅读 20. options.BatchSize = 300; //Madness? THIS IS SPARTA! 疯了吧?这是斯巴达! 21.// If this code works, it was written by Paul DiLascia. // If not, I don't know who wrote it 如果这个代码能够正常工作,那么是Paul DiLascia写的 否则,我也不知道是谁写的22.// Peter wrote this, nobody knows what it does, don't change it! 这是彼得写的,没人知道它是做什么的,别改动!23. /** Logger */ private Logger logger = Logger.getLogger(); 不管怎么费尽心力,人会受伤的时候就会受伤。by 村上春树24.// I have to find a better job 我必须找到更好的工作25.// Real programmers don’t comment their code. // If it was hard to write, // it should be hard to understand. 真正的程序员不注释他们的代码。 如果很难写 应该是难以理解 26.// This is black magic // from // *Some stackoverlow link // Don’t play with magic, it can BITE. 这是来自stackoverlow的黑魔法 别玩魔法,它会咬人的27.// For the sins I am about to commit, may James Gosling forgive me 对于我即将犯下的罪行,希望詹姆斯·高斯林(James Gosling)能原谅我27.// Comment this later 稍后对此注释29.// Remove this if you wanna be fired 如果你想被炒鱿鱼,就删除它30. try{ }catch(Exception ex){ // Houston, we have a problem } Houston,我们有一个问题31.// I can’t divide with zero, so I have to divide with something very similar result = number / 0.00000000000001. 我不能除以0,所以我要除以一个非常相似的数32.int getRandomNumber() { Return 4; // chosen by fair dice roll. // guaranteed to be random. } 通过公平掷骰子选择 保证是随机的 33.#TODO: Figure out what I’m doing here and comment accordingly. 弄清楚这里做什么并相应地添加注释34.// If this code is still being used when it stops working, then // you have my permission to shoot me. Oh, you won't be able // to - I'll be dead... 如果这段代码停止工作时还在使用, 杀了我吧,哦~你不能这么做 我死了......35.// If you are reading this, that means you have been put in charge of my previous project. // I am sorry, so sorry for you. Godspeed. 如果你看到了这里,这意味着你已经被任命为我之前的项目的负责人。 对不起,真抱歉。祝你好运。36.// I wrote this while drunk, I don’t know what it does, // but if you remove it the program breaks. 我是在喝醉的时候写的,所以不知道它是干什么用的 但如果你删除它,程序就会中断37.// This code worked before, but my cat decided to take a // trip across my keyboard... 这段代码以前是有效的,但是我的猫决定在我的键盘上跑一趟38.long long ago; /* in a galaxy far far away */ 在很远很远的银河系外 (这段代码能运行,绝对是个奇迹)39.long john; // silver 金银岛.40.#define TRUE FALSE // Happy debugging suckers 快乐的去调试你的代码吧,哈哈41.// Dear future me. Please forgive me. // I can't even begin to express how sorry I am. 未来亲爱的我,请原谅我 我说不出来我有多抱歉42.// private instance variable for storing age public static int age; 用于存储年龄的私有实例变量43.// I am not sure why this works but it fixes the problem. 虽然我不知道为什么这样管用,但它却是修复了问题44.last = first; /* Biblical reference */ 最后即是开始,圣经引用45.try { } catch (SQLException ex) { // Basically, without saying too much, you're screwed. Royally and totally. } catch(Exception ex){ //If you thought you were screwed before, boy have I news for you!!! } 不用多说,基本上你完蛋了46.// John! If you'll svn remove this once more, // I'll shut you, for God's sake! // That piece of code is not "something strange"! // That is THE AUTH VALIDATION. 如果你再删除一次 看在上帝的份上,我要关闭你 这段代码不是什么“奇怪的东西” 那就是身份验证47.long time; /* know C */ 过来很久时间才知道48. // Abandon all hope ye who enter beyond this point 入此门者了断希望 49./* Ah ah ah! You'll never understand why this one works. */ 啊啊啊!你永远都不会明白为什么这个方法有效 50.try{ }catch (Ex as Exception) { // oh crap, we should do something. } 糟糕,我们应该做点什么51.// TODO make this work 用TODO做这件事 52.// If you're reading this, then my program is probably a success 如果你现在在认真详细的阅读这段代码,那么写的这段代码应该是没有问题的53.// set break point here - you'll never reach it 在这里设置断点-你永远作不到十全十美54./* ** The author disclaims copyright to this source code. ** In place of a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. */ 作者放弃此源代码的版权 这是一份祝福,而不是法律通知 愿你行善不作恶。 愿你宽恕自己,宽恕他人 愿你自由分享,永远不要超过付出55.// I'm not sure what I did 我不确定我做了什么56.// This is crap code but it's 3 a.m. and I need to get this working. 这是垃圾代码,但现在是凌晨3点,我需要让他能够正常运行
2021年08月11日
180 阅读
0 评论
0 点赞
2021-07-20
微信支付报错dial tcp [240e:e1:a900:50::49]:443: connect: network is unreachable
在使用商家扫码付款 提示错误信息 https://api.mch.weixin.qq.com/pay/micropay\": dial tcp [240e:e1:a900:50::49]:443: connect: network is unreachable。 解决办法是: 自己的代码服务器 禁用掉 ipv6
2021年07月20日
170 阅读
0 评论
2 点赞
2021-07-08
TP3.2框架中如何使用多个mysql函数 如FIND_IN_SET 和 !FIND_IN_SET
数据查询中可能会用到数据表中的多个字段去做匹配 可能会用到多个FIND_IN_SET 也可能需要拼接多个条件$user_ids = [1,2,3]; //获取需要匹配的值 if ($user_ids ){ foreach ($user_ids as $val){ $map[] = " FIND_IN_SET($val,show_user_id) "; } } $where['_string'] = implode(" OR ",$map); # 预览sql效果: WHERE FIND_IN_SET('1', show_user_id) OR FIND_IN_SET('2', show_user_id) OR FIND_IN_SET(3, show_user_id) 但是如果我们想除了这个函数还有其他函数要使用的时候并且$where['_string']已经被使用的时候怎么拼接? $where['_logic'] = 'or';//and 或者 OR 就是看你的需要 $map['_string'] = " !FIND_IN_SET(4,show_user_id) "; $where['_complex'] = $map; # 预览sql效果: WHERE FIND_IN_SET('1', show_user_id) OR FIND_IN_SET('2', show_user_id) OR FIND_IN_SET(3, show_user_id) AND ( ( !FIND_IN_SET(4, show_user_id) //就是与FIND_IN_SET相反的意思 ) )
2021年07月08日
180 阅读
0 评论
1 点赞
2021-07-07
微信小程序播放视频卡顿问题
一、默认初次加载卡顿情况明显微信小程序使用video组件播放视频的时候,会出现卡顿或者无法播放的问题,加一个custom-cache=”{{false}}“即可解决,这个属性文档上没有,是从小程序开发社区中get到的<video src="{{url}}" id="videoOne" custom-cache="{{false}}"> </video>二、视频卡顿,还有一种情况就是视频内容画面分辨率太大。解决方案:使用视频压缩工具,处理视频内容,建议720P就可以了。如果以上问题还不能解决。可以尝试提交代码片段给官方处理https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
2021年07月07日
834 阅读
0 评论
2 点赞
2021-07-05
【laravel】 操作文件上传
1、获取上传的文件$file=$request->file('file');2、获取上传文件的文件名(带后缀,如abc.png)$filename=$file->getClientOriginalName();3、获取上传文件的后缀(如abc.png,获取到的为png)$fileextension=$file->getClientOriginalExtension();4、获取上传文件的大小$filesize=$file->getClientSize();5、获取缓存在tmp目录下的文件名(带后缀,如php8933.tmp)$filaname=$file->getFilename();6、获取上传的文件缓存在tmp文件夹下的绝对路径$realpath=$file->getRealPath();7、将缓存在tmp目录下的文件移到某个位置,返回的是这个文件移动过后的路径$path=$file->move(path,newname);move()方法有两个参数,第一个参数是文件移到哪个文件夹下的路径,第二个参数是将上传的文件重新命名的文件名8、检测上传的文件是否合法,返回值为true或false$file->isValid()
2021年07月05日
182 阅读
0 评论
0 点赞
1
...
7
8
9
...
15