Skip to content

Instantly share code, notes, and snippets.

@yongboy
yongboy / Apache_APISIX_Consul
Created July 9, 2020 07:50 — forked from moonming/Apache_APISIX_Consul
How to use Consul as Registration Center in Apache APISIX?
## Install Consul
1. download consul
```
wget https://releases.hashicorp.com/consul/1.7.3/consul_1.7.3_linux_amd64.zip
```
2. unzip to `/usr/bin`
```
sudo unzip consul_1.7.3_linux_amd64.zip -d /usr/bin
@yongboy
yongboy / lua_malloc_trim.lua
Created September 30, 2017 02:46
使用方式: 1. 可以单独用作init_worker_by_lua_file指令配置 2. 或单独在对应需要初始化的代码所需要地方,导入即可:require "lua_malloc_trim"
-- 目的:启动一个单独定时器,每隔一段时间自动调用glibc库对应的libc.so.6文件的malloc_trim()接口,尝试清理掉被缓存已free掉的内存信息
-- 使用方式:
-- 1. 可以单独用作init_worker_by_lua_file指令配置
-- 2. 或单独在对应需要初始化的代码所需要地方,导入即可:require "lua_malloc_trim"
-- User: nieyong
-- Date: 2017/9/20
-- Time: 下午8:45
local ffi = require "ffi"
local glibc = ffi.load("c")
@yongboy
yongboy / lua_malloc_trim.lua
Created September 30, 2017 02:46
使用方式: 1. 可以单独用作init_worker_by_lua_file指令配置 2. 或单独在对应需要初始化的代码所需要地方,导入即可:require "lua_malloc_trim"
-- 目的:启动一个单独定时器,每隔一段时间自动调用glibc库对应的libc.so.6文件的malloc_trim()接口,尝试清理掉被缓存已free掉的内存信息
-- 使用方式:
-- 1. 可以单独用作init_worker_by_lua_file指令配置
-- 2. 或单独在对应需要初始化的代码所需要地方,导入即可:require "lua_malloc_trim"
-- User: nieyong
-- Date: 2017/9/20
-- Time: 下午8:45
local ffi = require "ffi"
local glibc = ffi.load("c")
@yongboy
yongboy / build_asan.sh
Last active January 20, 2021 06:47
build gcc 4.8.2 AddressSanitizer (ASAN) with openresty + stream-lua-nginx-module for debug, the linux bash script
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
yum install devtoolset-2-libasan-devel libssan
/opt/rh/devtoolset-2/root/usr/bin/gcc --version
cd openresty-1.11.2.5
export ASAN_OPTIONS=detect_leaks=0
./configure --with-cc="gcc -fsanitize=address" \
--with-cc-opt="-O1 -fno-omit-frame-pointer" \
--with-debug \
@yongboy
yongboy / luajit-luarocks-osx.sh
Created March 16, 2017 01:15 — forked from marshyski/luajit-luarocks-osx.sh
LuaJIT and luarocks on Mac OS X El Capitan
# This is to install both on OS X if you don't want to use homebrew
# xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
xcode-select --install
curl -O http://luajit.org/download/LuaJIT-2.0.4.zip
unzip LuaJIT-2.0.4.zip
cd LuaJIT-2.0.4
make && make install
curl -O http://keplerproject.github.io/luarocks/releases/luarocks-2.3.0.tar.gz
@yongboy
yongboy / presentation.md
Created January 17, 2017 03:46 — forked from slfritchie/presentation.md
Erlang tracing, for the Riak source code reading series, 2014-03-18, Tokyo, Japan

Erlang Tracing: more than you wanted to know

Rough Outline

  • What can be traced?
  • How can trace events be specified?
  • "match specifications": twisty passages, all alike
  • WTF, can I just use DTrace and drink my coffee/beer/whisky in peace?
  • Trace delivery mechanisms: pick one of two
@yongboy
yongboy / test1.erl
Created June 26, 2015 06:00
DNS解析测试脚本
%%%-------------------------------------------------------------------
%%% @author nieyong
%%% @copyright (C) 2015
%%% @doc
%%% DNS解析测试
%%% @end
%%%-------------------------------------------------------------------
-module(test1).
-export([start/2]).
@yongboy
yongboy / pydmesg
Created July 1, 2014 06:08 — forked from saghul/pydmesg
#!/usr/bin/env python
# coding=utf8
# Copyright (C) 2010 Saúl ibarra Corretgé <saghul@gmail.com>
#
"""
pydmesg: dmesg with human-readable timestamps
"""
@yongboy
yongboy / server_v2.c
Last active November 16, 2017 15:05
可绑定指定IP地址和端口的示范HTTP服务器程序,仅仅作为示范。
/*
* One demo http server, just for test!
* how to compile it:
* gcc server_v2.c -o server_v2 /usr/local/lib/libev.a -lm
* how to run it:
* ./server_v2 -p port_num -i the_bind_ip
* default port is 8000
* default ip is all of the local ip
* eg:
* ./server_v2 -p 9000 -i 192.168.192.130
@yongboy
yongboy / jsonp.html
Created June 5, 2014 13:51
mqtt jsonp example
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jsonp example</title>
<script src="http://libs.baidu.com/jquery/1.5.0/jquery.js"></script>
<script type="text/javascript">
var clientId = "";
var urlPrefix = "http://127.0.0.1:8080/jsonp";
$(document).ready(function(){