首页
📷在线壁纸
🎬娱乐天地
🔖友情链接
更多
📝留言板
Search
1
【javascript】JS-向当前url追加参数
2,345 阅读
2
【PHP】生成随机昵称
2,202 阅读
3
【PHP】判断一个字符串是否属于序列化后的数据
2,024 阅读
4
【css】html+css给文章页,做阅读全文
1,975 阅读
5
【PHP】 设计模式(23种)
1,909 阅读
📂默认分类
💓typecho
🏳️🌈代码改变世界
🍇 mysql
🍈 Winform
🍓 golang
🍉 设计模式
🥝 PHP
🍎 python
🍊 nginx
🍋 网络安全
🍍 javascript
🫑 database
🍡 AI
🍭文艺范
🍏mac
登录
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
🍡 AI
🍭文艺范
🍏mac
页面
📷在线壁纸
🎬娱乐天地
🔖友情链接
📝留言板
搜索到
124
篇与
的结果
2021-09-21
tree命令输出目录树层结构
你也想要生成这个目录树层结构吗?,按下面操作即可:. ├── etc │ └── greet-api.yaml ├── go.mod ├── go.sum ├── greet.api ├── greet.go └── internal ├── config │ └── config.go ├── handler │ ├── greethandler.go │ └── routes.go ├── logic │ └── greetlogic.go ├── svc │ └── servicecontext.go └── types └── types.go 7 directories, 11 files 1 、安装 tree# mac 下使用 brew包管理工具 brew install tree # linux 下使用yum安装 yum install tree2、 安装成功后,直接在终端使用,使用 --help 查看帮助信息tree --help看到如下功能usage: tree [-acdfghilnpqrstuvxACDFJQNSUX] [-H baseHREF] [-T title ] [-L level [-R]] [-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes] [--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset] [--filelimit[=]#] [--si] [--timefmt[=]<f>] [--sort[=]<name>] [--matchdirs] [--ignore-case] [--] [<directory list>] ------- Listing options ------- -a All files are listed. -d List directories only. -l Follow symbolic links like directories. -f Print the full path prefix for each file. -x Stay on current filesystem only. -L level Descend only level directories deep. -R Rerun tree when max dir level reached. -P pattern List only those files that match the pattern given. -I pattern Do not list files that match the given pattern. --ignore-case Ignore case when pattern matching. --matchdirs Include directory names in -P pattern matching. --noreport Turn off file/directory count at end of tree listing. --charset X Use charset X for terminal/HTML and indentation line output. --filelimit # Do not descend dirs with more than # files in them. --timefmt <f> Print and format time according to the format <f>. -o filename Output to file instead of stdout. -------- File options --------- -q Print non-printable characters as '?'. -N Print non-printable characters as is. -Q Quote filenames with double quotes. -p Print the protections for each file. -u Displays file owner or UID number. -g Displays file group owner or GID number. -s Print the size in bytes of each file. -h Print the size in a more human readable way. --si Like -h, but use in SI units (powers of 1000). -D Print the date of last modification or (-c) status change. -F Appends '/', '=', '*', '@', '|' or '>' as per ls -F. --inodes Print inode number of each file. --device Print device ID number to which each file belongs. ------- Sorting options ------- -v Sort files alphanumerically by version. -t Sort files by last modification time. -c Sort files by last status change time. -U Leave files unsorted. -r Reverse the order of the sort. --dirsfirst List directories before files (-U disables). --sort X Select sort: name,version,size,mtime,ctime. ------- Graphics options ------ -i Don't print indentation lines. -A Print ANSI lines graphic indentation lines. -S Print with CP437 (console) graphics indentation lines. -n Turn colorization off always (-C overrides). -C Turn colorization on always. ------- XML/HTML/JSON options ------- -X Prints out an XML representation of the tree. -J Prints out an JSON representation of the tree. -H baseHREF Prints out HTML format with baseHREF as top directory. -T string Replace the default HTML title and H1 header with string. --nolinks Turn off hyperlinks in HTML output. ---- Miscellaneous options ---- --version Print version and exit. --help Print usage and this help message and exit. -- Options processing terminator. 3、 输出你的树层目录结构cd 目标文件夹路径然后 tree 一下,会将该层级下所有文件都遍历了输出,不管层级多深4、 常用技巧我们可以在目录遍历时使用 -L 参数指定遍历层级tree -L 2如果你想把一个目录的结构树导出到文件 Readme.md ,可以这样操作tree -L 2 >README.md //然后我们看下当前目录下的 README.md 文件只显示文件夹tree -d 显示项目的层级,n表示层级数。例:显示项目三层结构,tree -l 3;tree -L n tree -I pattern 用于过滤不想要显示的文件或者文件夹。比如要过滤项目中的node_modules文件夹;tree -I “node_modules”
2021年09月21日
124 阅读
0 评论
2 点赞
2021-09-18
markdown折叠内容语法
如题,语法是:<details> <summary>Title</summary> content!!! </details> 举例 <details> <summary>CLICK ME</summary> **<summary>标签与正文间一定要空一行!!!** </details>
2021年09月18日
160 阅读
0 评论
0 点赞
2021-09-14
清除谷歌浏览器的dns缓存
清除谷歌浏览器的dns缓存
2021年09月14日
160 阅读
0 评论
2 点赞
2021-09-13
mac下为MAMP添加php扩展msgpack
查看最新的扩展版本https://pecl.php.net/package/msgpackPHP7.2.22 的文件夹地址/Applications/MAMP/bin/php/php7.2.22wget -c https://pecl.php.net/get/msgpack-0.0.1.tgz tar zxvf msgpack.tgz cd msgpack /Applications/MAMP/bin/php/php7.2.22/bin/phpize ./configure --with-php-config=/Applications/MAMP/bin/php/php7.2.22/bin/php-config make && make install vi /Applications/MAMP/bin/php/php7.2.22/etc/php.ini #加上一行 extension=msgpack.so # 重启下php # php -m 验证
2021年09月13日
132 阅读
0 评论
2 点赞
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 点赞
1
...
5
6
7
...
13