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 AnyEvent::Handle; | |
BEGIN { | |
my $push_write = \&AnyEvent::Handle::push_write; | |
*AnyEvent::Handle::push_write = sub { | |
if (@_ > 2) { | |
goto &$push_write; | |
} else { | |
if(utf8::is_utf8 $_[1]) { | |
@_ = (@_); | |
$_[1] = "$_[1]"; |
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
// (c) Roman Tokarev | |
#ifndef _DEFER_H_ | |
#define _DEFER_H_ | |
#define CONCAT(a_, b_) a_ ## b_ | |
#define CONCAT2(a_, b_) CONCAT(a_, b_) | |
#define UNIQUE_TOKEN(var_) CONCAT2(var_, __LINE__) | |
#define DEFER \ |
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() |
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 obj = require('obj') | |
local fiber = require('fiber') | |
local log = require('log') | |
local remote = require('net.box') | |
local pool = obj.class({},'pool') | |
function pool:_init(cfg) | |
local zones = {} | |
self.total = 0 |
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 weak = setmetatable({},{__mode = 'v'}) | |
do | |
local Class = {} | |
-- function Class:super( class,method ) | |
-- return function () | |
-- print("work") | |
-- end | |
-- end | |
function Class:test() | |
self:super(Class,'method')() |
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: ",...) |
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() |
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 .= $_; |
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__ |
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(), "@_"; | |
} |