Skip to content

Instantly share code, notes, and snippets.

@bjne
bjne / crc32c.lua
Created January 10, 2019 21:38
crc32c and zstd for luajit/openresty
-- Copyright (C) by Bjørnar Ness <bjornar.ness@gmail.com>
local ffi = require "ffi"
local cast = ffi.cast
local bxor = bit.bxor
local bnot = bit.bnot
local band = bit.band
local rshift = bit.rshift
local t = {
{ name = "abc", sort={ def="after"}},
{ name = "def", sort={ abc="before", foo="before" } },
{ name = "ghi", sort={ def="before", abc="after", def="before" } },
{ name = "123", sort={ def="before", abc="before" } },
{ name = "xyz" },
{ name = "foo", sort={ bar="after"}},
{ name = "baz", sort={ ghi="before"}},
{ name = "bar", sort={ foo ="before", baz="before" }},
}
@bjne
bjne / gist:e061f61b0be8e54bdfc50f31e6fe3434
Created September 6, 2018 21:50
ngx lua ctx passing
diff --git a/build/ngx_lua-0.10.13/src/ngx_http_lua_common.h b/build/ngx_lua-0.10.13/src/ngx_http_lua_common.h
index 01ef2be..048e1bf 100644
--- a/build/ngx_lua-0.10.13/src/ngx_http_lua_common.h
+++ b/build/ngx_lua-0.10.13/src/ngx_http_lua_common.h
@@ -227,6 +227,8 @@ struct ngx_http_lua_main_conf_s {
ngx_int_t busy_buf_ptr_count;
#endif
+ ngx_int_t ctx_idx;
+
@bjne
bjne / configure_collectd.sh
Created March 12, 2016 11:44
simplify configuration of collectd
./configure $(sed 's/^#[ ]*--enable/--disable/g' << EOF | awk '{print $1}'
--prefix=/opt/collectd
--enable-aggregation Aggregation plugin
# --enable-amqp AMQP output plugin
# --enable-apache Apache httpd statistics
# --enable-apcups Statistics of UPSes by APC
# --enable-apple_sensors Apple's hardware sensors
# --enable-aquaero Aquaero's hardware sensors
# --enable-ascent AscentEmu player statistics
# --enable-barometer Barometer sensor on I2C
+----------+
| |
| alerta |
| |
+----^-----+
|
ALERT | (ALERT)
^ | ^
+-------------------+
| |