View loop.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use 5.010; | |
use AnyEvent; | |
use AnyEvent::HTTP; | |
use Time::HiRes 'time'; | |
my $records = [ (1)x4e3 ]; | |
my $i = 0; |
View cv.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use 5.010; | |
use AnyEvent; | |
use Time::HiRes 'time'; | |
sub async (&) { | |
my $code = shift; | |
my $t;$t = AE::timer 0,0,sub { undef $t;$code->(); } |
View simple_loop.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use EV; | |
use Scalar::Util 'weaken'; | |
my @tasks = qw(1 2 3); | |
sub dbg(@) { | |
printf "[%0.06f] %s\n",EV::now(), "@_"; | |
} |
View portable_endian.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "License": Public Domain | |
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like. | |
#ifndef PORTABLE_ENDIAN_H__ | |
#define PORTABLE_ENDIAN_H__ | |
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__) | |
# define __WINDOWS__ |
View case.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.010; | |
use CBOR::XS; | |
use Data::Dumper; | |
my $cbor = CBOR::XS->new(); | |
my $data = "\x82\x01\xD9\x56\x52\x44test"; | |
say Dumper $cbor->decode($data); | |
my $buf; | |
for (split //, $data) { | |
$buf .= $_; |
View init.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if box.sandbox then | |
box.sandbox = nil | |
end | |
local ffi = require 'ffi' | |
ffi.cdef [[ | |
void exit(int) | |
]] | |
box.fiber.wrap(function() |
View test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local r,e = pcall(function () | |
local res = peer:call('box.raise', tostring(box.error.ER_PROC_LUA), "Test die" ) | |
end) | |
print("call res = ",r," ",e) | |
local r,e = xpcall(function () | |
local res = peer:call('box.raise', tostring(box.error.ER_PROC_LUA), "Test die" ) | |
end, function(...) | |
print("Error: ",...) |
View iproto.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local iproto_proto = Proto("iproto", "iproto protocol") | |
function iproto_proto.dissector(buffer, pinfo, tree) | |
pinfo.cols.protocol = "IPROTO" | |
local iprotree = tree:add(iproto_proto, buffer(), "IPROTO") | |
local buffer_len = buffer:len() | |
local offset = 0 | |
while offset < buffer_len do | |
local len = buffer((offset + 4), 4):le_uint() | |
local sync = buffer((offset+8), 4):le_uint() |
View gist:596741
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
se uni::perl; | |
use Benchmark ':all'; | |
use lib::abs; | |
BEGIN {unshift @INC, lib::abs::path 'kraih/lib' } | |
use Mojo::ByteStream 'b';; | |
say $INC{'Mojo/ByteStream.pm'}; | |
my %results; | |
$results{old} = timethis -1 , sub { b('x'x1000) }; |
View gist:596742
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use uni::perl; | |
use Benchmark ':all'; | |
use lib::abs; | |
BEGIN {unshift @INC, lib::abs::path 'kraih/lib' } | |
use Mojo::ByteStream 'b';; | |
say $INC{'Mojo/ByteStream.pm'}; | |
my %results; | |
$results{old1} = timethis -1 , sub { b("тестовая строка")->encode('utf8')->decode('utf8') }; |
OlderNewer