分类 学习笔记 下的文章
Linux 各目录的作用
Linux 各目录的作用
/bin
bin是binary的缩写。这个目录沿袭了UNIX系统的结构,存放着使用者最经常使用的命令。例如cp、ls、cat
,等等。
/boot
这里存放的是启动Linux时使用的一些核心文件。
/dev
dev是device(设备)的缩写。这个目录下是所有Linux的外部设备,其功能类似DOS下的.sys和Win下的.vxd。在Linux中设备和文件是用同种方法访问的。例如:/dev/hda
代表第一个物理IDE硬盘。
tips 各种小记录
hide win
go build -ldflags "-H windowsgui"
go build -ldflags "-s -w"
-s
去掉符号表,然后 panic
的时候 stack trace
就没有任何文件名/行号信息了。
-w
去掉 DWARF
调试信息,得到的程序就不能用 gdb
调试。
查看汇编
go tool compile -S main.go
static file
// 根访问
http.Handle("/", http.FileServer(http.Dir(".")))
// 指定 路径访问
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
cookie
http.HandleFunc("/one", func(w http.ResponseWriter, r *http.Request) {
cookie := &http.Cookie{Name: "cookie", Value: "zxysilent", Path: "/", HttpOnly: true,MaxAge: 7200}
http.SetCookie(w, cookie)
})
http.HandleFunc("/two", func(w http.ResponseWriter, r *http.Request) {
cookie, _ := r.Cookie("cookie")
w.Write([]byte(cookie.String()))
})
跨域
w.Header().Set(`Access-Control-Allow-Origin`, `*`)
中间件
1
http.Handle(`/`, mid(http.HandlerFunc(fn)))
func mid(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
//中间件的逻辑
w.Header().Set("Content-Type", "application/json")
w.Header().Set(`Access-Control-Allow-Origin`, `*`)
next.ServeHTTP(w, r)
})
}
2
http.HandleFunc(`/`, mid(fn))
func mid(next http.HandlerFunc) http.HandlerFunc{
return func(w http.ResponseWriter, r *http.Request) {
//中间件的逻辑
w.Header().Set("Content-Type", "application/json")
w.Header().Set(`Access-Control-Allow-Origin`, `*`)
next.ServeHTTP(w, r)
}
}
npm
prefix = D:\Program Files\nodejs\node_global
cache = D:\Program Files\nodejs\node_cache
cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
// --history-api-fallback 解决本地开发 vue-router-history模式 404 错误
"scripts": {
"dev": "webpack-dev-server --content-base ./ --open --inline --hot --port=82 --history-api-fallback --compress --config build/webpack.dev.config.js",
"build": "webpack --progress --hide-modules --config build/webpack.prod.config.js"
},
install git
sudo apt-get install git git-core git-doc
node
npm install --registry=https://registry.npm.taobao.org
prod
npm run webpack.build.production
nginx参数
基础cmd
sudo nginx #打开 nginx
nginx -s reload|reopen|stop|quit #重新加载配置|重启|停止|退出 nginx
nginx -t #测试配置是否有语法错误
nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
-?,-h : 打开帮助信息
-v : 显示版本信息并退出
-V : 显示版本和配置选项信息,然后退出
-t : 检测配置文件是否有语法错误,然后退出
-q : 在检测配置文件期间屏蔽非错误信息
-s signal : 给一个 nginx 主进程发送信号:stop(停止), quit(退出), reopen(重启), reload(重新加载配置文件)
-p prefix : 设置前缀路径
-c filename : 设置配置文件
-g directives : 设置配置文件外的全局指令