Tag: Lua

Lua Template Engine Yet Again



Introduction After writing a template engine in Lua, I found some deficiencies and wrote a few more iterations. After having used the template engine for quite a while, I’ve made a few enhancements and some fixes. This is hopefully the final version of the template engine. <h1... Continue reading

Lua For Loop Scope



Introduction One odd thing about Lua when compared to other programming languages is, everything is global by default. Take this for example: function func_a() q_var = 7 end func_a() print(q_var) Once... Continue reading

Lua-stater a Lua State Machine



At work I use state machines extensively in one of our applications. I’ve found state machines to be very powerful when working with messaging. They are especially useful when combined with event based processing, where an event comes in, the current state can process and move to the next state... Continue reading

Lua Ternary



Lua doesn’t have true ternary operator but there is a way to mimic the behavior. This is one of the biggest issues people who aren’t used to Lua have when reading Lua code. For the most part Lua is simple and straight forward to understand. Assuming a blocky and easy... Continue reading

Lua Case Insenstive Table



Introduction This is something I wrote for PenLight but alas it wasn’t merged. The problem they had is the use if __pairs which isn’t present in Lua 5.1. The project wants to maintain compatibility with 5.1 and LuaJIT which targets 5.1. All the Lua projects I... Continue reading

Lua-perforator a Lua Profiling Module



When I wrote the fixed width integer part of my Lua number library there were some performance issues. Even though I kept it simple and I knew a it wasn’t going to be quick, I did find there were a few places that needed to be optimized. To this... Continue reading

Lua-hashings a Lua Hash Library



A while back I wrote lua-nums and said it was working on a project that needed its features. Well, this is that project! lua-hashings is a pure Lua cryptographic hash library. This all started with crc32 and a work project. I was working with a third party API... Continue reading

Lua-nums a Lua Number Library



One area that I’ve always found problematic in Lua is its number type. It’s a one size fits all solution and there are things I want to do that doesn’t really work with it. I’m mainly a C programmer and I’ve found unsigned integer wrapping to be useful in many... Continue reading

Binary Headers



Introduction Earlier in the year I wrote a Lua implementation of xxd -i (it’s at the bottom under the “Embedding” section). I wrote this because a few platforms I was working with didn’t support xxd. I didn’t want to attempt compiling and installing it. I had Lua installed... Continue reading

Lua Template Engine Revisited



Introduction A while ago I wrote a template engine in Lua. This engine was fairly basic and I wrote it for work as a proof of concept. It was meant as a way to see this was a viable solution. After moving forward with the project I found... Continue reading

Extending an Application with Lua Plugins



Introduction A very common use of the Lua language (which is a very versatile) is using Lua to extend an application via plugins. Many popular games use Lua for this very purpose. Adding a plugin framework to an existing application is trivial with Lua. Also, Lua provides a very... Continue reading

Using Lua as a Templating Engine



Introduction There are a lot of templating engines to choose from. The vast majority of which are primarily geared toward the web. Meaning they’re specially designed for outputting HTML/XML documents. Lua provides more flexibility and can easily be used as a general templating engine. Also, Lua is very easy... Continue reading

Wrapping a Lua module in C



Introduction So far I’ve covered wrapping a C library in Lua, writing a Lua module, and calling Lua from C. The next step is using this knowledge to wrap a Lua module in C. Basically, the opposite of wrapping a C library in Lua for use... Continue reading

Calling Lua From C



Introduction One very useful feature of Lua is how easy it is to work with from C. Unlike other scripting languages Lua’s C support goes to and from. Meaning you not only can call C from Lua but you can call Lua from C. Often you’ll see applications written... Continue reading

Writing Lua Modules



Introduction With Lua 5.2 the recommended way to write modules changed. Instead of using module(“mymodule”, package.seeall) the recommendation now is to create a local table, put all of the module’s functions in it and return the table. The big difference is a local table does not register the module... Continue reading

Wrapping a C library in Lua



Introduction An often overlooked feature of Lua is the C API. The most common use I’ve seen is to allow Lua scripts to use existing C libraries instead of reimplementing existing functionality in pure Lua (which is not always feasible). Fortunately, Lua has very strong integration with C and... Continue reading

ARC ActiveX Apple B&N Base64 C lang COM DLL DNS Device Docker FLAC FT GUI GeR2 JNI Javascript Linux Lua Lua C API Mac N770 OS X Off Road OpenSSL REST API STR Shocks Sigil Suspension TLS TOC TRD TRD Pro TRD Sport Tacoma Toyota Vaultwarden Windows WireGuard about ad blocking algorithm amazon analysis android apnx app arch linux automotive backup bash batteries bitwarden book bookeen bookview bug bzr c++ calibre car cats certbot compression configuration container conversion copyright copyright infringement cover cso cybook data structure decoding decompression development device interfaces direction distros dmca donations downloader drm dropbox duplicity eReader ebook ebooks editor electronics encoding epub fb2 files focus st formats formatting future gadgets generic type get books git github gnome google gpl guide hardening headless heuristic hex hg htmlz iOS ideas image intel internationalization interop java jekyll json kernel kindle kwin language law lebookread legal library linode maintenance maintenance programming malware blocking markdown memory mobi mp3 music nginx nook objective-c opds openid opensearch opf packages palmdoc password manager pcre pdb pdf pgm plans play store plucker plugin pml pmlz pocket pro podcast podman ppa print project management prs prs300 prs505 prs700 prs900 pyqt python qt rb regex release restic reveiw reverse engineer reverse proxy review rtf s2n scm screen saver screenshot script search security server sort sorting source code specification spell check spideroak ssl store sync t2b t4b tcr textile thanks thread threading thumbnail tips translations truck txt txtz ubuntu unbound usb vault video vpn vps widget wordpress wpmu x11 xlib xorg xxd yubikey zip zsh ztxt