h - Move left
j - Move down
k - Move up
l - Move right
$ - Move to end of line
0 - Move to beginning of line (including whitespace)
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
/* | |
This program tests the performance characteristics of write combining | |
On an intel CPU only 4 writes at a time will be combined so we should see | |
a big performance improvement if we only write to distinct memory locations | |
<=4 times per iteration of a loop |
mat4 translate(vec3 d) | |
{ | |
return mat4(1, 0, 0, d.x, | |
0, 1, 0, d.y, | |
0, 0, 1, d.z, | |
0, 0, 0, 1); | |
} | |
mat4 scale(float c) | |
{ |
template<bool> struct _compile_time_assert; | |
template<> struct _compile_time_assert<true> {}; | |
#define ctassert(expr) if (0) { int flaming_goat_sausage = sizeof(_compile_time_assert<(bool)(expr)>); flaming_goat_sausage++; } | |
int main (int argc, char *argv[]) { | |
ctassert (sizeof (int) == 4); | |
ctassert ((sizeof (int) == 5) == false); | |
//BLAM | |
ctassert (sizeof (int) == 5); |
try: | |
from subprocess import DEVNULL # Python 3. | |
except ImportError: | |
DEVNULL = open(os.devnull, 'wb') | |
def start_subprocess(cmd): | |
"""Run cmd (a list of strings) and return a Popen instance.""" | |
return subprocess.Popen(cmd, stdout=DEVNULL, stderr=DEVNULL) |
For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.
After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft
Learning Rust
The following is a list of resources for learning Rust as well as tips and tricks for learning the language faster.
Warning
Rust is not C or C++ so the way your accustomed to do things in those languages might not work in Rust. The best way to learn Rust is to embrace its best practices and see where that takes you.
The generally recommended path is to start by reading the books, and doing small coding exercises until the rules around borrow checking become intuitive. Once this happens, then you can expand to more real world projects. If you find yourself struggling hard with the borrow checker, seek help. It very well could be that you're trying to solve your problem in a way that goes against how Rust wants you to work.
# WSL通过Win访问网络,所以WSL的网关指向的是Windows,DNS服务器指向的也是Windows,设置WSL的proxy为win的代理ip+端口即可 | |
# WSL中的DNS server在/etc/resolv.conf中查看,该文件是由/etc/wsl.conf自动生成的。 | |
# 如果关闭了wsl.conf中自动生成resolve.conf并自行修改了resolve.conf,DNS nameserver并不是本机win ip | |
# 需要开启wsl.conf的自动生成,再运行以下命令 | |
# https://zhuanlan.zhihu.com/p/153124468 | |
# 添加到环境变量设置中,例如~/.zshrc | |
export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*') | |
export https_proxy="http://${hostip}:7890" | |
export http_proxy="http://${hostip}:7890" |