- Nov 2019
-
github.com github.com
-
regex library for lua. The string.match doesn't support some characters such as
|
so we need to use a more complete set.
-
-
howtomakeanrpg.com howtomakeanrpg.com
-
t = { name = "Bob" } function t:sayHello() -- note the 't:' part print("Hello" .. self.name) end t:sayHello() -- "Hello Bob"
Implementing a class in lua.
Tags
Annotators
URL
-
-
github.com github.com
-
Nice example repo for lua.
-
lint: @luacheck -q .
We should probably run a lua linter at some point.
-
-
github.com github.com
-
-- patch os.getenv to not have existing environment variables interfere local _getenv = os.getenv os.getenv = function() end -- luacheck: ignore finally(function() os.getenv = _getenv -- luacheck: ignore end)
patch os.getenv
-
-
help.interfaceware.com help.interfaceware.com
-
Tip: If you see require('mymodule') it is just an alternative syntax for require 'mymodule' the two perform identically and are interchangeable.
-
Here is the code from main() using different variables, both work fine:
How to import and call a function in a module in lua. You can also use the local MM = require('mymodule') syntax.
-
This is the module, notice how the interface table mymodule is local and is returned on the last line of the module:
How to return functions from a module in lua.
-
-
github.com github.com
-
It's good practice to keep file loaded by content_by_lua_file at a minimum and place all processing logic into external modules. This allows lua_code_cache to work its magic and simplifies your testing.
Kinda counter intuitive but in a way it makes sense since require does built in caching and it makes it easier to test. This actually makes me feel a lot more comfortable making a utils area and just testing the functions in there.
-
-
www.lua.org www.lua.org
-
how require works in lua
-
-
github.com github.com
-
output = lustache:render("{{title}} spends {{calc}}", view_model)
This will return a string of the rendered template.
Tags
Annotators
URL
-
- Oct 2019
-
lua.2524044.n2.nabble.com lua.2524044.n2.nabble.com
-
Is anyone aware of a lua http lib that supports keepalive?
When sending a request you can pass the following keepalive settings which will keep the connection open:
local http = require "resty.http" local httpc = http.new() httpc:connect("127.0.0.1", 9081) local response, err = httpc:request({ path = "/proxy" .. ngx.var.request_uri, method = "HEAD", headers = ngx.req.get_headers(), keepalive_timeout = 60, keepalive_pool = 10, })
-
-
openresty-reference.readthedocs.io openresty-reference.readthedocs.io
-
non-blocking internal requests
Note ngx.location.capture only works on internal requests which means if you want to request an external endpoint dynamically then you need to setup something like below and call that internal endpoint instead of calling the external url directly.
Say for example you want to send a request to / endpoint with the thirdparty url as part of the path (
http:proxy-server.com/http://example.com
).location /external/ { internal; set $upstream ""; rewrite_by_lua_file ./lua/get_external.lua; resolver 8.8.8.8; proxy_pass $upstream;
Where lua/get_external.lua:
-- strip beginning '/' from uri path ngx.var.upstream = ngx.var.request_uri:sub(2)
-
-
github.com github.com
-
set $template_root /usr/local/openresty/nginx/html/templates;
We should probably use this instead of root since root has other implications.
Tags
Annotators
URL
-
-
github.com github.com
-
docker-openresty/alpine/Dockerfile.fat
openrestry nginx image that Hypothesis's new proxy-server is based on.
-
- Sep 2019
-
openresty-reference.readthedocs.io openresty-reference.readthedocs.io
-
This API function (as well as ngx.location.capture_multi) always buffers the whole response body of the subrequest in memory. Thus, you should use cosockets and streaming processing instead if you have to handle large subrequest responses.
So my interpretation of this is the request is issued, the entire response is buffered in memory, then res.headers is read from that buffer. I wonder if there is a way to cut off this buffer and close the connection early such that only the headers make it into the buffer for responses that are very large.
-
Network I/O operations in user code should only be done through the Nginx Lua API calls as the Nginx event loop may be blocked and performance drop off dramatically otherwise. Disk operations with relatively small amount of data can be done using the standard Lua io library but huge file reading and writing should be avoided wherever possible as they may block the Nginx process significantly. Delegating all network and disk I/O operations to Nginx's subrequests (via the ngx.location.capture method and similar) is strongly recommended for maximum performance.
Very important ngx.location.capture does not block in nginx.
-
-
stackoverflow.com stackoverflow.com
-
local LuaSocket = require("socket") client = LuaSocket.connect("example.com", 80) client:send("GET /login.php?login=admin&pass=admin HTTP/1.0\r\nHost: example.com\r\n\r\n") while true do s, status, partial = client:receive('*a') print(s or partial) if status == "closed" then break end end client:close()
How to issue an http request through a socket in lua.
-
-
stackoverflow.com stackoverflow.com
-
ngx.unescape_uri(str)
decode a url string
-
-
stackoverflow.com stackoverflow.com
-
ngx.log(ngx.STDERR, 'your message here')
For debugging and printing strings to the console.
-
-
www.lua.org www.lua.org
-
print(a .. " World") --> Hello World
-
-
openresty-reference.readthedocs.io openresty-reference.readthedocs.io
-
header_filter_by_lua 'ngx.header.Foo = "blah"';
Not sure why you wouldn't use raw nginx for this.
-
access_by_lua ' local res = ngx.location.capture("/auth") if res.status == ngx.HTTP_OK then return end if res.status == ngx.HTTP_FORBIDDEN then ngx.exit(res.status) end ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
Potentially something like this for getting the content-type response header and using that to decide which proxy server to send the original request to.
-
The Lua code cache can be temporarily disabled during development by switching lua_code_cache off
For dev mode switch the lua file cache off.
-
-
github.com github.com
-
it defaults to /etc/nginx/conf.d/default.conf
-
-
github.com github.com
-
default nginx config for openresty lua
-
-
github.com github.com
-
docs on lua templating
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
resolver 8.8.8.8;
-
-
docs.coronalabs.com docs.coronalabs.com
-
string.sub() Returns a substring (a specified portion of an existing string).
-
-
github.com github.com
-
local data = ngx.req.get_body_data()
Tags
Annotators
URL
-
- Jul 2017
-
openresty.org openresty.org
-
since
lua-resty-redis
can not be used inset_by_lua*
, dynamic routing based on redis should be impelemented in theaccess_by_lua
block
-
- Apr 2017
-
terralang.org terralang.orgTerra1
-
Terra is a low-level system programming language that is embedded in and meta-programmed by the Lua programming language
-
- Feb 2017
-
github.com github.com
-
The test system used in lua-resty-waf
Tags
Annotators
URL
-
- Jan 2017
-
blog.datamules.com blog.datamules.com
- Dec 2016
-
github.com github.com
-
olivinelabs.com olivinelabs.com
Tags
Annotators
URL
-
- Sep 2016
-
forum.renoise.com forum.renoise.com
-
I don't know what then, I just remember somehow. Around the same time I install renoise, I also install vim. Then in renoise I go to Help>Show Preferences Folder.... Then I right click on Config.xml, then edit in VIM. Then I /search for showscr or something like that. Change false into true, done. On windows sometimes I'm lazy and I just modify the one shortcut that I use to have --scripting-terminal or something as an argument. Also: if you really do a lot of (re)installs I would advise to back up your Config.xml anyway, just like the KeyBindings.xml, TemplateSong.xrns, etc, it'll save you a lot of time right?
How to enable Scripting Tools in Renoise Tools menu
-