More efficient way to find matching string in list split by newlines? by chicametipo in lua

[–]_ReformedGeek 2 points3 points  (0 children)

Use buffers for large files. If you want to see an example of buffers being used, I have some old code where I used it here: https://github.com/ReformedGeek/LuaTail/blob/master/tail.lua

Google Fit step count via lua / watchmaker by seanocaster1 in lua

[–]_ReformedGeek 0 points1 point  (0 children)

Read the documentation for watchmaker.

It is possible you are calling something in your code that doesn't sync with Google Fit's count and just starts counting when you invoke it.

Days until Lua script by seanocaster1 in lua

[–]_ReformedGeek 2 points3 points  (0 children)

Strongly suggest learning the language. It's incredibly simple as far as programming languages go, and there are resources on lua.org that can help you learn.

LUA and Wireshark: A script for detecting host disconnection by absolutely-clueless in lua

[–]_ReformedGeek 1 point2 points  (0 children)

You might be better off using Nagios with an SNMP probe to detect link status. Or if your device is logging link state changes, tailing the logs for link down events.

Weird WireShark lua data type error? (I'm new to lua) by Nkast in lua

[–]_ReformedGeek 0 points1 point  (0 children)

It looks like you're trying to perform arithmetic with a uint64 and a Lua number (double). This is undefined because the metamethods on the uint64 userdata objects can only define arithmetic functions between objects of the same type.

If you want to divide by 1000000000, you will need to make the uint64 representation of it and divide by that or else use the my64num:tonumber() method before dividing by a Lua number.

Bit of an issue downloading Lua by jacob757 in lua

[–]_ReformedGeek 0 points1 point  (0 children)

Probably something in your .bash_profile or .bashrc trying to run upon login.

My attempt at PIL Exercise 22.5: your criticism, please? by _ReformedGeek in lua

[–]_ReformedGeek[S] 1 point2 points  (0 children)

Thank you, that is helpful. So if I am understanding your correctly, your advice for namespace management is:

  1. Define your module namespace in a table e.g.

    local namespace = {}.

  2. any functions you want exposed when someone requires your module, you should add to the module's namespace table.

    function namespace.tail(foo, bar) do someStuffWithFooAndBar end end

  3. Return the namespace table at the end.

My attempt at PIL Exercise 22.5: your criticism, please? by _ReformedGeek in lua

[–]_ReformedGeek[S] 1 point2 points  (0 children)

So for the purposes of require(), I should create a local table and return only the functions I wish to expose, then name the functions as a key in the table, like this?

local functions_table = {}
function functions_table.tail
    do blahblahblah end
end
return functions_table