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 iter, dir = lfs.dir('.') | |
local file = dir:next() | |
while file and file ~= 'foo' do | |
print(file) | |
file = dir:next() | |
end | |
dir:close() |
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
require 'luarocks.require' | |
require 'cosmo' | |
require 'mustache' | |
-- This needs the Cosmo in source control to work (because of the nested long strings and | |
-- cosmo.last - install with luarocks install cosmo --from=http://luarocks.org/repositories/rocks-cvs | |
do | |
local template = "$cards[[$if{show}[[$rank of $suit$if{not _last}[[, ]]]]]]" | |
local view = { |
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
template = "$do_cards[[$rank of $suit, ]]" | |
view = { | |
{ rank = "Ace", suit = "Spades" }, | |
{ rank = "10", suit = "Hearts" }, | |
} | |
result = cosmo.fill(template, { | |
do_cards = function() | |
for i,v in ipairs(view) do | |
cosmo.yield(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
template = "$cards[[$rank of $suit, ]]" | |
view = { | |
{ rank = "Ace", suit = "Spades" }, | |
{ rank = "10", suit = "Hearts" }, | |
} | |
result = cosmo.fill(template, { cards = view }) | |
print(result) -- Ace of Spades, 10 of Hearts, |
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
template = "Today is $date_string{ today }" | |
result = cosmo.fill(template, { | |
today = os.time(), | |
date_string = function (args) | |
return os.date("%B %d, %Y", args[1]) | |
end | |
}) | |
print(result) -- Today is October 23, 2009 |
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
template = "$cards[[$if{show}[[$rank of $suit, ]]]]" | |
view = { | |
{ rank = "Ace", suit = "Spades", show = true }, | |
{ rank = "5", suit = "Clubs" }, | |
{ rank = "10", suit = "Hearts", show = true }, | |
} | |
result = cosmo.fill(template, { cards = view }) | |
print(result) -- Ace of Spades, 10 of Hearts, |
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
location ~ ^(.+\.lua)(.*)$ { | |
root html; | |
fastcgi_pass 127.0.0.1:9100; | |
fastcgi_index index.lua; | |
fastcgi_split_path_info ^(.+\.lua)(.*)$; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} |
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
$ spawn-fcgi -a 127.0.0.1 -p 9100 -F 4 -- ~/lualr2/bin/wsapi.fcgi |
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
require "sputnik.wsapi_app" | |
require "orbit" | |
require "wsapi.util" | |
local filter = orbit.new() | |
local sputnik = sputnik.wsapi_app.new{ | |
VERSIUM_PARAMS = { '/Users/mascarenhas/sputnik/wiki-data/' }, | |
BASE_URL = '/sputnik.ws', | |
PASSWORD_SALT = '6QQQuj9A2aUqwKq5YQsCCG8hEZZX1Lf2praCyM1I', |
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 lua | |
-- Does a "luarocks make" with symlinks from your source tree instead of copying | |
-- Run with "lua luarocks_ln.lua make <rockspec>" at the root of the source tree | |
local command_line = require("luarocks.command_line") | |
local fs = require("luarocks.fs") | |
require "lfs" |
OlderNewer