Skip to content

Instantly share code, notes, and snippets.

View zhdaniel's full-sized avatar
🎯
Focusing

Daniel Zhang zhdaniel

🎯
Focusing
View GitHub Profile
@ECHO OFF
%COMSPEC% /K ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"" x86
SET LUA_VERSION=5.3
CD src
CL /MD /c /DLUA_BUILD_AS_DLL *.c
REN lua.obj lua.o
REN luac.obj luac.o
LINK /DLL /IMPLIB:lua%LUA_VERSION%.lib /OUT:lua%LUA_VERSION%.dll *.obj
LINK /OUT:lua.exe lua.o lua%LUA_VERSION%.lib
LIB /OUT:lua%LUA_VERSION%-static.lib *.obj
@zhdaniel
zhdaniel / split.js
Created June 12, 2016 06:34
将数组中连续的数划分在一起
var data = [[1, 2, 3, 4, 6, 7, 9], [2, 4, 5, 6, 7, 8]];
_.each(data, function (item) {
var i,
j,
current;
for(i = 0; i < item.length; i++) {
current = item[i];
for(j = i + 1; j <= item.length; j++) {
if(current + 1 === item[j]) {
current = item[j];
@zhdaniel
zhdaniel / latency.markdown
Created January 20, 2018 17:44 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs