Skip to content

Instantly share code, notes, and snippets.

@omigafu
omigafu / luajit ffi使用
Created May 10, 2019 12:03
luajit ffi使用
local ffi = require("ffi")
local t = {1, 2, 3} -- array of floating point numbers
-- lua数组 t 也可以是int,float
-- ffi.new("float[?]", #t, t) new一个cdata,float数组,大小是#t:3,初始化用t
-- ffi.string 当第二个参数有的时候,第一个参数返回的指针类型是变成了void。(可能会导致字节序问题)
-- 如果第二个参数没有的话,第一个指针会转换成char*,并且当遇到/0的时候截断,字符串长度是由strlen()确定
local str = ffi.string(ffi.new("float[?]", #t, t), 4 * #t)
print(#t)
print(str)
print(#str)
@omigafu
omigafu / go必看知识点
Created November 29, 2018 07:01
go 必看知识点
Go 语言实践:编写可维护的程序的建议
英文:https://dave.cheney.net/practical-go/presentations/qcon-china.html
中文:https://github.com/llitfkitfk/go-best-practice
Golang 新手可能会踩的 50 个坑
https://segmentfault.com/a/1190000013739000
@omigafu
omigafu / 0_reuse_code.js
Created January 17, 2017 02:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console