This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Load Vue library | |
package.loadlib("https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js", "*") | |
-- Get Object helper | |
local Object = dofile("https://gist.githubusercontent.com/daurnimator/5a7fa933e96e14333962093322e0ff95/raw/8c6968be0111c7becc485a692162ad100e87d9c7/Object.lua").Object | |
local myapp = js.new(js.global.Vue, Object{ | |
el = "#foo"; | |
template = [[ | |
<div id="foo">{{message}}</div> | |
]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This code monkey patches cqueues primitives to allow for transparent use of cqueues inside of tarantool | |
local cqueues = require "cqueues" | |
local fiber = require "fiber" | |
local socket = require "socket" -- https://tarantool.org/en/doc/1.7/reference/reference_lua/socket.html (not luasocket) | |
local old_step; old_step = cqueues.interpose("step", function(self, timeout) | |
if cqueues.running() then | |
fiber.yield() | |
return old_step(self, timeout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a key + cert. see https://daurnimator.com/post/115624714644/howto-generate-a-self-signed-ssl-cert-in-one | |
openssl req -newkey 2048 -keyout server.pem -nodes -x509 -out server.pem -batch | |
# Start http server | |
openssl s_server -port 4555 -www |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env tarantool | |
local cqueues = require "cqueues" | |
local fiber = require "fiber" | |
local socket = require "socket" | |
package.loaded["http.client"] = nil -- tarantool has a namespace clash | |
local websocket = require "http.websocket" | |
local cq = cqueues.new() | |
-- Hook up cqueues loop inside tarantool fiber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
location /.well-known/acme-challenge { | |
alias /etc/dehydrated/.acme-challenges; | |
} | |
location / { | |
return 302 https://$host$request_uri; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ /* add node's require() to lua searchers */ | |
lauxlib.luaL_requiref(L, lua.to_luastring("package"), lualib.luaopen_package, 0); | |
if (lua.lua_getfield(L, -1, lua.to_luastring("searchers")) != lua.LUA_TTABLE) | |
lauxlib.luaL_error(L, lua.to_luastring("'package.searchers' must be a table")); | |
lua.lua_pushcfunction(L, function(L) { | |
let name = lauxlib.luaL_checkstring(L, 1); | |
let path; | |
try { | |
path = require.resolve(lua.to_jsstring(name)); | |
} catch(e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local js = require "js" | |
-- Helper to copy lua table to a new JavaScript Object | |
-- e.g. Object{mykey="myvalue"} | |
local function Object(t) | |
local o = js.new(js.global.Object) | |
for k, v in pairs(t) do | |
assert(type(k) == "string" or js.typeof(k) == "symbol", "JavaScript only has string and symbol keys") | |
o[k] = v | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local js = require "js" | |
local window = js.global | |
local document = window.document | |
local function setElement(elem, props) | |
for k, v in pairs(props) do | |
if type(k) == "number" then | |
-- skip | |
elseif type(v) == "table" then | |
local to = elem[k] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
:local peerid $dn42peerid | |
:local nbpings 5 | |
/tool fetch url=("https://dn42.us/peers/pending/" . $peerid) dst-path=dn42-peerfinder | |
:local pending [/file get dn42-peerfinder contents] | |
/file remove dn42-peerfinder | |
:local reqidstart [:find $pending "\"req_id\": \"" -1] | |
:if ($reqidstart > 0) do={ | |
:set reqidstart ($reqidstart+11) | |
:local reqid [:pick $pending $reqidstart [:find $pending "\"" $reqidstart]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local document = js.global.document; | |
local extra = {} | |
function extra:append(x) | |
self.__wrapped__:append(x) | |
return self | |
end | |
local function wrap(e) | |
return setmetatable({ |