打造你的专属键盘 — ErgoDone

写在前面

低能预警:这是最没有技术含量的一篇博客,无关人员可以撤离。

部分图片来自网络,侵删

这个十一假期,亲手DIY了一把键盘。当 …

more ...

阻塞TCP流 - phxrpc代码阅读(3)

写在前面

phxrpc的流(streamstreambuf)与网络访问其实是耦合在一起的,所以本文可以结合着第一篇笔记一起来看。虽然我非常想吐槽这种 …

more ...

定时器以及其它 - phxrpc阅读笔记(2)

写在前面

phxrpc使用了协程(ucontext)和IO复用技术(epoll)来实现网络通信。定时器在其中起到了非常重要的作用。下面我们就来分析一下phxrpc的timer.[h|cpp]中的代码 …

more ...


Code Golf - Heapify

void heapify(vector<int>& vec) {
    int n = vec.size();
    for (int a = 0, b = 1; b - 1 < n; a = b, b <<= 1) {
        nth_element(vec.begin() + a, vec.begin() + b, vec.end());
    }
}

You can implement a “heapify” by only four lines of code. And the time complexity is O(n).

more ...

Using Set Cover to Optimize a Large-Scale Low Latency Distributed Graph

Background

Linkedin (or other social networks, such as Facebook and G+) use the “social graph information” to show the social relationship between you and other members.

Such as, “You and Mr.Obama share 10 mutual friends” or “You have 1,000 second-degree connections”.

This feature is very common for a …

more ...

Workflowy full notes

Recently, I’m becoming a crazy fan of workflowy because its ability to build a personal wiki concisely.

However, there’s only one thing bothers me that workflowy hide all the notes as the screenshot below, and it annoys me a lot.

Alt text

Luckily we can always find a way to …

more ...

用C++实现一个通用的sort函数

问题

用C++实现一个尽可能通用的sort函数

分析

一个通用的sort函数应该包含以下要点:

  • 确实可以排序(LOL)
  • 可以应对C-style array和C++-style container的排序需求
  • 可以应用于任意random access container
  • 可以 …
more ...

ZeroMQ启示录

ØMQ是一个消息系统

ZeroMQ是一个消息系统,也被称为“消息中间件”。它被广泛的用于经济、游戏、嵌入式等领域。

什么是消息系统

打个比方,消息系统就像我们使用的 …

more ...

Codeforces Round #290 (Div. 2) Tutorial

A. Fox And Snake

Implementation

(n, m) = map(int, raw_input().split())

res = []

for i in xrange(n):
    if i % 2 == 0:
        res.append('#' * m)
    elif (i / 2) % 2 == 0:
        res.append('.' * (m - 1) + '#')
    else:
        res.append('#' + '.' * (m - 1))

for line in res:
    print line

B. Fox And Two Dots

DFS …

more ...