渔舟唱晚的天空
——welkinwalker的遐想
上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页
摘要: 类的成员函数指针和普通的函数指针 在C++中是完全两个不同的东西今天偶然需要找了点资料才发现这个问题,写一个简单的例子#include<iostream>usingnamespacestd;classtest_class{public:voidprint(uint32_tnum);};voidtest_class::print(uint32_tnum){cout<<num<<endl;}voidprint(uint32_tnum){cout<<num<<endl;}typedefvoid(test_class::*funptr)(ui 阅读全文
posted @ 2011-08-22 16:34 welkinwalker 阅读(435) 评论(0) 推荐(0) 编辑
摘要: AWKone-line写的非常之好,前些日子我尝试翻译了一下,对我自己的能力也有了一点提升,最近又看了一下Famous Sed One-Liners Explained,觉得sed的难度比awk有过之而无不及啊,一度非常崩溃,幸好坚持了下去,加上一直在cu的shell版块发帖子提问,在黑哥等人的帮助下,也算马马虎虎看完了,为了造福一下部分像我这种sed菜鸟,我将看过的这些内容翻译一下,请大家批评指正。谢谢!先进入第一部分:空行,编号,以及文本转换开始翻译之前我想讲一下sed程序的执行流程,还是举一个例子说明吧#more file123456#sed ‘/5/p’ file123456456# 阅读全文
posted @ 2011-08-12 14:43 welkinwalker 阅读(1495) 评论(0) 推荐(0) 编辑
摘要: awk的OFS不能够直接在print中打印,需要用逗号分隔后打印awk 'BEGIN{FS=":";OFS="=";} {print $3,$4;}' /etc/passwd下面这两条语句都不能按照预期工作:awk 'BEGIN{FS=":";OFS="=";} {print $3$4;}' /etc/passwdawk -F':' 'BEGIN{OFS="=";} {print $3$OFS$4;}' /etc/passwd 阅读全文
posted @ 2011-08-12 12:16 welkinwalker 阅读(8306) 评论(1) 推荐(0) 编辑
摘要: 今天在看hypertable的异步通讯库的过程中发现,usleep, sleep 函数会重置 clock的返回值,很是奇怪。这里记录一下,再给一个例子:下面的代码是能正常运行的,但是当我调整了sleep的位置后,程序就永远不能动了。#include<stdio.h>#include<time.h>#include<unistd.h>voidwait(intseconds){clock_tendwait;endwait=clock()+seconds*CLOCKS_PER_SEC;while(clock()<endwait){}}intmain(){in 阅读全文
posted @ 2011-08-05 15:38 welkinwalker 阅读(761) 评论(0) 推荐(0) 编辑
摘要: 解决老chunk的若干问题,包括:failover问题。以前支持两个进程的时候,如果其中一个挂掉,则另外一个要接管所有的数据请求,当失败进程重启的时候,又要把所有数据发回去。扫描过期文件问题。以前处理过期数据的方法是:每隔一定时间,启动一个扫描脚本,把一个进程上的所有记录扫面一遍,删除过期的。扩展时的负载均衡问题。 以前只能是成倍扩展,两台机器添加一台机器后,只有一台机器的压力能够被缓解,如果已经是4个进程 ,则要加到8个才可以。相比以前的关键改动在于:参与一致性哈希的对象变了,以前的时候是node,现在变成了node里面的chunk文件。带来的一些列变化包括:master不光要维持node信 阅读全文
posted @ 2011-07-25 13:46 welkinwalker 阅读(324) 评论(0) 推荐(0) 编辑
摘要: find -regex .*cc -o -regex .*h | xargs wc -lfind也自带了执行命令的方法:find -regex .*cc -o -regex .*h -exec wc -l '{}' \;这种方法的结果不太对,只能统计到满足 -regex .*h 的文件注明一下: find默认从当前目录递归的查找;-o 表示条件或;-regex表示正则表达式条件;{}使用来替换满足条件的结果的,要用’‘括起来;-exec执行命令需要加分号;,不过要使用反斜杠转移;也可以指定文件类型,用-type 指定,方法如下:-typecFile is of typec:bb 阅读全文
posted @ 2011-07-20 14:10 welkinwalker 阅读(506) 评论(0) 推荐(0) 编辑
摘要: for arg in 10.20.150.{91..93} ;do scp ~/.ssh/id_rsa.pub admin@$arg:~/.ssh && ssh admin@$arg "cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys" ;done 阅读全文
posted @ 2011-07-19 17:47 welkinwalker 阅读(259) 评论(0) 推荐(0) 编辑
摘要: But we’re still not done. Because generating and reading the select()bit arraystakes time proportional to the largest fd that you provided for select(), the select() call scales terribly when the number of sockets is high.Different operating systems have provided different replacement functions for 阅读全文
posted @ 2011-07-15 17:15 welkinwalker 阅读(2504) 评论(2) 推荐(0) 编辑
摘要: Level Trigger:1) The input signal is sampled when the clock signal is either HIGH or LOW.2) It is sensitive to Glitches.Example: Latch.Edge Trigger:1) The input signal is sampled at the RISING EDGE or FALLING EDGE of the clock signal.2) It is not-sensitive to Glitches.Example: Flipflop.翻译过来一个叫做条件触发( 阅读全文
posted @ 2011-07-15 15:33 welkinwalker 阅读(2557) 评论(0) 推荐(0) 编辑
摘要: 下面这段代码:#include<iostream>#include<fstream>usingnamespacestd;main(){char*filename=(char*)malloc(40);strcpy(filename,"/home/admin/local/apache/logs/access_log");ifstreamifs(filename);if(ifs.good()){cout<<"opensuccess"<<endl;stringtemp;getline(ifs,temp);cout& 阅读全文
posted @ 2011-07-12 11:21 welkinwalker 阅读(341) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页