Archive for Before posting please check the "stickies" in the support forums.
Please ask questions in real English and not "txt". You will get a better response.
Please do not ask support questions via PMs.

The free forums are now under new ownership, a full announcement will be made shortly Forum Index -> Off Topic
myff admin

Anyone use Lua?

It's an embedded scripting language with a lot of nice features, albeit some of those features making it unreadable unless you know the language

I'm currently testing some firewall stuff written in it, and also some caching stuff. I have a feeling that the fact that you can write some quite clever and specific caches in lua when using lighttpd might be one of the reasons that our current lighttpd cache is not keeping up with releases  

Quite possibly less than 100 lines of lua code will create an image cache that fits the bill better than our current cache.

I find the history of lua quite interesting as it started in 1993, a time when I was working on Alex a language with some similarities, Alex was good at high level cross platform stuff, quite the opposite of Lua which has dealt with low level data/code semantics as its core.

I don't really know the evolutionary path of Lua which has has 19 more years to evolve than the ill fated Alex, but as a software engineer I do like the idea of the solid foundation of Lua, with Alex data semantics were being added as needed which is really the wrong way round.
myff admin

A LUA example.


function file_exists(path)
  local attr = lighty.stat(path)
  if (attr) then
      return true
      return false
    typepos = lighty.env["uri.path"]:match(".*()%..+$")
    if (typepos) then
        type = lighty.env["uri.path"]:sub(typepos+1)
        type =  "";
   if (type == "jpg" or type=="swf" or type == "png" or type == "gif" or type == "jpeg") then
        cached = nil
        dirpath = "/data/cache/"..lighty.env["uri.authority"]
        path =  dirpath ..lighty.env["uri.path"]
        --print("search path"..path);
       if (file_exists(path)) then
                cached = true

       if (cached) then
        --print("found in cache");
        contenttype = "image/".. type

        lighty.content = {  { filename = path } }
        lighty.header["Content-Type"] = contenttype
        return 200
          newrequestpath = "http://" .. lighty.request["Host"]..lighty.env["uri.path"]
          newrequestpath = newrequestpath:gsub("images2","iwww");
          --print("request "..newrequestpath)
          os.execute("mkdir -p "..dirpath)
          command = "wget -O ".. path .." ".. newrequestpath .. "&"

may still be bugs in that and it is not sophisticated, but works as an image cache, albeit for images we know will never change, and which can be found on an alternate path so we can simply do a wget to populate cache. In the event the image is not already cached the system will fall through to a standard request for the image, leaving wget running as a background task setting up the cache for the next request.
myff admin

on further examination that example need and has been enhanced, and sadly there do appear issues in the scripting language.
on a lot of levels nothing ever changes, there are many parallels with issues with Alex 18 years ago.
I guess one difference is open source.


Yep. I know this topic hasn't been posted in awhile. But I am making a point here. I do know Lua In fact Self taught Myself. No Reading Manuals books or any kind. Same for some other program languages I know.

But never call Lua LUA. I been hearing other Lua Users.

But heck MyFF Admin If you understand Lua I got a Game for you to play if Haven't before. That is where I am Lua away on. Making cool new items and such.

Yeah But do you know Batch? Since I do. Lately been working lots ideas and games. I am creating a RPG. Yeah I know all Batch is Text rated but if you know how code batch and the Characters you can do some impossible stuff. No doubt about it. And the cool thing about Teaching myself to code without books or tutorials I can write more.

But hey It took me 30s I think figure out Batch and Lua.

Later I will create a topic if not Created for Just Programming Languages. And maybe a forum. Where can share any programming languages know and learn.

But anyway How many characters can MyFF phpBB2 fit? since I don't see a thing we can set it to I know the signature is 255. But mostly I have it 455 On phpBB3. Forum Index -> Off Topic
Page 1 of 1
Create your own free forum | Buy a domain to use with your forum