打包
1 | zip target.zip target # 打包一个文件 |
1 | zip target.zip target # 打包一个文件 |
1 | sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" |
1 | chsh -s /bin/zsh |
1 | pip install powerline-status --user |
Install
1 | cd ~/.oh-my-zsh/custom/plugins/ |
高亮
1 | cd ~/.oh-my-zsh/custom/plugins/ |
补全
1 | cd ~/.oh-my-zsh/custom/plugins/ |
1 | <dependency> |
算法 | 长度 |
---|---|
MD5 | 128bit |
SHA1 | 160bit |
SHA256 | 256bit |
节点定义
构造
遍历
应用
常见解题思路 递归,根据当前节点信息、递归左子树返回数据、递归右子树返回数据,判断是否解决;有时需要额外的变量存储结果。
图解 思路 参考 leetcode,忽略 random 优化的思路步骤如下。
1 | /** |
测试
1 |
|
输出
1 | [ -1, 0, 0, 1, 1, 2, 3, 3, 4, 8, 9 ] |
在一些场景下,我们需要通过 new 来创建 spring bean,而不是借助 spring 框架,这时会遇到 @Autowired
注解的字段没有初始化的问题(null)。 此时,可以借助 aspect 来解决,具体步骤可以分为三步。
context:spring-configed
-javaagent:/path/to/aspectjweaver-{version}.jar
对于 spring boot,启用 context:spring-configed
可以在 Application 类上使用注解 @EnableSpringConfigured
来实现,可能还需要 @EnableAspectJAutoProxy
注解。对于xml配置,可以添加如下代码。
1 | <aop:aspectj-autoproxy/> |
[TOC]
1 | d := time.Duration(10) |
1 | fmt.Printf("%v", []float64{0.1, 0.5, 0.99, 0.999}) |
1 | urlBaiduFanyiSug := "https://fanyi.baidu.com/sug" |
1 | // []byte -> string; bys: []byte |
1 | go mod tidy # 整理依赖, 下载没有下载的, 移除没有的 |
1 | git config --global --add url."git@your-repo.com:".insteadOf "https://your-repo.com/" |
1 | go list -m -versions git.*.com/org/repo |
1 | go get git.*.com/org/repo |
阶段 | STW(STOP THE WORLD) |
---|---|
STW sweep termination | YES |
concurrent mark and scan | NO |
STW mark termination | YES |
1 | GODEBUG=gctrace=1 ./<program> <parameters> |
1 | gctrace: setting gctrace=1 causes the garbage collector to emit a single line to standard |
1 | gc # @#s #%: #+#+# ms clock, #+#/#/#+# ms cpu, #->#-># MB, # MB goal, # P |
gc #
:编号@#s
:自程序启动到打印 gc 日志的时间#%
:自程序启动,gc 花费的时间占比#+#+# ms clock
:垃圾回收时间,(sweep)+(mark & scan)+(termination)#+#/#/#+# ms cpu
:垃圾回收占用的 CPU 时间 (sweep)+(mark & scan (辅助时间/后台gc时间/空闲时间))+(termination)#->#-># MB
:gc 开始时堆大小、gc 结束时堆大小、存活堆大小#MB goal
:全局堆大小#P
:使用的处理器数量ms cpu 约等于 cpu_num * ms clock
示例
1 | gc 35 @1130.489s 1%: 0.71+3290+0.12 ms clock, 5.7+5932/26084/4619+1.0 ms cpu, 35956->37042->8445 MB, 37411 MB goal, 32 P |
参考
1 | curl http://127.0.0.1:12067/debug/pprof/profile > profile.dat |
1 | string -> int32 |
GLIBC_2.32' not found
1 | 错误 |
针对 redis 的 benchmark,可使用 redis 自带的 redis-benchmark
工具。
1 | 命令 |
参数 | 说明 | 默认值 | 示例 |
---|---|---|---|
-h | 主机 | 127.0.0.1 | |
-p | 端口 | 6379 | |
-a | 密码 | ||
-s | 指定服务器socket | ||
-c | 客户端并发连接数 | 50 | |
-n | 请求数 | 10000 | |
-d | 以字节的形式指定 SET/GET 值的数据大小 | 2 | |
-k | 连接保持,1=keep alive 0=reconnect | 1 | |
-r | SET/GET/INCR 使用随机 key, SADD 使用随机值 | ||
-P | 通过管道传输 <numreq> 请求 |
1 | |
-q | 强制退出 redis,仅显示 query/sec 值 | ||
–csv | 以 CSV 格式输出 | ||
-l | 生成循环,永久执行测试 | ||
-t | 仅运行以逗号分隔的测试命令列表 | set,lpush | |
-l | Idle 模式,仅打开 N 个 idle 连接并等待 |
1 | redis-benchmark -h <host> -p <port> -t set -n 100000 -d 1024 -a <password> |