Posts
All the articles I've posted.
go 分批读取http应答数据
Published: at 09:38 AM我们读取http应答通常用: ioutil.ReadAll(resp.Body) 很好用也很方便,但是如果应答的包很大时(下载文件),不仅会分配很大的内存而且慢。 所以我们需要分批读取,每次读取一块直到所有应答读取完成。 代码如下: func ReadChunk(r io.Reader, maxChunkSize int, ...
linux C++进程CPU占用100%排查
Published: at 07:42 AM现象 使用top -c命令查看发现某个进程的CPU一直100%以上,第一反应就是查看日志,如果发现某一处频繁打印日志,那么恭喜你很容易就定位到问题所在了,如果查看日志发现没什么异常请继续往下看。 出现问题的线程 进程ID你应该已经知道了,下一步要找到出现问题的线程ID,...
linux C++内存优化
Published: at 02:42 AM在linux上你会发现明明我的内存都释放了但是进程占用的内存还是没降下来,而在windows上就没有这种情况。这涉及到linux上内存分配原理(参考(http//blog.sina.com.cn/s/blogb4ef897e0102vg0l.html))。 在linux系统下,一块内存被C的free函数或者C++的delete函数显式释...
mysql备份、恢复表
Published: at 05:21 AM备份恢复单个表 dump mysqldump dbname tablename > tablename.sql 远程dump mysqldump -u <dbusername> -h <dbhost> -p dbname tablename > tablename.sql 恢复 mysql -u <username> -p dbname mysql> source <fullpath>/tablename.s...
centos7监控网卡流量
Published: at 08:05 AM安装 yum install iftop -y 查看网卡流量 iftop -i eth0 监控特定ip的流量 监控某个特定IP的带宽访问情况: iftop -i eth0 -B -F 182.92..20 显示182.92..20这个IP与服务器的网卡eth1交互的数据量,单位是Byte。 退出 q 显示界面说...
C++ 智能指针简单实现
Published: at 06:02 AM此实现仅做学习之用,生产中不要使用,可以使用stdsharedptr和boostsharedptr。 代码很少相信大家都看得懂。 template<class T> class SmartPtr { struct Counter { Counter() count(1){} int count; }; public Smart...
什么是云计算,大数据,人工智能
Published: at 10:32 AM作者:刘超 www.cnblogs.com/popsuper1982/p/8505203.html 原标题:不是技术也能看懂云计算,大数据,人工智能 我今天要讲这三个话题,一个是云计算,一个大数据,一个人工智能,我为什么要讲这三个东西呢?因为这三个东西现在非常非常的火,它们之间好...
goquery基本用法
Published: at 07:21 AM当我们通过网络拿到网页文本数据的时候,要对网页中的数据进行分析,筛选有用的数据。如果只是用平常的strings库来处理数据那效率太低了,goquery可以让我们使用类似jquery的方式来处理数据。 地址:https//github.com/PuerkitoBio/goquery(https//github.com/Puerki...
golang slice切片作为函数参数时的陷阱
Published: at 10:30 AM直接用例子说话 例1: func main() { s = make(int, 1, 3) // 创建一个长度为1,容量为3的切片 fmt.Printf("before slice addr %p point %p, val %v, len %d, cap %d\n", &s, s, s, len(s), cap(s)) modifySlice1(s) fmt.Printf("after slice addr %...
linux expect scp自动输入密码
Published: at 09:26 AMExpect是一个根据脚本与其他交互程序进行“对话”的程序,通过脚本,Expect根据程序的输出信息来判断需要什么输入,然后将输入信息发送给程序。详细文档(https//linux.die.net/man/1/expect) 现在通过一个简单的例子来使用它,使用scp在不同机器间传输文件每次都要输入密...