分享一个查看大文件的软件(日志查看)
分享一个大文件查看软件 唯一缺点就是无法编辑 文档介绍可以处理4G的日志 没试过那么大 但是几百兆的日志文件还是可以做到秒开
分享一个大文件查看软件 唯一缺点就是无法编辑 文档介绍可以处理4G的日志 没试过那么大 但是几百兆的日志文件还是可以做到秒开
最近总是看到mysql查询的结果后面抛出错误:
ERROR:
No query specified
出现此错误是sql不合法原因:
\G后面不能再加分号;,因为\G在功能上等同于加了;,如果再加分号,那么就是;;(2个分号),就会出现SQL语法错误。
例:
$where['uid'] = array('eq',$uid);
$where['rid'] = array('eq',$rid);
$where['_logic'] = 'or';
$map['_complex'] = $where;
$map['Type'] = $type;
用单引号代替双引号来包含字符串,这样做会更快一些。因为PHP会在双引号包围的字符串中搜寻变量,单引号则 不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册中说echo是语言结构,不是真正的函数,故把函数加 上了双引号)。
1、如果能将类的方法定义成static,就尽量定义成static,它的速度会提升将近4倍。
2、$row[’id’] 的速度是$row[id]的7倍。
3、echo 比 print 快,并且使用echo的多重参数(译注:指用逗号而不是句点)代替字符串连接,比如echo $str1,$str2。
4、在执行for循环之前确定最大循环数,不要每循环一次都计算最大值,最好运用foreach代替。
5、注销那些不用的变量尤其是大数组,以便释放内存。
6、尽量避免使用__get,__set,__autoload。
7、require_once()代价昂贵。
8、include文件时尽量使用绝对路径,因为它避免了PHP去include_path里查找文件的速度,解析操作系统路径所需的时间会更少。
9、如果你想知道脚本开始执行(译注:即服务器端收到客户端请求)的时刻,使用$_SERVER[‘REQUEST_TIME’]要好于time()。
10、函数代替正则表达式完成相同功能。
11、str_replace函数比preg_replace函数快,但strtr函数的效率是str_replace函数的四倍。
12、如果一个字符串替换函数,可接受数组或字符作为参数,并且参数长度不太长,那么可以考虑额外写一段替换代码,使得每次传递参数是一个字符,而不是只写一行代码接受数组作为查询和替换的参数。
13、使用选择分支语句(译注:即switch case)好于使用多个if,else if语句。
14、用@屏蔽错误消息的做法非常低效,极其低效。
15、打开apache的mod_deflate模块,可以提高网页的浏览速度。
16、数据库连接当使用完毕时应关掉,不要用长连接。
17、错误消息代价昂贵。
18、在方法中递增局部变量,速度是最快的。几乎与在函数中调用局部变量的速度相当。
19、递增一个全局变量要比递增一个局部变量慢2倍。
20、递增一个对象属性(如:$this->prop++)要比递增一个局部变量慢3倍。
# 将本地分支的更新,推送到远程主机
git push <远程主机名> <本地分支名>:<远程分支名>
# 将本地的master分支推送到origin主机的master分支。如果master不存在,则会被新建。
git push origin master
# 如果省略本地分支名,则表示删除指定的远程分支,因为这等同于推送一个空的本地分支到远程分支
git push origin :master
# 等同于
git push origin --delete master
# 将所有本地分支都推送到origin主机
git push --all origin
# git push不会推送标签(tag),除非使用–tags选项
git push origin --tags
# 推送tag
git push origin tag_name
# 删除远程标签
git push origin :tag_name
简单的给按钮加上确认弹框
下面是删除所有标签按钮例子(附TP5跳转地址):
<a href="javascript:if(confirm('确定删除所有标签?'))location='{:url('Tag/delall')}'">删除所有标签</a>
控制器代码
public function viewbug(){
$where = array();
$name = '';
if (Request::instance()->isPost()) {
$name = $_POST['playerName'];
$where['playerName'] = array('like',"%$name%");
}
$count = Db::name('ygo_bug')->where($where)->count();
$bugs = Db::name('ygo_bug')->where($where)->order('id desc')->paginate(100);
$this->assign('count',$count);
$this->assign('name',$name);
$this->assign('bugs',$bugs);
return $this->fetch();
}
html代码
<div class="hui-pager hui-pager-center" style="padding:10px 30px;">{$bugs->render()}</div>
css代码
<style>
.pagination { display: inline-block; padding-left: 0; margin: 20px 0; border-radius: 4px; }
.pagination li { display: inline; }
.pagination li a,.pagination li span { position: relative; float: left; padding: 6px 12px; margin-left: -1px; line-height: 1.428571429; text-decoration: none; background-color: #fff; border: 1px solid #ddd; }
.pagination li:first-child a { margin-left: 0; border-bottom-left-radius: 4px; border-top-left-radius: 4px; }
.pagination li:last-child a { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.pagination li a:hover, .pagination li a:focus { background-color: #eee; }
.pagination .active span, .pagination .active span:hover, .pagination .active span:focus { z-index: 2; color: #fff; cursor: default; background-color: #428bca; border-color: #428bca; }
.pagination .disabled span, .pagination .disabled span:hover, .pagination .disabled span:focus { color: #999; cursor: not-allowed; background-color: #fff; border-color: #ddd; }
.pagination-lg li a { padding: 10px 16px; font-size: 18px; }
.pagination-sm li a, .pagination-sm li span { padding: 5px 10px; font-size: 12px; }
</style>
默认情况下contos7不带nginx的yum源
可以通过rpm添加yum源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum源添加完成之后就可以使用yum安装nginx了(yum可以自行解决依赖关系安装nginx)
yum -y install nginx
安装完成之后可以通过命令启动nginx和设置开启自动运行
systemctl start nginx
systemctl enable nginx
没有任何报错就说明nginx安装并启动成功
如果有错误,可在nginx错误日志中查看原因
/var/log/nginx/error.log
server {
listen 80;
server_name home.zhouqq.com;
root /www/zhouqq;
index index.html index.htm index.php;
error_page 404 /404.html;
location = /404.html {
return 404 'Sorry, File not Found!';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html; # windows用户替换这个目录
}
location / {
try_files $uri @rewrite;
}
location @rewrite {
set $static 0;
if ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
set $static 1;
}
if ($static = 0) {
rewrite ^/(.*)$ /index.php?s=/$1;
}
}
location ~ /Uploads/.*\.php$ {
deny all;
}
location ~ \.php/ {
if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_NAME $1;
fastcgi_param PATH_INFO $2;
fastcgi_param SCRIPT_FILENAME $document_root$1;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
#!/bin/sh
rq=`date +%Y%m%d`
# 删除文件夹中一些过期的备份文件
find /back/ -name "*.sql" -mtime +10 |xargs rm -fr
find /back/ -name "*.tar.gz" -mtime +10 |xargs rm -fr
# 备份整个www目录
zip -r /back/wwwback_$rq.tar.gz /apps/www/*
# 备份数据库
mysqldump -uroot -p123456 database > /back/database`date +%Y-%m-%d_%H%M%S`.sql
启动备份只需要使用计划任务执行sh脚本就行,如:
55 23 * * * /back.sh