2020-01-15
Deploy VPN on AWS

Deploy VPN on AWS

Algo provides an opportunity to setup personal VPN easily, which allows people to deploy personal VPN sever on AWS for 1 year freely.

Read More

2019-05-07
Unsigned integers in cpp

In computer programming, an integer overflow occurs when an arithmetic operation attempts to create a numeric value that is outside of the range that can be represented with a given number of digits – either larger than the maximum or lower than the minimum representable value.

The most common result of an overflow is that the least significant representable digits of the result are stored; the result is said to wrap around the maximum (i.e. modulo a power of the radix, usually two in modern computers, but sometimes ten or another radix).

An overflow condition may give results leading to unintended behavior. In particular, if the possibility has not been anticipated, overflow can compromise a program’s reliability and security.

Read More

2019-04-10
How to specify a newer version gcc for cmake

After I upgraded gcc from version of 4.4.7 to version of 7.4.0 on CentOS 6.5, some ridiculous bugs happened when I linked my project to gtest. So I rebuilt gtest using the newer gcc, however, bugs remained. In the end, I found that cmake did not use the newer gcc when I was typing cmake .. command, I guessed that was the key.

Read More

2019-02-14
C++ rvalue reference

c++ rvalue reference

why we need rvalue references?

rvalue references are a new reference type introduced in c++0x that help solve the problem of unnecessary copying and enable perfect forwarding. When the right-hand side of an assignment is an rvalue, the the left-hand side object can steal resources from the right-hand side object rather than performing a separate allocation, thus enabling move semantics.

Read More

2016-12-23
Another Way To Generate A Prime Table

1
2
3
4
5
6
7
8
9
10
11
12
13
void CalculatePrimesUpTo(int max) {
::std::fill(is_prime_, is_prime_ + is_prime_size_, true);
is_prime_[0] = is_prime_[1] = false;

for (int i = 2; i <= max; i++) {
if (!is_prime_[i]) continue;

// Marks all multiples of i (except i itself) as non-prime.
for (int j = 2*i; j <= max; j += i) {
is_prime_[j] = false;
}
}
}
Read More