Quantcast
Channel: ZRJ
Browsing all 120 articles
Browse latest View live

Chrome 中印象笔记悦读插件的问题

印象笔记有一个 Chrome 插件,叫做悦读,可以过滤页面上的杂乱元素,得到一个清爽的纯内容视图,并且可以剪辑到印象笔记中,是个很好的插件。 然而有一个问题,例如这个页面,http://www.techxue.com/techxue-12450-1.html,摘取一段话...

View Article


2014

今年的年终总结总是感觉无从下笔,于是就一直这么拖,拖到今天,别人都上班了,自己明天也要上班了,才开始写。感觉难写的原因主要是理不出一条逻辑上的主线出来,既然如此,那么就碎碎念,想到哪写到哪吧。...

View Article


从柴静的穹顶之下学什么

今天上午二刷柴静的穹顶之下,边看边记,想把提纲重新还原出来,同时也是对她的叙述手法的一个学习吧,先放提纲 提纲 开场,PM2.5,北京,2013.2,曲线图,共同经历,共鸣 出差,四地,细节,咳嗽,切柠檬 怀孕,B超图,低期望,健康,对比,良性,出生后,手术,细节,小熊 回溯,山西,十年,群众口述,每天都这样,小女孩,采访,蓝天,白云,没见过 北京,一年,污染天数,全景365小图,拼图...

View Article

(void)var 是在干嘛

最近在看 muduo 的代码,看到类似这样的写法: size_t n = activeTimers_.erase(timer); assert(n == 1); (void)n; 而且不止一处,于是就很好奇,这种 (void)var...

View Article

动态链接库中的全局变量

想给自己之前的日志库,加一个染色的功能 gcc 有一个自己的特性,叫 __thread,介绍可以看这里,https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Thread_002dLocal.html,是可以用来修饰一个全局变量,从而让这个全局变量在每个线程都有一份拷贝,例子如下: #include <stdio.h> #include...

View Article


boost optional 以及 operator bool

boost 库有一个组件,叫做 optional,用来保存一些可有可无的成员变量,说明见这里,http://www.boost.org/doc/libs/1_58_0/libs/optional/doc/html/index.html,样例用法如下 #include <boost/optional.hpp> #include <stdio.h> #include...

View Article

netty 初窥

先说结论,总体感觉很好,比 cpp 上的 nio 框架好。 缘起是一个同学来问 java web 的问题,帮他调了一下,两年没怎么碰过 java web 的东西了,各种生疏,而且在调试的过程中,也再次感觉到 java 这个东西实在不适合做 web,一个是重,ssh 框架一上来就给人压得喘不过气的感觉,新增一个功能,要 spring struts 里面 xml 各种配,访问一下数据库,需要...

View Article

Linux 调用 system 函数的注意事项

来看这个代码 #include <stdio.h> #include <stdlib.h> int main() { system("sleep 5 && touch test.txt"); FILE *fp = fopen("test.txt", "r"); if (!fp) { printf("%m\n"); return -1; }...

View Article


Populating Next Right Pointers in Each Node II

来看这个题,https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/,要求常数空间,想了想,没想到,找了答案,是这样 class Solution { public: void connect(TreeLinkNode *root) { if (!root) { return; }...

View Article


std::next_permutation

std 中有一个 next_permutation 的算法,见这里,http://en.cppreference.com/w/cpp/algorithm/next_permutation,这个页面上面有一个实现 template<class BidirIt> bool next_permutation(BidirIt first, BidirIt last) { if (first ==...

View Article

iOS 微信如何收藏动画表情

网上看了一些办法,都不靠谱,实践下来,其实方法如下: 在电脑上登录 Windows 微信(网页版不行) 把要收藏表情的那个网页分享到文件传输助手 在 Windows 上打开网页,把动画表情保存到桌面 从桌面把文件拖入文件助手的聊天窗,发送出去 在手机上收藏,完成 好吧,这明显又是一篇水文,但是没办法,这种文章搜索引擎才喜欢收录。。

View Article

getdatetimestr

下午写了这么一个函数 char* getdatetimestr() { static char datetimestr[32] = {0}; static time_t last_update_time; struct timeval tv; gettimeofday(&tv, NULL); time_t nowtime = tv.tv_sec; if (nowtime !=...

View Article

再谈对非阻塞的理解

一般来说,现在大家 epoll 都是搭配着非阻塞 IO 一起用的,要问为什么?大家都这么用的啊,而且异步嘛,非阻塞嘛,很自然嘛 但是,非阻塞 IO 具体是怎么对 send 和 recv 起作用的。一般理解,我们之所以要用非阻塞,是为了避免这种情况: 客户端跟我们 tcp 三次握手完了,我们 listen fd 上得到一个 IN 事件了,然后 accept,得到一个新的 client...

View Article


visual studio 配合 boost

visual studio 是写 c++ 最好的 IDE 这是宇宙真理没有什么好讨论了,加上 VAssistX 更是如虎添翼。哪怕是 linux 开发我都要搭一个 windows->linux 的文件自动实时同步环境,然后在 windows 上编码,上 linux 去 make。 但是,问题来了,如何让 visual studio 搭配 boost 呢。...

View Article

36 进制

看到同事桌上有一份面试题,有一个 36 进制运算的题目,手贱敲了一下,不调真的不好做啊 #include <stdio.h> #include <string> #include <algorithm> #include <math.h> int convert_36_10(std::string strNum) {...

View Article


条件变量的用法和封装

对条件变量的用法的说明可以见这里,http://www.wuzesheng.com/?p=1668,写的不错,看一个裸写的无封装的用法如下: #include <stdio.h> #include <sys/time.h> #include <time.h> #include <pthread.h> #include <unistd.h>...

View Article

word 交叉引用同时显示标题编号和标题文字

找了一圈,没有看到 word 中有这个功能,本来想着这种问题百度应该有,百度了一圈也没有找到,最后还是 Google 到一个 2005 年的帖子,看这里,http://www.wordbanter.com/showthread.php?t=9240 Trying to insert a cross reference that includes both the heading number and...

View Article


比较字符串形式的版本号

版本号是一个字符串,主要考虑以下三种用例,点分的个数一致还好,不一致需要注意 #include <boost/algorithm/string.hpp> #include <algorithm> #include <vector> #include <string> bool version_less_than(std::string...

View Article

laravel 分页的一个 bug

先定基调,laravel 是一个好框架 然后,他提供了一个自动分页的,叫 Page,可以自动分页,同时在分页的 RESTful 响应报文中给出上一页下一页的 url,这很好,但是,这个实现是通过 url 的 parma 来达成的,也就是如果你的路径本来是 http://xxx.com/path/to/a/page,他会变成 /path/to/a/page?page=1,但是,如果你的路径本来就有...

View Article

unix domain socket dgram

大体上参考这里,http://philherlihy.com/unix-domain-sockets-datagram/ 改动之后如下 服务端 #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include...

View Article
Browsing all 120 articles
Browse latest View live