作者:matrix
发布时间:2016-12-31
分类:零零星星
类似于TP5框架的软删除功能
软删除的作用就是把数据加上删除标记,而不是真正的删除,同时也便于需要的时候进行数据的恢复。
这里以数据库表Dynamics为例
执行SQL语句给表新建字段delete_time:
ALTER TABLE sx_dynamics ADD `delete_time` char(13) DEFAULT NULL COMMENT '删除时间';
新建Model层文件
<?php
/**
* Created by PhpStorm.
* User: pang
*/
namespace Home\Model;
use Think\Model;
use Think\Page;
class DynamicsModel extends Model
{
/**
* 重写Model删除方法 实现TP5类似的软删除
*
* @param bool $trueDel 是否真实删除数据
* @return mixed
*/
public function delete($trueDel = false)
{
if ($trueDel) {
return parent::delete();
}
$data['delete_time'] = time();
return parent::save($data);
}
}
在Controller层
//使用D()方法实例化Model 调用重写的delete 软删除方法
D('dynamics')->where($w)->delete();
查询的where条件:
$where['delete_time'] = array('exp', 'IS NULL');//没有删除的数据
$where['delete_time'] = array('exp', 'IS NOT NULL');//已经删除的数据
-EOF-
for mac
作者:matrix
发布时间:2016-12-30
分类:零零星星
安装环境
按照ubuntu正常安装的时候却报错:
Lnmp Unable to get linux distribution name, or do NOT support the current di
原因是因为 /etc/issue 中记录的是linux发行版本:elementary OS Loki
lnmp脚本无法识别出为ubuntu的系统内核
修改main.sh文件
文件路径:/lnmp1.3/include/main.sh
搜索关键字Get_Dist_Name()查找该方法替换为一下内容:
Get_Dist_Name()
{
if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
DISTRO='CentOS'
PM='yum'
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
DISTRO='RHEL'
PM='yum'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
DISTRO='Aliyun'
PM='yum'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
DISTRO='Fedora'
PM='yum'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='Debian'
PM='apt'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='Ubuntu'
PM='apt'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
DISTRO='Raspbian'
PM='apt'
elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
DISTRO='Deepin'
PM='apt'
else
DISTRO='Ubuntu'
PM='apt'
fi
Get_OS_Bit
}
或者下载main.sh覆盖:http://pan.baidu.com/s/1hsyVSw8
然后再执行install.sh脚本安装就可以了
作者:matrix
发布时间:2016-12-29
分类:零零星星
搭建方法:http://www.jianshu.com/p/b5c4fbadbfae
apt-get update
apt-get install python-pip
pip install shadowsocks
添加:/etc/shadowsocks.json
{
"server":"my_server_ip",
"server_port":8388,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"mypassword",
"timeout":300,
"method":"aes-256-cfb",
"fast_open": false
}
ssserver -c /etc/shadowsocks.json -d start
我用ubuntu按照上面链接的方法来搭建的服务,安装运行到是ok,但是reboot重启Ubuntu的时候就发现出现问题。
编辑/etc/rc.local
添加开机自启动的命令失败:
ssserver -c /etc/shadowsocks.json -d start
Ubuntu下/etc/rc.local 文件修改之后没有成功。
实际上系统是执行了/etc/rc.local里面的命令,只是没有设置好ssserver命令的环境变量,系统当然无法执行。
我们需要做的就是给运行/etc/rc.local 的脚本里面添加环境变量就可以。
修改/etc/init.d/rc.local文件
vi /etc/init.d/rc.local
然后按i键执行vi编辑器的插入口令
将原本的PATH=/sbin:/usr/sbin:/bin:/usr/bin 修改为 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
按esc键输入:wq!保存退出
重启Ubuntu
reboot
然后系统就会成功执行 ssserver -c /etc/shadowsocks.json -d start 命令启动服务
重启:ssserver -c /etc/shadowsocks.json -d restart
加速
若vps是kvm虚拟技术,可提升扶墙效率
https://github.com/ToyoDAdoubi/doubi
- 安装锐速hack版
https://github.com/91yun/serverspeeder
-
安装Google BBR
$ bash -c "$(curl -sSL https://github.com/teddysun/across/raw/master/bbr.sh)" #安装bbr
$ bash -c "$(curl -sSL https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh)" #bbr plus
$ lsmod | grep bbr #检测
bash <(curl -L -s http://down.08mb.com/tcp_opz/tcpa/tcpa.sh) #安装
参考:
http://www.jianshu.com/p/f88424fd4ab3
http://blog.csdn.net/zhe_d/article/details/50312967
http://www.jianshu.com/p/b5c4fbadbfae
http://www.jianshu.com/p/94445ee49df0
小众化工具 brook
https://github.com/txthinking/brook