我一般用 tcpdump 有两种用法,一个是存盘,拿 wireshark 看,那么的话,就这么写
tcpdump -s 0 -i any -p udp and src 10.170.7.40 -w `date +%s`.pcap
或者实时打印到屏幕,就参考这里,http://www.askbjoernhansen.com…,这么写
I always forget the parameters for this and have to look them up in th…… 阅读全文
linux ss
ss 是一个类似 netstat 的网络连接查看工具,man page 是这么说的
ss – another utility to investigate sockets
而 netstat 的 man page 中也有说到
This program is obsolete. Replacement for netstat is ss.
常用命令有
-s 参数,打印 summary
# ss -s
Total: 1596 (kernel 1890)
TCP: 7587 (estab …… 阅读全文
python 日志初始化
import logging
logging.basicConfig(format = '[%(asctime)s][%(levelname)s] %(message)s [%(funcName)s::%(lineno)d]', level = logging.DEBUG)
logging.debug(123)
—————————
2016-2-19 09:26:26 update
logging.basicConfig(stream=s…… 阅读全文
navicat 新建查询报错目录名或卷标语法不正确
网上查了一下,说要删了重建,其实这个错误在提示中比较明显了,解决方法是在右键,连接属性,高级,设置位置,把路径名中的非法字符去掉就可以了,例如冒号改成下划线等等,那么,Windows 路径中的非法字符有哪些呢,看这里,https://msdn.microsoft.com/zh-…
The following reserved characters:
< (less than…… 阅读全文
获取当前机器 IP
std::string GetLocalIP()
{
struct ifreq req;
int sock_fd;
char szLocalIP[16]= {0};
string strLocalIP="";
sock_fd = socket(AF_INET,SOCK_STREAM,0);
if(sock_fd < 0)
return strLocalIP;
sn…… 阅读全文
清除旧日志脚本
bash 的语法真是反人类啊,反人类啊啊啊
#!/bin/bash
# created: 2015-10-10 13:24:15
size=204800
echo "loop delete oldest log file until directory size < "$size" KB"
while [ 1 ]; do
directory_size=$(du -s | cut -f1)
if [ "$size" -gt &…… 阅读全文
unix domain socket dgram
大体上参考这里,http://philherlihy.com/unix-domain-sockets-datagram/
改动之后如下
服务端
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <…… 阅读全文
laravel 分页的一个 bug
先定基调,laravel 是一个好框架
然后,他提供了一个自动分页的,叫 Page,可以自动分页,同时在分页的 RESTful 响应报文中给出上一页下一页的 url,这很好,但是,这个实现是通过 url 的 parma 来达成的,也就是如果你的路径本来是 http://xxx.com/path/to/a/page… /path/to/a/page?page=1,但是,如果你的路径…… 阅读全文
比较字符串形式的版本号
版本号是一个字符串,主要考虑以下三种用例,点分的个数一致还好,不一致需要注意
#include <boost/algorithm/string.hpp>
#include <algorithm>
#include <vector>
#include <string>
bool version_less_than(std::string str_version_a, std::string str_version_b)
{
std::vec…… 阅读全文
word 交叉引用同时显示标题编号和标题文字
找了一圈,没有看到 word 中有这个功能,本来想着这种问题百度应该有,百度了一圈也没有找到,最后还是 Google 到一个 2005 年的帖子,看这里,http://www.wordbanter.com/show…
Trying to insert a cross reference that includes both the heading number and
the heading text … like “3.2 Contra…… 阅读全文