Skip to content

Instantly share code, notes, and snippets.

@ochaton
ochaton / bad_tarantool.sh
Created July 6, 2021 16:45
Monitoring fiber of latency of single ev_once
View bad_tarantool.sh
> 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
@Grinnz
Grinnz / perl7faq.md
Last active December 14, 2022 14:39
Perl 7 FAQ
View perl7faq.md

Perl 7 FAQ

last updated 2022-05-26

Is Perl 7 coming?

It is the current plan that this version number will be used for Perl at some point in the future.

When is Perl 7 coming?

View ls.lua
_G.ls = setmetatable({}, {
__serialize = function()
local res = {}
for _, sp_info in box.space._space:pairs(512, { iterator = "GE" }) do
local sp = box.space[sp_info.name]
local info = {}
info.name = tostring(sp.name)
info.engine = tostring(sp.engine)
info.len = tostring(sp:len())
@knazarov
knazarov / full_text_search_tarantool.lua
Created September 23, 2020 08:00
Full text search example for Tarantool
View full_text_search_tarantool.lua
#!/usr/bin/env tarantool
local pickle = require('pickle')
local yaml = require('yaml')
function trivec(str)
str = string.lower(str)
local vec = ""
View rsa.lua
--- 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
@R-omk
R-omk / tnteval
Created January 24, 2020 06:56
Print output from tarantool to stdout
View tnteval
#!/usr/bin/env tarantool
local CONSOLE_SOCKET_PATH = 'unix/:/var/run/tarantool/tarantool.sock'
local os = require("os")
console = require('console')
console.on_start(function(self)
local status, reason
status, reason = pcall(function() require('console').connect(CONSOLE_SOCKET_PATH) end)
if not status then
@RunsFor
RunsFor / nginx.conf
Last active August 1, 2022 19:48
HTTP terminating tools comparison in tarantool (MacBook Pro 13 2017 3.5 Ghz Intel Core i7, 16GB)
View nginx.conf
worker_processes 8;
error_log logs/error.log info;
events {
worker_connections 4096;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active March 21, 2023 15:03
What is Strict Aliasing and Why do we Care?
View WhatIsStrictAliasingAndWhyDoWeCare.md

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@jef-sure
jef-sure / positive_int.pl
Created December 9, 2017 16:56
Check for Positive Integer entry
View positive_int.pl
#!/usr/bin/perl
use B;
use Scalar::Util::LooksLikeNumber 'looks_like_number';
sub positive_int {
my $lln = looks_like_number($_[0]);
($lln == 1 || $lln & B::SVf_IOK) && $_[0] > 0;
}
for (0, "0", 123, "123", 123.45, "123.45", "yolki-palki", "nancy") {
print "$_ -> " . (positive_int($_) ? "true" : "false");
@eyecatchup
eyecatchup / git-commit-log-stats.md
Last active March 17, 2023 16:42
Some commands to get git commit log statistics for a repository on the command line.
View git-commit-log-stats.md

git commit stats

Commands to get commit statistics for a Git repository from the command line -
using git log, git shortlog and friends.