Skip to content

Instantly share code, notes, and snippets.

View sharonovd's full-sized avatar
🙀
where are you jon

Dmitry Sharonov sharonovd

🙀
where are you jon
View GitHub Profile
#!/usr/bin/env tarantool
local net_box = require('net.box')
local fiber = require('fiber')
local clock = require('clock')
local CONN_STRING = 'localhost:3301' -- SET UP CONECTION STRING TO YOUR ROUTER / PLAIN TARANTOOL
local WORKER_COUNT = 256 -- SET UP NUMBER OF PARALLEL REQUESTS HERE
local conn = assert(net_box.connect(CONN_STRING))
--- RSA bindings for Tarantool
--- Carefully adapted from https://github.com/spacewander/lua-resty-rsa
local bit = require "bit"
local band = bit.band
local ffi = require "ffi"
local ffi_new = ffi.new
local ffi_gc = ffi.gc
local ffi_copy = ffi.copy
local ffi_str = ffi.string
@sharonovd
sharonovd / demo-data
Last active June 4, 2020 11:32
TDG demo-data
[
{
"name": "Account",
"type": "record",
"logicalType": "Aggregate",
"fields": [
{"name": "id", "type": "int"},
{"name": "name", "type": ["null", "string"], "default": null}
],
"indexes": ["id", "name"],
#!/usr/bin/env tarantool
-- Sets common rocks paths so that the app can be started from any
-- directory
--
-- By default, when you do require('mymodule'), tarantool looks into
-- the current working directory and whatever is specified in
-- package.path and package.cpath. If you run your app while in the
-- root directory of that app, everything goes fine, but if you try to
-- start your app with "tarantool myapp/init.lua", it will fail to load
-- its modules, and modules from myapp/.rocks.
def mult(v1, v2):
"""vX is array of int pairs, e. g. [(6, 2), [7,3 ]] which is equivalent to vector (6, 6, 7, 7, 7) """
result = 0
position1 = -1
position2 = -1
counter1 = 0
counter2 = 0
while True:
assert counter1 >= 0 and counter2 >= 0
local uuid = require('uuid')
local log = require('log')
box.cfg{}
box.schema.create_space('test', {if_not_exists=true })
box.space.test:create_index('primary', {parts={1,'string'}, if_not_exists=true})
for i = 1,1000000 do
box.space.test:replace({uuid.new():str(), 'test', 'testtesttesttesttesttesttesttesttesttesttesttest'})
end
@sharonovd
sharonovd / init.lua
Created February 27, 2019 15:16
Sample app for prefix-based selection
local fio = require('fio')
local log = require('log')
local json = require('json')
local utf = require('utf8')
box.cfg({})
--- specify data schema
box.once('init_addresses', function()
box.schema.create_space('address')
local fiber = require('fiber')
function another_func()
fiber.sleep(1)
fiber.yield()
end
function test()
local fib = fiber.create(another_func)
fib:set_joinable(true)
function utils.urlencode(data)
if type(data) == 'string' then
if data then
local res = string.gsub(data, '\n', '\r\n')
res = string.gsub(res, '([^%w _.~-])', function(c)
return string.format('%%%02X', string.byte(c))
end)
return string.gsub(res, ' ', '+')
end
elseif type(data) == 'number' then
d:cia d.sharonov$ docker build .
Sending build context to Docker daemon 60.7MB
Step 1/5 : FROM centos:7
---> 49f7960eb7e4
Step 2/5 : COPY ./SDK /root/SDK
---> Using cache
---> 6c60e5bb0d31
Step 3/5 : COPY ./cia /root/cia
---> Using cache
---> 4462b7b2da25