Git
Git是目前世界上最先进的分布式版本控制系统(没有之一)
Git如何存储版本差异?
SHA-1算法的安全性
16核i5处理器、64块Geforce 970显卡、256G内存,破解时间为10天
微软在2013年的Windows 8系统里就改用了SHA-2,Google、Mozilla则宣布2017年1月1日起放弃SHA-1
非防窃取,但防篡改
.gitignore文件
- The following paths are ignored by one of your .gitignore files:App.class
- Use -f if you really want to add them.
- $ git check-ignore -v App.class
- .gitignore:3:*.class App.class
git 回滚
- git checkout -- <file>...
- --mixed – 默认选项。缓存区和你指定的提交同步,但工作目录不受影响
- --hard – 缓存区和工作目录都同步到你指定的提交
git rebase
- git rebase [branch_name] # 基于某个分支合并
- git rebase --continue # 解决冲突后,继续合并
- git rebase --abort # 放弃合并
git statsh
回滚版本时,本地有已修改的但未提交的内容;
正在开发需求时,如何修复紧急bug (储藏);
- git stash pop (等同于git stash apply && git stash drop) # 还原
git 对比历史
- git diff # 显示工作目录与上次提交或缓存区之间的差异
- git diff --cached # 显示缓存与上次提交之间的差异
- git diff HEAD # 显示工作目录与上次提交的差异
- git diff [branch_name] # 显示工作目录与某个branch之间的差异
- git diff master [branch_name] # 显示主干与某个branch之间的差异
git log
- git log --pretty=oneline # 每次提交历史显示到一行
- git log --graph --pretty=oneline --abbrev-commit # 显示提交历史树图
Nginx配置
Nginx编译
- nginx编译时./configure --help以--without开头的都默认安装。
- --prefix=PATH : 指定nginx的安装目录。默认 /usr/local/nginx
- --conf-path=PATH : 设置nginx.conf配置文件的路径。nginx允许使用不同的配置文件启动,通过命令行中的-c选项。默认为prefix/conf/nginx.conf
- --user=name: 设置nginx工作进程的用户。安装完成后,可以随时在nginx.conf配置文件更改user指令。默认的用户名是nobody。--group=name类似
- --with-pcre : 设置PCRE库的源码路径,如果已通过yum方式安装,使用--with-pcre自动找到库文件。使用--with-pcre=PATH时,需要从PCRE网站下载pcre库的源码(版本4.4 - 8.30)并解压,剩下的就交给Nginx的./configure和make来完成。perl正则表达式使用在location指令和 ngx_http_rewrite_module模块中。
- --with-zlib=PATH : 指定 zlib(版本1.1.3 - 1.2.5)的源码解压目录。在默认就启用的网络传输压缩模块ngx_http_gzip_module时需要使用zlib 。
- --with-http_ssl_module : 使用https协议模块。默认情况下,该模块没有被构建。前提是openssl与openssl-devel已安装
- --with-http_stub_status_module : 用来监控 Nginx 的当前状态
- --with-http_realip_module : 通过这个模块允许我们改变客户端请求头中客户端IP地址值(例如X-Real-IP 或 X-Forwarded-For),意义在于能够使得后台服务器记录原始客户端的IP地址
- --add-module=PATH : 添加第三方外部模块,如nginx-sticky-module-ng或缓存模块。每次添加新的模块都要重新编译(Tengine可以在新加入module时无需重新编译)
Nginx操作
- # /usr/local/nginx-1.6/sbin/nginx -t # 检查配置文件是否正确
- # ./sbin/nginx -V # 可以看到编译选项
- #./sbin/nginx -s stop # 停止nginx
- #./sbin/nginx -s reload # 重启nginx
- 或 kill -HUP `cat /usr/local/nginx-1.6/logs/nginx.pid`
Nginx 基础参数
- worker_processes 4; #启动进程,通常设置成和cpu的数量相等
- #epoll是多路复用IO(I/O Multiplexing)中的一种方式,
- #仅用于linux2.6以上内核,可以大大提高nginx的性能
- #单个后台worker process进程的最大并发链接数
- # 即 max_clients = worker_processes * worker_connections
- # 在设置了反向代理的情况下,max_clients = worker_processes * worker_connections / 4
- # max_clients不能超过可打开的文件句柄数
Nginx Web服务器参数
- keepalive_timeout 65; # 连接超时
- client_header_buffer_size 128k;
- large_client_header_buffers 4 128k;
- access_log logs/nginx.access.log main;
- index index index.html index.htm;
- proxy_next_upstream http_502 http_504 error timeout invalid_header;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- error_page 500 502 503 504 /50x.html;
- location ~ ^/(images|javascript|js|css|flash|media|static)/ {
- #过期30天,静态文件不怎么更新,过期可以设大一点,
Nginx负载参数
- server x.x.x.x1:8998 weight=6 max_fails=2 fail_timeout=10s;
- server x.x.x.x2:8997 weight=3 max_fails=2 fail_timeout=10s;
- server x.x.x.x3:8997 weight=1 max_fails=2 fail_timeout=10s;
Nginx 日志参数
- "$upstream_http_content_type"
跨域设置
Nginx设置
- if ($http_origin ~ 'domain1.com|domain2.com$') {
- add_header Access-Control-Allow-Origin "$http_origin";
- add_header Access-Control-Allow-Methods "POST, GET, OPTIONS";
- add_header Content-Type application/json;
- add_header Access-Control-Allow-Headers "x-requested-with";
Ruby设置
- class XxxxxController < ApplicationController
- before_action :access_control_headers
- def access_control_headers
- headers['Access-Control-Allow-Origin'] = "*" # or your web site like http://m.zeju.com
- headers['Access-Control-Request-Method'] = %w{GET POST OPTIONS}.join(",")
- headers['Access-Control-Allow-Headers'] = "x-requested-with"
分享到微信时,没有展示图片的问题
在紧挨<body>标签开始的位置,放一张300*300以上的png图片,并隐藏展示
例如:
<div style="display:none"><img src="xxx.png"/></div>
任务清单记录工具
滴答清单