Skip to content

Instantly share code, notes, and snippets.

@fur-q
fur-q / imgur.lua
Last active August 29, 2015 14:16
imgur hilarity finder for best laughs time
-- $ 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"
}
#!/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:
@fur-q
fur-q / assert.lua
Last active November 26, 2015 15:19
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(...)
@fur-q
fur-q / auth.lua
Last active June 21, 2017 08:49
nginx rtmp/hls server setup
-- 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
@fur-q
fur-q / host.c
Created January 25, 2016 00:52
luajit script host
#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);