This file contains hidden or 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
#include <stdio.h> | |
#include <lua.h> | |
#include <lualib.h> | |
#include <lauxlib.h> | |
#define DIE(e) do { fprintf(stderr, "FATAL: %s\n", e); return 1; } while (0) | |
static void l_getargs(lua_State * L, int argc, const char ** argv) { | |
int i; | |
lua_newtable(L); |
This file contains hidden or 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 users: | |
-- $ htpasswd -s -c /etc/nginx-rtmp/.htpasswd streamname | |
-- stream: | |
-- $ ffmpeg -i foo.mp4 -c copy -f flv rtmp://abc.de/streamname?auth=password | |
local users = {} | |
for line in io.lines("/etc/nginx-rtmp/.htpasswd") do | |
local user, pass = line:match("([^:]+):{SHA}([^\n]+)") | |
users[user] = pass | |
end |
This file contains hidden or 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 asr = {} | |
function asr.equal(a, b) return a == b end | |
function asr.error(fn, ...) local ok, out = pcall(fn, ...) return (not ok) and out end | |
function asr.match(a, b) return tostring(a):match(b) end | |
function asr.type(a, b) return type(a) == b end | |
local mt = {} | |
function mt.__index(t, k) | |
if not asr[k] then return end | |
return function(...) |
This file contains hidden or 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
#!/bin/sh | |
ARIA2_URI=${ARIA2_URI:-127.0.0.1:6800} | |
[ -n "$ARIA2_SECRET" ] && SECRET='"secret":"$ARIA2_SECRET", ' | |
die() { | |
[ -n "$1" ] && echo $1 | |
cat << EOF | |
Usage: $(basename $0) OPTION (VALUE) | |
Available options: |
This file contains hidden or 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
-- $ lua imgur.lua abcde [fghij] | |
local leet = { | |
["o"] = 0, ["i"] = 1, ["e"] = 3, ["a"] = 4, ["s"] = 5, ["t"] = 7 | |
} | |
local teel = { | |
[0] = "O", [1] = "I", [3] = "E", [4] = "A", [5] = "S", [7] = "T" | |
} |
This file contains hidden or 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
#! /bin/sh | |
error() { | |
echo >&2 "$1" | |
exit 1 | |
} | |
required() { | |
command -v "$1" >/dev/null 2>&1 || error "$1 required but not installed; quitting" | |
} |
This file contains hidden or 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
CC = gcc | |
LUA = luajit | |
loader: loader.o myscript.l.o | |
$(CC) $(LDFLAGS) -o $@ $^ | |
%.l.o: %.lua | |
$(LUA) -bg $^ $@ |
This file contains hidden or 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 function parse_url(url) | |
local out = {} | |
url = string.gsub(url, "#(.*)$", function(f) | |
out.fragment = f | |
return "" | |
end) | |
url = string.gsub(url, "^([%w][%w.+-]*):", function(s) | |
out.scheme = s | |
return "" | |
end) |
This file contains hidden or 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 function prettyprint(t, l) | |
l = l or 0 | |
for k, v in pairs(t) do | |
io.write(string.rep(" ", (l * 4)), k, " = ") | |
if type(v) == "table" then | |
io.write("table:\n") | |
prettyprint(v, l+1) | |
else | |
io.write(tostring(v), "\n") | |
end |
This file contains hidden or 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
static int cf_tolua(lua_State *L) { | |
lua_pushliteral(L, "hello"); | |
return 1; | |
} | |
static int cf_fromlua(lua_State *L) { | |
const char *str = lua_tostring(L, 1); // first argument passed in; second would be at index 2 | |
printf("%s\n", str); | |
return 0; | |
} |
NewerOlder