Skip to content

Instantly share code, notes, and snippets.

View moteus's full-sized avatar

Alexey Melnichuk moteus

View GitHub Profile
@moteus
moteus / get_win_ver.lua
Last active December 21, 2015 18:49
Detecting windows and service pack versions
local function exec(str)
local f, err = io.popen(str .. " 2>&1", "r")
if not f then return nil, err end
local str, err = f:read("*all")
f:close()
if str then return str end
return str, err
end
local WINVER = {
@moteus
moteus / prefix_tree.lua
Created June 21, 2013 08:32
Finds longest prefix from prefix list for given string
------------------------------------------------
-- Общие функции для работы с деревом --
------------------------------------------------
local default_compare = function(lhs, rhs) return lhs == rhs end;
local default_char_set = {'0','1','2','3','4','5','6','7','8','9'};
local INVALID_VALUE_ALWAYS_NIL = {}
--Удаляет все пустые ветви в дереве
local pack_empty