《设计模式之禅》-秦小波
书名
《设计模式之禅》
作者
秦小波`
出版日期
2010-03-01
ISBN
9787111295440
主要内容
讲述软件设计6大原则,24种设计模式及其扩展
设计原则设计原则只是一种倡议,一种规范,目的是设计出更健全的软件。
设计模式不是硬性规定,应结合具体情况自由组合,灵活改变。
单一职责原则说明
There should never be more than one reason for a class tochange.
有且仅有一个原因(属性、行为、协议等)引起(接口、类、方法)的变更。
一个方法、类、接口只做一件事。
优点
降低类的复杂度
提高可读性、可维护性
降低变更引起的风险,单一接口的变更不会影响其他接口
缺点
This is sometimes hard to see
无法确定是否分离其行为等原因,增加复杂性。注意
“职责”和“变化原因”可用于衡量类/接口设计优良与否的一个原因,但这是不可度量的,应适应具体问题
建议
接口“单一职责”
类“单一变化原因”
里氏替换原则说明
Functions that us ...
Ubuntu18.04安装Xfce桌面与VNC远程工具
安装Xfce桌面1sudo apt-get install xfce4
安装VNC1sudo apt-get install vnc4server
启动VNC Server
第一次启动VNC Server时会要求设置密码
1vncserver
修改xstartup文件
1vim ~/.vnc/xstartup
修改为以下内容:
1234567#!/bin/shunset SESSION_MANAGERunset DBUS_SESSION_BUS_ADDRESSstartxfce4 &[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresourcesxsetroot -solid grey
关闭VNC Server链接1vncserver -kill :链接号 #注意kill之后有空格
更改Ubuntu默认python版本
查看
查看已安装的python版本
1ls /usr/bin/python*
查看默认的 Python 版本
1python --version
修改修改某用户的默认Python 版本使用alias创建python别名至指定版本
1alias python='/usr/bin/python3.4'
修改系统的默认 Python 版本使用 update-alternatives,使用方法可参考https://www.jianshu.com/p/4d27fa2dce86
列出可选python版本
1update-alternatives --list python
若出现错误:update-alternatives: error: no alternatives for python
update-alternatives未识别到python,则需手动指定python安装路径
12update-alternatives --install /usr/bin/python python python具体路径# update-alternativ ...
在ubuntu服务器上使用Chrome Headless
Chrome服务器安装Chrome1234# sudo apt-get install libxss1 libappindicator1 libindicator7wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.debsudo dpkg -i google-chrome*.deb# 如果报错,根据提示修复
Chrome headless的启动1google-chrome --headless --remote-debugging-port=9222 https://www.baidu.com --disable-gpu
param
description
headless
无头模式
remote-debugging-port
调试端口
disable-gpu
禁止GPU
访问本地调试端口,应看到调试信息
1curl http://localhost:9222
Chrome Driverhttps://sites.google.com/a/chromium. ...
413 Request Entity Too Large
若nginx用所用的php请求解析服务是fpm, 则修改fpm/php.ini文件,设置可上传的最大值
12upload_max_filesize = 20Mpost_max_size = 20M
重启fpm服务
1service phpx-fpm restart
若仍出现413错误,则排除php.ini的问题
在nginx的网站配置中设置可上传的最大值
12345server {...client_max_body_size 20m;...}
重启nginx服务
1service nginx restart
PPA安装Oracle Java11
添加源Ubuntu/Mint 64bit1sudo add-apt-repository ppa:linuxuprising/java
Debian 64bit123su -echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main" | sudo tee /etc/apt/sources.list.d/linuxuprising-java.listapt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A
安装12apt-get updateapt-get install oracle-java11-installer
Ubuntu的add-apt-repository: command not found
1sudo apt-get install software-properties-common python-software-properties
linux下vim编辑器backspace和方向键不能正常使用的问题
问题当使用backspace和上下左右时出现字母或不能用的清空
原因安装的是vim-tiny
解决方法进入/etc/vim,找到vimrc.tiny文件
将set compatible改为set nocompatible
并添加set backspace=2
Ubuntu 完全卸载Apache2
删除apache
12sudo apt-get --purge remove apache-commonsudo apt-get --purge remove apache
删除配置文件
123sudo find /etc -name "*apache*" |xargs rm -rfsudo rm -rf /var/wwwsudo rm -rf /etc/libapache2-mod-jk
删除关联
1dpkg -l |grep apache2|awk '{print $2}'|xargs dpkg -P
查看ubuntu系统的版本信息
cat /proc/version
123linux内核版本号gcc编译器版本号Ubuntu版本号
uname -a
12内核版本字长
lsb_release -a
1234Distributor ID: Ubuntu //类别Description: Ubuntu 14.04.2 LTS //版本说明Release: 14.04 //版本Codename: trusty //代号