分类 成长之路 中的文章

lumen cors跨域问题

1,创建CrossHttp中间件 <?php /** * Created by PhpStorm. * User: cnbattle * Date: 18-10-22 * Time: 下午12:40 */ namespace App\Http\Middleware; use Closure; class CrossHttp { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($request->getMethod() == "OPTIONS") { $allowOrigin = [ 'http://admin.580xb.cn', ]; $Origin = $request->header("Origin"); if (in_array($Origin, $allowOrigin)) { return response()->json('ok', 200, [ # 下面参数视request中header而定 'Access-Control-Allow-Origin' => $Origin, 'Access-Control-Allow-Headers' => 'x-requested-with,content-type,Authorization,CityCode', 'Access-Control-Allow-Methods' => 'POST,DELETE,GET,PUT,OPTIONS']); } else { return response()->json('fail', 405); } } $response = $next($request); $response->header('Access-Control-Allow-Origin', '*'); return $response; } } 2……

阅读全文

HTTP状态码大全

1xx:信息响应类,表示接收到请求并且继续处理 2xx:处理成功响应类,表示动作被成功接收、理解和接受 3xx:重定向响应类,为了完成指定的动作,必须接受进一步处理 4xx:客户端错误,客户请求包含语法错误或者是不能正确执行 5xx:服务端错误,服务器不能正确执行一个正确的请求 1xx(信……

阅读全文

linux crontab命令详解

crontab命令被用来提交和管理用户的需要周期性执行的任务,与windows下的计划任务类似,当安装完成操作系统后,默认会安装此服务工具,并且会自动启动crond进程,crond进程每分钟会定期检查是否有要执行的任务,如果有要执行的任务,则自动执行该任务。 #语法 crontab(……

阅读全文

oneinstack helper

oneinstack help ./install.sh version: 1.7 updated date: 2018-04-20 Usage: ./install.sh command ...[parameters].... --help, -h Show this help message, More: https://oneinstack.com/auto --version, -v Show version info --nginx_option [1-3] Install Nginx server version --apache_option [1-2] Install Apache server version --php_option [1-7] Install PHP version --phpcache_option [1-4] Install PHP opcode cache, default: 1 opcache --php_extensions [ext name] Install PHP extension, include zendguardloader,ioncube,imagick,gmagick --tomcat_option [1-4] Install Tomcat version --jdk_option [1-4] Install JDK version --db_option [1-15] Install DB version --dbinstallmethod [1-2] DB install method, default: 1 binary install --dbrootpwd [password] DB super password --pureftpd Install Pure-Ftpd --redis Install Redis --memcached Install Memcached --phpmyadmin Install phpMyAdmin --hhvm Install HHVM --ssh_port [22] SSH port, default: 22 --iptables Enable iptables --reboot Restart the server after installation ./vhost.sh Usage: ./vhost.sh [ add | del | list | dnsapi ] add --->Add Virtualhost del --->Delete Virtualhost list --->List Virtualhost dnsapi……

阅读全文

两种判断shell执行用户是否为root用户

方式一: # Check if user is root if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script, please use root to run" exit 1 fi 方式二: # Check if user is root [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }……

阅读全文

统计代码git提交的行数

统计某人的代码提交量,包括增加,删除: git log --author="$(git config --get user.name)" --pretty=tformat: --numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' - 仓库提交者排名前 5(如果看全部,去掉 head 管道即可): git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5 仓库提交者(邮箱)排名前 5:这个统计可能不会太准,因为很多人有不同的邮箱,但会……

阅读全文

Go语言(golang)包设计哲学/原则与项目结构组织最佳实践

总结下Go的package设计哲学 明确目的 在准备设计一个包之前,我们需要明确它的目的。 包的命名就必须明确体现其目的,而不仅仅是为了存放代码。像标准库的io,http,fmt这些包名就很好,而像util.helper,common这种命名就是反面教材。 可用性 想想使用这个包的人真正的……

阅读全文

最近文章

分类

标签

友情链接

其它