Skip to content

Instantly share code, notes, and snippets.

View x5lcfd's full-sized avatar
:octocat:
coding.

x5lcfd x5lcfd

:octocat:
coding.
View GitHub Profile
@x5lcfd
x5lcfd / ctags.cnf
Last active June 17, 2017 15:38
项目用, vim tags.
--exclude=.git
--exclude=.svn
--regex-LUA=/^def\.method\(.*\)\.[ \t]*([a-zA-Z0-9]*)\s*=\s*function.*$/\1/t,tfunctions/
--regex-LUA=/^def\.virtual\(.*\)\.[ \t]*([a-zA-Z0-9]*)\s*=\s*function.*$/\1/t,tfunctions/
--regex-LUA=/^def\.override\(.*\)\.[ \t]*([a-zA-Z0-9]*)\s*=\s*function.*$/\1/t,tfunctions/
--regex-LUA=/^def\.static\(.*\)\.[ \t]*([a-zA-Z0-9]*)\s*=\s*function.*$/\1/t,tfunctions/
--regex-LUA=/^def\.final\(.*\)\.[ \t]*([a-zA-Z0-9]*)\s*=\s*function.*$/\1/t,tfunctions/
--regex-LUA=/^.*\s*function[ \t]*([a-zA-Z0-9_]+)\s*\(.*$/\1/l,lfunction/
--regex-LUA=/^.*local\s*[ \t]*([a-zA-Z0-9_]+)\s*=\s*function.*$/\1/l,lfunction/
#!/usr/bin/env lua
--[[-------------------------------------------------------------------
ChunkSpy.lua
A Lua 5.1 binary chunk disassembler
ChunkSpy was inspired by Nick Trout's vmmerge5.lua
Copyright (c) 2004-2006 Kein-Hong Man <[email protected]>
The COPYRIGHT file describes the conditions under which this
software may be distributed (basically a Lua 5-style license.)
@x5lcfd
x5lcfd / lua_string.lua
Created March 13, 2017 12:06
Lua string collections
-- split
string.split = function(s, p)
local rt= {}
string.gsub(s, '[^'..p..']+', function(w) table.insert(rt, w) end )
return rt
end
// http://stackoverflow.com/questions/874134/find-if-string-ends-with-another-string-in-c
bool has_suffix(const std::string &str, const std::string &suffix)
{
return str.size() >= suffix.size() &&
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
}
@x5lcfd
x5lcfd / tsinghua-brew.sh
Created February 17, 2017 17:25
homebrew from mirrors.tuna.tsinghua.edu.cn
# 替换现有上游
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
brew update
# 使用homebrew-science或者homebrew-python
:: setvar varname cmd
:: Set VARNAME to the output of CMD
:: Triple escape pipes, eg:
:: setvar x dir c:\ ^^^| sort
:: -----------------------------
:: http://stackoverflow.com/a/25954264/6181205
@echo off
SETLOCAL
@x5lcfd
x5lcfd / EnumParse.cs
Created February 13, 2017 07:38
StringToEnum
// Mono2.6 doesn't have Enum.TryParse
public static TEnum ToEnum<TEnum>(this string strEnumValue, TEnum defaultValue)
{
if (!Enum.IsDefined(typeof(TEnum), strEnumValue))
return defaultValue;
return (TEnum)Enum.Parse(typeof(TEnum), strEnumValue);
}

ADD_SUBDIRECTORY 用于向当前工程添加存放源文件的子目录,并可以指定中间二进制和目标二进制存放的位置.

换个地方保存目标二进制

不论是 SUBDIRS 还是 ADD_SUBDIRECTORY 指令(不论是否指定编译输出目录),我们均可以通过 SET 指令重新定义 EXECUTABLE_OUTPUT_PATHLIBRARY_OUTPUT_PATH 变量来指定最终的目标二进制位置.

SET (EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
@x5lcfd
x5lcfd / latency.txt
Created February 1, 2017 03:17 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@x5lcfd
x5lcfd / gpugems.css
Created December 22, 2016 16:53
GPU GEMS Dark Style
/*
url prefix: https://developer.nvidia.com/gpugems/
*/
.white-background {
background-color: #000;
}
.row > .col-md-8 > p {
color: white;