FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups  Who is OnlineWho is Online   Join! (free) Join! (free)  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  • Welcome
  • Guest

Anyone use Lua?

 
Post new topic   Reply to topic    myfreeforum.org Forum Index -> Off Topic
View previous topic :: View next topic  
Author Message
myff admin
Site Admin
Site Admin
FLAG

Virtual Cash: 92890

Joined: 22 May 2005
Posts: 32203



Add Karma

rated by 281 members
Add Comment
Show Comments


online/offline
PostPosted: Sat Feb 25, 2012 1:23 am    Post subject: Anyone use Lua?  Reply with quote

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.
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums
Back to top
View user's profile Send private message Visit poster's website
myff admin
Site Admin
Site Admin
FLAG

Virtual Cash: 92890

Joined: 22 May 2005
Posts: 32203



Add Karma

rated by 281 members
Add Comment
Show Comments


online/offline
PostPosted: Sat Feb 25, 2012 8:47 am    Post subject: Reply with quote

A LUA example.

Code:

function file_exists(path)
  local attr = lighty.stat(path)
  if (attr) then
      return true
  else
      return false
  end
end
    --print(lighty.env["uri.path"]);
    --print(lighty.env["physical.path"]);
    typepos = lighty.env["uri.path"]:match(".*()%..+$")
    if (typepos) then
        type = lighty.env["uri.path"]:sub(typepos+1)
    else
        type =  "";
    end
    --print(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
       end

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

        lighty.content = {  { filename = path } }
        lighty.header["Content-Type"] = contenttype
        return 200
       else
          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 .. "&"
          --print(command)
          os.execute(command)
       end
   end


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.
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums
Back to top
View user's profile Send private message Visit poster's website
myff admin
Site Admin
Site Admin
FLAG

Virtual Cash: 92890

Joined: 22 May 2005
Posts: 32203



Add Karma

rated by 281 members
Add Comment
Show Comments


online/offline
PostPosted: Sun Feb 26, 2012 12:39 am    Post subject: Reply with quote

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.
_________________

Family Friendly Shareware | | Web Design/Services | Free Forums
Back to top
View user's profile Send private message Visit poster's website
CodeDos
Newbie
Newbie
FLAG

Virtual Cash: 50

Joined: 24 Aug 2014
Posts: 5



Add Karma

rated by 0 members
Add Comment
Show Comments


online/offline
PostPosted: Mon Aug 25, 2014 4:32 am    Post subject: Reply Reply with quote

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.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    myfreeforum.org Forum Index -> Off Topic All times are GMT
Page 1 of 1
 
 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2005 phpBB Group
Create your own free forum | Buy a domain to use with your forum