Skip to content

Instantly share code, notes, and snippets.

@echohes
echohes / lua_http_cookie.lua
Created March 10, 2021 13:20
example for lua, http cookie use in eltex-ecss10 api
#!/usr/bin/env bash
set -o errexit
set -o nounset
token=$1
url=$2
day_count_save=$3
#get all project from gitlab, limit 100
all_project=`curl -s --header "Private-Token: ${token}" https://${url}/api/v4/projects?per_page=100`
@echohes
echohes / jssip_test.html
Created August 3, 2018 07:20
Jssip (jssip-3.2.11.min.js) WebPhone (Video Calling Example)
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Sip demo</title>
</head>
<body>
<head><title>WebRT</title>
<style>
@echohes
echohes / calculate_timezone_select_iterator.lua
Created July 25, 2018 23:02
Get iterator and number for the range of available timeszone relative to the current time.
function tz_calculate(crt,start_time,end_time)
--[[ The function receives the current time, the start time and the end time.
         Counts the total time of work "job_time" and the difference between the end of work and the current time "calc".
Compares calc and job_time
         If calc is less than or equal to job_time, then the iterator LE (<=) and the calc result are selected to select the taason band.
         If job_time is greater than calc, then the GE iterator (> =) is selected, and the timezone is calculated as the difference (calc - job_time)
--]]
job_time = (end_time - start_time)
calc = (end_time - crt)
if (calc <= job_time) then
@echohes
echohes / get_timing_cache.lua
Last active July 11, 2018 09:37
Tarantool-Queue, adding tasks to the queue based on the time from 9 to 21
function get_timing_cache(num,tz,cth,ctm)
-- Time Calculate delay and ttl queues options
-- num - number, tz - timezone(utc), cth - current time hour, ctm - current time mintute
num_time = tz + cth
if num_time < 9 then
delay = tonumber(((9 - num_time) * 60 * 60) -(ctm * 60))
ttl = 43100
return {delay,ttl}
elseif num_time >= 9 and num_time < 21 then
delay = 2
@echohes
echohes / export_tar.lua
Created July 11, 2018 09:31
Export data to Tarantool
csv = require("csv")
f = require("fio").open("/usr/local/share/tarantool/data.csv", { "O_RDONLY"})
for i, tup in csv.iterate(f) do
if tonumber(tup[1]) then
box.space.recall:upsert({tonumber(tup[1])},{{'=',1,0}})
end
end