Lua - Part 4

Jan 11, 2018

will probably use http.request (lua-http) instead of socket.http. Nope. Used socket.http.

luarocks install lua-cjson

https://www.kyne.com.au/~mark/software/lua-cjson.php

luarocks install luasec

luarocks install http -- for lua-http above by daurnimator

for luasec:

https://stackoverflow.com/questions/42628888/get-https-page-content-with-lua

http://notebook.kulchenko.com/programming/https-ssl-calls-with-lua-and-luasec

require("socket")
local https = require("ssl.https")
local body, code, headers, status = https.request("https://www.google.com")
print(status)


old but interesting from the regex dude
http://regex.info/blog/lua/json

Jan 18, 2018

YAML

https://luarocks.org/modules/gvvaughan/lyaml
https://github.com/gvvaughan/lyaml

install:

web template

when i use open resty nginx, then i'll use this:
https://luarocks.org/modules/bungle/lua-resty-template
https://github.com/bungle/lua-resty-template

trying mustache.

general mustache templating info:
http://mustache.github.io
http://mustache.github.io/mustache.5.html

lua version:
https://luarocks.org/modules/olivine-labs/lustache
http://olivinelabs.com/lustache/
[x] https://github.com/Olivine-Labs/lustache

https://github.com/mustache/mustache/issues/113

Mustache appears to encode everything parsed through it as a {{variable}} but I don't want this to happen. How do I stop it in an instance of mustache? I don't want to break core code.

Your first option for doing variable interpolation without HTML escaping is to use either the triple mustache {{{unescapedInterpolation}}} tag (or its alternate-delimiter-friendly equivalent, {{&unescapedInterpolation}}).

http://olivinelabs.com/lustache/

All variables are HTML-escaped by default. If you want to render unescaped HTML, use the triple mustache: {{{name}}}. You can also use & to unescape a variable.

Jan 24, 2018

pattern matching

http://lua-users.org/wiki/PatternsTutorial

XML

i'll need to install one or two xml/rss related modules.

https://luarocks.org/modules/luarocks/luaexpat

https://luarocks.org/modules/gaspard/xml

https://luarocks.org/modules/slact/feedparser

Jan 31, 2018

installed luaexpat. update: i don't understand this module and usage. looking elsewhere. won't use this.

luarocks install luaexpat

http://www.keplerproject.org/luaexpat/

http://lua-users.org/wiki/DetectingUndefinedVariables
https://github.com/mpeterv/luacheck

luarocks install luacheck


http://www.keplerproject.org/luaexpat/lom.html

Lua Object Model (LOM) is a representation of XML elements through Lua data types. Currently it is not supposed to be 100% complete, but simple.

https://github.com/LuaDist/luaexpat/blob/master/src/lxp/lom.lua


More XML.

http://lua-users.org/wiki/LuaXml


https://github.com/manoelcampos/xml2lua - not for Lua v5.3

xml2lua is an XML parser written entirely in Lua which doesn't depend on any external C/C++ library.

http://manoelcampos.com/xml2lua/


https://stackoverflow.com/questions/40634946/how-to-parse-xml-file-in-lua ---- answer suggested xmlreader


on feb 8, 2018, i installed this module.

luarocks install xmlua

https://luarocks.org/modules/clear-code/xmlua
https://clear-code.github.io/xmlua/
luarocks install xmlua

forget this too.

It uses LuaJIT's FFI module.

That's a bigger install.

http://luajit.org/ext_ffi.html


feb, 2018 cont.

now trying this

luarocks install luaxml

https://luarocks.org/modules/djerius/luaxml

https://github.com/LuaDist/luaxml

jeesh. just looking for a pure lua simple xml parser. i have little use for xml parsing, mainly for rss files and in the toledowx app, a custom xml file, provided by the nws.

JSON, JSON, JSON is way more preferred by me. far easier to deal with.


tried this:
https://github.com/Phrogz/SLAXML

manually copied down two lua files and placed them in my lib directory.

i don't understand any of this xml parsing. it's not mapping to what i would consider proper lua tables in an easy to understand format. this is insane.

i would advise never processing xml in lua. i just want lua tables that make sense. the crap produced by two of the above xml parsers is hideous.


Data Dumper

http://lua-users.org/wiki/DataDumper

http://lua-users.org/wiki/TableSerialization

http://lua-users.org/wiki/TablesTutorial

https://www.tutorialspoint.com/lua/lua_arrays.htm

https://stackoverflow.com/questions/7274380/how-do-i-display-array-elements-in-lua


Penlight utilities - might be something to investigate.

http://stevedonovan.github.io/Penlight/api/index.html

http://stevedonovan.github.io/Penlight/api/manual/01-introduction.md.html#

It is often said of Lua that it does not include batteries. That is because the goal of Lua is to produce a lean expressive language that will be used on all sorts of machines, (some of which don’t even have hierarchical filesystems). The Lua language is the equivalent of an operating system kernel; the creators of Lua do not see it as their responsibility to create a full software ecosystem around the language. That is the role of the community.

https://github.com/stevedonovan/Penlight/blob/master/lua/pl/pretty.lua