Skip to content

Instantly share code, notes, and snippets.

Mons /
Last active April 20, 2023 17:12
Script for changing stored UUID of Tarantool backup files (.snap, .xlog, .vy*)
#!/usr/bin/env perl
use 5.010;
use strict;
use File::Find;
use Getopt::Long;
sub usage {
return <<EOF
-- (c) Dmitry Sharonov если что - я вчера на скорую руку добавил в семлпер еще тройку лидеров из топа, вот так:
local top = fun.iter(, f); return f end):totable()
table.sort(top, function(f1, f2) return f1.average > f2.average end)'yaml').encode(fun.iter(top):take(3):totable()))
Mons / ev-ares.c
Created September 22, 2013 11:42
c-ares + libev gcc -lev -lcares async_dns.c
#include <ev.h>
#include <ares.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdarg.h>
Mons / XSTesting.xs
Created November 27, 2012 13:17
Creating closure callback from XS
* Usage:
my $x = XSTesting::makecb("my arg for x");
my $y = XSTesting::makecb("my arg for y");
say $x->();
say $y->();
Mons / timegm.lua
Last active August 20, 2021 18:48
Lua FFI implementation of timegm (convert any given date to GMT epoch timestamp)
local ffi = require 'ffi'
if not pcall(ffi.typeof, 'struct tm') then
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
if not pcall(assert, false, {}) then
local a = _G.assert
assert = function(t, m)
if t == nil then
error("value expected", 2)
if not t then
if m == nil then
error("assertion failed", 2)
Mons /
Created July 6, 2021 16:48 — forked from ochaton/
Monitoring fiber of latency of single ev_once
> tarantool -l fiber -l clock -e 'fiber.create(function() while true do while clock.time() < fiber.time()+0.1 do end fiber.sleep(0.01) end end)' test.lua
entering the event loop
e:100.011µs p:0.017µs t:99.998µs
e:100.042µs p:0.010µs t:100.035µs
e:100.013µs p:0.015µs t:100.004µs
e:100.005µs p:0.006µs t:99.994µs
e:100.007µs p:0.004µs t:99.996µs
e:100.010µs p:0.009µs t:99.993µs
e:100.012µs p:0.016µs t:100.000µs
e:100.009µs p:0.050µs t:99.999µs
Mons / ftrace-example.lua
Created April 15, 2021 15:35
Trace function call time
local log = require('log')
local clock = require 'clock'
local json = require 'json'.new() json.cfg{ encode_use_tostring = true }
local function ftail(fname, args, start, ...)
local run = clock.realtime() - start
if run > TOO_LONG_CALL_THRESHOLD then"Function call %s(%s) was too long: %0.2fs", fname, json.encode(args), run)
local client = require 'http.client'
local fiber = require 'fiber'
local yaml = require 'yaml'
local uris = {
local fiber = require 'fiber'
local clock = require 'clock'
local N = 1e6
local i = 0;
local cond = fiber.cond()
local function creator()
i = i + 1