转自: http://www.cnblogs.com/cnspace/archive/2011/ …
分类存档:默认分类
http://www.jetbrains.com/products.html
jetbrains 开发了多种语言的一系列的IDE: http://www.jetbrains. …
PHP中类的初始化
在JAVA中有如下代码:
1 2 3 4 5 6 7 8 9 10 |
public class Test { static { _i = 10; } public static int _i; public static void main(String[] args) { System.out.println(_i); } } |
&n …
关于cookie的数量测试
测试目的: 浏览器最多允许的cookie的个数是多少?子域与父域之间的关系? 实验 …
小米2下的chrome调试
缘起 pc上的网页元素调试的软件很多,用起来也很方便,比如: firebug/IE的开发者工具/chrome的 …
bitfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#include <iostream> #include <fstream> using namespace std; int dump(ifstream *, bool dump = false); int main(int ac, char** av) { string filename = "activeuser.bin"; time_t t = time(NULL); if (ac > 1) { filename = string(av[1]); } ifstream in("n.txt"); if (!in) { cout << "open file fail" <<endl; } cout << "count:" << dump(&in, false) <<endl; cout << "use time:" << time(NULL) - t << endl; in.close(); return 0; } int dump(ifstream *in, bool dump) { unsigned char* ch = new unsigned char[8]; int i = 0, j = 0, pos = 0, cnt = 0; char c; while (i < 8) { *(ch+i) = ('\x01' << (7 - i)); //cout << *(ch + i) << endl; //printf("%d\n", *(ch+i)); i++; } while(!in->eof()) { *in >> c; j = 0; while (j < 8) { if ((ch[j] & c) == ch[j]) { cnt++; if (dump) { cout << pos * 8 + j << endl; } } j++; } pos++; } return cnt; } |
关于sqlite的事务的使用
缘起 sqlite写入500条不大的记录居然要花费20多秒的时间,太慢了!!! 分析 sqlite是一个非常优 …
PHP实现的一维关联数组序列化
下面是一个典型的k-v存储格式的PHP实现:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
class db { public function test() { //..... } private function pack($arr) { $str = ''; foreach($arr as $key=>$val) { $str .= pack("n", strlen($key)).pack("n", strlen($val)).$key.$val; } return $str; } private function unpackUserInfo($str) { $arrResult = array(); $len = strlen($str); if ($len < 5) return $arrResult; $pos = 0; while($len - $pos >= 5) { $arr1 = unpack("n", substr($str, $pos, 2)); $arr2 = unpack("n", substr($str, $pos+2, 2)); $len_key = $arr1[1]; $len_val = $arr2[1]; $key = substr($str, $pos + 4, $len_key); $val = substr($str, $pos + 4 + $len_key, $len_val); $pos += 4 + $len_key + $len_val; $arrResult[$key] = $val; } return $arrResult; } } |
…
test
test
关于rsyslog不可靠的原因
缘起 人说rsyslogd丢日志,却未言起因,今好奇而查之。 闲话不闲 近几天不知缘何想起一个问题: tcp是 …