Skip to content

Instantly share code, notes, and snippets.

View agentzh's full-sized avatar

Yichun Zhang agentzh

View GitHub Profile
agentzh /
Last active December 18, 2022 13:01
Create 2 network namespaces and bridge them and the default namespace together so that they can directly talk to each other via static IP addresses; also enable Internet access in all the namespaces via NAT.
#!/usr/bin/env bash
set -x
echo 1 > /proc/sys/net/ipv4/ip_forward || exit 1
ip netns del ns1 > /dev/null 2>&1
View a.txt
[agentzh@fed34-min ~ 0 ]$ sudo "dnf" install -y "openresty-openssl111-asan"
Last metadata expiration check: 0:00:01 ago on Tue May 11 12:26:10 2021.
Dependencies resolved.
Package Architecture Version Repository Size
openresty-openssl111-asan x86_64 1.1.1i-5.fc34 openresty 2.1 M
Installing dependencies:
libasan x86_64 11.1.1-1.fc
View hello.sp
[V=browser-hello.mp4] Hi, I'm Matthew from OpenResty Inc. In this video, I'll demonstrate how to implement a "hello world" HTTP interface using OpenResty.
First of all, we make sure we are using OpenResty's nginx.
[delay=0] $ export PATH=/usr/local/openresty/nginx/sbin:$PATH
$ which nginx
[S] It's usually in this path.
And then we go to the home directory.
View or-lua-module.sp
[V=browser-hello-module.mp4] Hello, I'm Matthew from OpenResty Inc. Today I'd demonstrate how to write your own Lua modules in your OpenResty applications, step by step.
Let's put our simple OpenResty application in a new directory named 'test-module'.
$ cd ~/
$ mkdir test-module/
$ cd test-module/
And then we create the sub-directory structure as always:
View youtube-subscribe.nav
goto ""
[Button "GOT IT"]=btn1
click -> btn1
[Button "NO THANKS"]=btn0
View rr-staprun-errors.tx
$ sudo rr /opt/stap-plus/bin/staprun hello.ko
rr: Saving execution to trace directory `/root/.local/share/rr/staprun-0'.
[FATAL /home/agentzh/git/rr/rr/src/]
(task 26471 (rec:26471) at time 394)
-> Assertion `t->regs().syscall_result_signed() == -syscall_state.expect_errno' failed to hold. Expected ENOSYS for 'init_module' but got result 0 (errno SUCCESS); execution of syscall unsupported by rr
Tail of trace dump:
real_time:2421511.598055 global_time:374, event:`SYSCALLBUF_FLUSH' tid:26471, ticks:453980
{ syscall:'close', ret:0x0, size:0x10 }
{ syscall:'openat', ret:0x3, size:0x10 }
View fix.patch
From 100d5e81de0f34ebba38472e373dece4c3449ea4 Mon Sep 17 00:00:00 2001
From: "Yichun Zhang (agentzh)" <>
Date: Tue, 3 Mar 2020 15:15:30 -0800
Subject: [PATCH] Bug: proc_mem_rss() broken on older kernels lacking
This is a regression introduced in commit de253786000.
buildrun.cxx | 3 +++
runtime/linux/autoconf-mm-shmempages.c | 5 +++++
agentzh / dns_server.lua
Created August 18, 2016 19:33
My first hacked version of silly Lua DNS server atop NGINX (with patched ngx_stream_lua_module).
View dns_server.lua
local bit = require "bit"
local byte = string.byte
local lshift = bit.lshift
local rshift = bit.rshift
local concat = table.concat
local insert = table.insert
local char = string.char
local band =
local sub = string.sub
local gsub = string.gsub
View gmail-stmp-tls.lua
local account = "" -- use your own gmail account
local password = "password" -- if you enable 2-phase authentication, you need to
-- generate and use a application-specific password here...
local sender_name = "Jon Snow"
local recipient = ""
local recipient_name = "Arya Stark"
local mail_title = "This is a test mail"
local mail_body = [[<html><body><p>Mail Body...</body></html>]]
View s390x-luajit2-test-failures.txt
=== test/unportable/math_special.lua
Failed test when running /home/agentzh/git/luajit2-test-suite/s390x-luajit math_special.lua 1: 132
=== test/ffi/ffi_enum.lua
/opt/luajit-s390x/bin/luajit-2.1.0-beta3: ffi_enum.lua:53: too many callbacks
Failed test when running /home/agentzh/git/luajit2-test-suite/s390x-luajit ffi_enum.lua 1: 256
=== test/ffi/ffi_nosink.lua
=== test/ffi/ffi_jit_array.lua
=== test/ffi/ffi_parse_struct.lua
=== test/ffi/ffi_arith_ptr.lua
=== test/ffi/ffi_const.lua