Luna is a template engine that allows the use of Lua code in your templates.
It stays close to the Lua philosophy and is easy to use.
[[ -- this marks the beginning of a Lua code block pageTitle = "My Awesome Site!"
SHELL = /bin/sh | |
LIBS = | |
PREFIX = /usr | |
ALL = src docs examples tests | |
CLEAN = $(addsuffix -clean,$(ALL)) | |
INSTALL = $(addsuffix -install,$(ALL)) | |
UNINSTALL = $(addsuffix -uninstall,$(ALL)) |
Note: These are Minecraft server management scripts. They're quite handy. |
function tree(num) | |
local nums = tostring(num) | |
local lastnum = tonumber(nums:sub(-1)) | |
if lastnum%2 == 0 then | |
-- even lastnum | |
if num/2 == 1 then return num end | |
return { | |
num = num, | |
left = 2, | |
right = tree(num/2) |
local s = "abcdefghi" | |
local ss = string.sub | |
for n=1,1000000 do | |
local a,b,c,d,e,f,g,h,i = | |
ss(s, 1, 1), | |
ss(s, 2, 2), | |
ss(s, 3, 3), | |
ss(s, 4, 4), | |
ss(s, 5, 5), | |
ss(s, 6, 6), |
#!/usr/bin/env lua | |
-- _ | |
-- __ ___ __ ___ | |_ _ _ _ __ ___ _ __ | |
-- \ \ /\ / / '_ ` _ \| __| | | | '_ \ / _ \ '__| | |
-- \ V V /| | | | | | |_| |_| | |_) | __/ | | |
-- \_/\_/ |_| |_| |_|\__|\__, | .__/ \___|_| | |
-- |___/|_| | |
-- public domain code | |
local usage = [[ | |
usage: %s [--interval #] ([--loop]|[--noloop]) <([file]|[--text "desu"])> |
return 5, 5, {{255, 255, 255, 255}}, { | |
{{1, 1, 1, 1, 1}, | |
{0, 0, 0, 1, 0}, | |
{0, 0, 1, 0, 0}, | |
{0, 1, 0, 0, 0}, | |
{1, 1, 1, 1, 1}} | |
} |
-- this goes in your LUA_PATH, which you can find out by running: | |
-- lua -e 'print(package.path:sub(22,package.path:sub(22):find("%?%.lua")+20))' | |
-- first, require("printr") | |
-- then, use the function printr() | |
-- this code is public domain | |
local stringFormat,stringRep,stringChar = string.format,string.rep,string.char | |
local tableInsert,tableConcat = table.insert,table.concat | |
local function serializevalue(v, d, n) |
-- this goes in your LUA_PATH, which is usually: | |
-- /usr/share/lua/5.1/ | |
-- /usr/local/share/lua/5.1 | |
-- C:\Program Files\Lua\5.1 | |
-- first, require("printr") | |
-- then, use the function printr() | |
-- this code is public domain | |
local stringFormat,stringRep,stringChar = string.format,string.rep,string.char | |
local tableInsert,tableConcat = table.insert,table.concat |
#!/usr/bin/env lua | |
-- This code is public domain, you may use it however you like. | |
local md5 = require("md5") | |
local tonumber = tonumber | |
local ioOpen,ioRead = io.open,io.read | |
local osExecute = os.execute | |
local tableConcat,tableInsert = table.concat,table.insert | |
if not arg[1] or not arg[2] or not arg[3] then | |
print("Usage: "..arg[0].." EncodeString OutResolution OutFilename") |