Skip to content

Instantly share code, notes, and snippets.

Alexey Melnichuk moteus

Block or report user

Report or block moteus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ELF-symbol-resolution.md

ELF

ELF Header

The first portion of any ELF file is the ELF header. This generally provides offsets to other headers (program headers and section headers) within an ELF.

typedef struct {
  unsigned char e_ident[EI_NIDENT];
  uint16_t e_type;
@moteus
moteus / install_lua.txt
Last active Apr 4, 2019
Lua/Luarocks Install instruction on Windows
View install_lua.txt
-- make and install lua --
1. Download install http://mingw-w64.sourceforge.net/download.php
2. Download and unpack Lua source (http://www.lua.org/ftp)
Tested on Lua 5.1.5 and 5.2.2
3. Make Lua
- run mingw builds terminal
- cd to lua src dir
- run mingw32-make mingw
@moteus
moteus / prefix_tree.lua
Created Jun 21, 2013
Finds longest prefix from prefix list for given string
View prefix_tree.lua
------------------------------------------------
-- Общие функции для работы с деревом --
------------------------------------------------
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
@moteus
moteus / mkforwardlib.lua
Created Jan 9, 2014
Create proxy dll library on Windows. This script use `dumpbin` to list all export symbols. Example: `mkforwardlib lua51 lua5.1 X86` create lua5.1.dll as proxy to lua51.dll
View mkforwardlib.lua
local reallib
local fakelib
local machine
local extrasymbols = {}
local args = {...}
local errmsg
if args[1] then reallib = args[1] end
if args[2] then fakelib = args[2] end
if args[3] then machine = args[3] end
@moteus
moteus / dbf.lua
Created Aug 22, 2016
Basic IO for dbf file format.
View dbf.lua
local printf = function(...) return print(string.format(...)) end
local function prequire(...)
local ok, mod = pcall(require, ...)
if ok then return mod end
return nil, mod
end
local function iif(cond, val1, val2)
if cond then return val1 end return val2
@moteus
moteus / multi_request.lua
Last active Apr 13, 2018
Run multiple curl requests from coroutines simultaneously
View multi_request.lua
local cURL = require "cURL.safe"
local json = require "cjson.safe"
-------------------------------------------------------------------
local MultiRequests = {} do
MultiRequests.__index = MultiRequests
function MultiRequests.new(...)
local self = setmetatable({}, MultiRequests)
return self:__init(...)
@moteus
moteus / cache_perf.lua
Last active Nov 23, 2017
Basic cache perfomance test for FusionPBX
View cache_perf.lua
-- to run test
-- * copy file to ${script_dir}\cache_perf.lua
-- * in some domain create varialble
-- category: test
-- subcategory: test
-- type: bool
-- value: false
-- * copy domain uuid to `domain_uuid` variable
-- * from fs_cli run `lua cache_perf.lua 1000`
-- (1000 is number of iteration)
View gw_monitor.lua
--- Service for FusionPBX to monitor on gateway status
-- and send email notification when gateway change its status.
--
-- Require FusionPBX 4.3 or higher
--
-- start: `fs_cli -x 'luarun gw_monitor.lua'`
-- stop: `fs_cli -x 'lua service gw_monitor stop'`
-- pid file: `${script_dir}/run/gw_monitor.pid`
local email = 'mail@address'
@moteus
moteus / fusion_backup.lua
Last active Nov 2, 2017
Backup FusionPBX
View fusion_backup.lua
local FS_DIR = 'c:/FreeSWITCH'
local FUSION_DIR = 'c:/wamp/www/fusionpbx'
local NGINX_DIR = 'c:/nginxwin'
local PHP_DIR = NGINX_DIR .. '/php_5.4'
-- local PASSWORD = '' -- password to pgsql (optional)
-- local BACKUP_DIR = '' -- target directory (default cwd)
-----------------------------------------------------------
local path = require "path"
local date = require "date"
@moteus
moteus / registry.lua
Created Oct 19, 2017
Implementation registry in lua
View registry.lua
local Registry = {} do
Registry.__index = Registry
function Registry:new()
return setmetatable({_r = {0}}, {__index = self})
end
function Registry:ref(value)
local registry = self._r
You can’t perform that action at this time.