- 博客(42)
- 资源 (3)
- 收藏
- 关注
原创 mysql 远程登入设置
本机ip绑定 1. 修改/etc/mysql/mysql.conf.d/mysqld.cnf 2. 设置bind-address = 10.100.2.1793. mysql -u root -p[passwd];4. use mysql;5. grant all privileges on *.* to root@'%' identified by 'passwd';
2017-09-05 12:49:28
288
原创 讲解for循环
for(初始化;表达式;后执行语句){}#include int main(void) { int i; for(i=0,printf("First=%d",i); printf("Second=%d",i),i<10; ++i,printf("Third=%d",i)) { printf("Fourth=%d",i);
2016-12-02 11:04:05
458
原创 给ping timestamp
ping 10.140.188.158 -c 10 | awk '{ print $0"\t" strftime("%D %H:%M:%S",systime()) } '
2016-08-01 16:54:59
950
原创 mapreduce demo
1. jar files:D:\userdata\nian\Desktop\search code\Char01\HadoopExample\lib\hadoop-0.20.2-core.jarD:\userdata\nian\Desktop\search code\Char01\HadoopExample\lib\commons-cli-1.2.jarD:\userdata\
2016-06-07 17:40:07
468
原创 shell 数组使用
#!/bin/shCmd=$0;usage(){ echo "usage : $Cmd raise|clear|show";}if [ $# -ne 1 ];then usage; exit;fialarmids=(3 4 237 238 931 1024 1052 1258 1299 1397 1770 1771 2009 2012 2017 2068 2
2015-10-21 16:44:51
553
原创 动态规划之硬币凑单
/** 硬币问题,用最少与最多数量的1,3,5面值硬币,凑单**/#include #include #define MAX_V 20#define coin_variety 3int main(){ int V[coin_variety] = {1,3,5}; int i,j,min[MAX_V],max[MAX_V],min_path[MAX_V];
2015-10-19 13:49:58
588
原创 sock 相关的结构
sock 相关的结构struct sockaddr { unsigned short sa_family; /* address family, AF_xxx */ char sa_data[14]; /* 14 bytes of protocol address */ }; struct sock
2015-09-08 16:39:50
386
转载 gdb查看内存区命令
用gdb查看内存格式: x /nfu说明x 是 examine 的缩写n表示要显示的内存单元的个数f表示显示方式, 可取如下值x 按十六进制格式显示变量。d 按十进制格式显示变量。u 按十进制格式显示无符号整型。o 按八进制格式显示变量。t 按二进制格式显示变量。a 按十六进制格式显示变量。i 指令地址格式c 按字符格式显示变量。
2015-08-05 13:38:02
1502
原创 v4转v6
ip转换:const uint8_t g_zero_addr[128] = {0};typedef struct { union { uint8_t head[12]; uint32_t u32_head[3]; }head_un;} mapped_head_t;mapped_head_t g_v4_mapped_head
2015-07-06 11:08:50
1726
转载 shell 模式匹配
模式匹配运算符号: ${var#pattern}最短匹配开头处,并删除该部分。 ${var##pattern}最长匹配开头处,并删除该部分。 ${var%pattern}最短匹配结尾处,并删除该部分。${var%%pattern}最长匹配结尾处,并删除该部分。
2015-06-02 13:09:53
512
原创 一个monitor脚本
#!/bin/bash# use for control nelmon log size.avoid full disc.# Author: nfli # Date 2015-6-1#Cmd=$0;usage(){ echo "usage : $Cmd crond [start|stop] | start | stop | status";}if [ $# -
2015-06-02 13:05:27
760
转载 js 获取html的select中的option的值
html代码: Volvo Saab Opel Audi 获取方法:var obj = document.getElementByIdx_x(”testSelect”); //定位idvar index = obj.selectedIndex; // 选中索引var text = obj.options[index].text; // 选中文本
2015-04-03 20:56:04
7770
转载 Linux删除某文件之外的所有文件
# shopt -s extglob (打开extglob模式)# rm -fr !(file1|file2)
2015-03-25 09:53:30
372
转载 ubuntu14.04 ssh 和 图形界面root登入
ssh root登入:vi /etc/ssh/sshd_config注释掉 #PermitRootLogin without-password,添加 PermitRootLogin yesservice ssh restart图形界面:vi /etc/lightdm/lightdm.conf文件内容最终为:[SeatDefaults]#启动后以roo
2015-03-17 12:17:18
627
转载 网络爬虫代码
import urllibimport timeimport sysurl = ['']*350page = 1link = 1while page <= 7: con = urllib.urlopen('http://blog.sina.com.cn/s/articlelist_1191258123_0_' + str(page) + '.html').read()
2015-01-04 11:41:06
429
转载 iconv脚本
#!/bin/bash#encode.sh -- encode a file with an indicated encoding# make sure user give two arguments[ "$#" != 2 ] && echo "Usage: `basename $0` [to_encoding] [file]" && exit -1# make sure the
2014-11-10 16:37:00
558
转载 makefile 模版
####################################################################### makefile 模版 (by lichuang)##########################################################################################项目路径和
2014-11-03 15:12:54
352
转载 宽字符处理函数函数与普通函数对照表
字符分类: 宽字符函数普通C函数描述iswalnum()isalnum()测试字符是否为数字或字母iswalpha()isalpha()测试字符是否是字母iswcntrl()iscntrl()测试字符是否是控制符iswdigit()isdigit()测试字符是否为数字
2014-10-14 16:08:58
420
原创 redefinition of ‘struct' 报错的解决办法
bia/home/linf/DictCompiler/src/../include/../include/tools.h:24: error: redefinition of ‘struct __term_s’/home/linf/DictCompiler/src/../include/tools.h:25: error: previous definition of ‘struct
2014-09-23 08:53:59
21590
3
原创 sort 对vector排序
#include #include#include #include #include #include #include #include #include using namespace std;typedef struct{ int c; wstring s;}__term_s;bool comp(__term_s cons
2014-09-22 17:38:59
593
原创 BOM头的处理
查找包含BOM头的文件:grep -r -I -l $'^\xEF\xBB\xBF' ./这条命令会查找当前目录及子目录下所有包含BOM头的文件,并把文件名在屏幕上输出。但是,删除BOM头,网上找到的命令大多不能用,比较常见的命令是:grep -r -I -l $'^\xEF\xBB\xBF' /path | xargs sed -i 's/^\xEF\xB
2014-09-16 15:58:28
422
原创 printf的封装
#define DBG(format, ...) \ fprintf(stderr, "[%s:%d] " format "\n",__FILE__, __LINE__, ##__VA_ARGS__ );#define FWDBG(FD,format,...)\ fwprintf(FD,L"[%s:%d]" format L"\n",__FILE__,
2014-09-12 10:37:58
787
原创 my_itoa 源码
#include#include #include #include #include char *reverse(char *s){ char temp; char *p = s; char *q = s; while(*q) ++q; q--; while(q > p) { temp = *p; *p++ = *q;
2014-05-21 17:12:03
602
原创 批量删除某一用户下进程
批量删除某一用户下进程kill -9 `ps -fu username |awk '{ print $2 }'|grep -v PID`
2014-01-10 16:30:25
937
转载 网络爬虫C++
写了一个网络爬虫,可以抓取网上的图片。需要给定初始网站即可。在vs2010中编译通过。编译后,运行即可,有惊喜哦!!![cpp] view plaincopyprint?//#include #include #include #include #include #include "winsock2.h"
2014-01-08 09:45:44
1073
转载 字符串Hash函数对比
今天根据自己的理解重新整理了一下几个字符串hash函数,使用了模板,使其支持宽字符串,代码如下: [cpp] view plaincopyprint?/// @brief BKDR Hash Function /// @detail 本算法由于在Brian Kernighan与Dennis Ritchie的《The C Programming La
2013-11-28 10:41:19
499
转载 暴雪公司有个经典的字符串的hash公式
暴雪公司有个经典的字符串的hash公式 先提一个简单的问题,假如有一个庞大的字符串数组,然后给你一个单独的字符串,让你从这个数组中查找是否有这个字符串并找到它,你会怎么做? 有一个方法最简单,老老实实从头查到尾,一个一个比较,直到找到为止,我想只要学过程序设计的人都能把这样一个程序作出来,但要是有程序员把这样的程序交给用户,我只能用无语来评价,或许它真的能工作,但也只能如此了。
2013-11-28 10:21:38
1010
转载 source insight 的relation window打不开
Q: My Context Window disappeared and I can't get it back.A: This may be caused by a corrupted configuration file. You will have to restart Source Insight without your configuration file. 1.
2013-11-22 15:02:48
5998
转载 Vim查找替换使用方法
vi/vim 中可以使用 :s 命令来替换字符串。该命令有很多种不同细节使用方法,可以实现复杂的功能,记录几种在此,方便以后查询。 :s/vivian/sky/ 替换当前行第一个 vivian 为 sky :s/vivian/sky/g 替换当前行所有 vivian 为 sky :n,$s/vivian/sky/ 替换第 n 行开始到最后一行中每一行
2013-11-12 09:34:01
467
转载 调用父类的带参数的构造函数
下面我们修改一下animal类的构造函数,增加两个参数height和weight,分别表示动物的高度和重量。代码如例2-13所示。 例2-13双击代码全选1234567891011121314151617181920212223242526272829
2013-07-18 15:37:35
929
转载 linux c与正则表达式
C中的正则表达式如何实现呢,以regex系列函数来简要说明:标准的linux c与c++不支持正则表达式;以POSIX函数库中的Regex系列函数来说明在Linux c下如何使用正则表达式:1、编译正则表达式: Regcomp函数,生成regex_t数据结构; int Regcomp(regex_t *preg, const char
2013-07-04 15:31:50
650
转载 C++:实现split分割字符串
#include #include #include using namespace std;void split(const string& src, const string& separator, vector& dest){ string str = src; string substring; string::size_typ
2013-06-18 09:12:43
512
转载 Linux 下 去掉终端显示的当前目录的绝对路径
Linux中,去掉终端显示的当前目录的绝对路径去~/.bashrc中,找到PS1变量的定义,如果没有,手动加上:可以将显示输出到标题栏上:#export PS1="\[\e]2;\u@\H \w\a\e[32;1m\]>\[\e[0m\] "最常见的设置,粉红色的:#export PS1="\[\e[35;1m\][\u@\h \W]$>\[\e[0m\]"绿色的:ex
2013-06-17 15:25:58
930
转载 使用libcurl POST数据和上传文件
为了具有通用性,将文件的内容读到了fc变量中,fclen是fc的长度。fc也可以是任何其它内容。curl 是 libcurl句柄。演示省略了很多显而易见的步骤。1. 普通的post请求,这里用curl_easy_escape对fc做了编码std::string data("req=plain");data.append("&file=");char *efc = curl_
2013-05-21 18:39:22
1745
转载 宽字符
Unicode或者宽字符都没有改变char数据型态在C中的含义。char继续表示1个字节的储存空间,sizeof (char)继续返回1。理论上,C中1个字节可比8位长,但对我们大多数人来说,1个字节(也就是1个char)是8位宽。C中的宽字符基于wchar_t数据型态,它在几个表头文件包括WCHAR.H中都有定义,像这样:typedef unsigned short wchar_
2013-04-11 17:52:22
455
转载 C语言中的区域设置
C语言中的区域设置是C标准委员会的发明,当时加进区域设置(相关声明在locale.h中)是为了支持欧洲那里与美国不同的字符集,现在的区域设置同时也支持亚洲字符集。 区域设置的函数有: /*设置区域设置,“C”为默认设置,“”(空字符串)为本地设置*/ char*setlocale(intcategory,constchar*locale); /*获取当前区域设置的数字格式习
2013-04-11 17:34:46
1252
原创 win7重建图标
taskkill /im explorer.exe /fcd /d %userprofile%/appdata/localdel iconcache.db /astart explorer.exe
2013-03-30 11:23:06
562
转载 makefile里PHONY的相关介绍
Phony TargetsPHONY 目标并非实际的文件名:只是在显式请求时执行命令的名字。有两种理由需要使用PHONY 目标:避免和同名文件冲突,改善性能。如果编写一个规则,并不产生目标文件,则其命令在每次make 该目标时都执行。例如: clean: rm *.o temp因为"rm"命令并不产生"clean"文件,则每次执行"make clean"的时候,该命令都会执
2013-03-29 10:54:08
451
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人