Skip to content

Instantly share code, notes, and snippets.

View cablehead's full-sized avatar

Andy Gayton cablehead

View GitHub Profile
local levee = require("levee")
local _ = levee._
local h = levee.Hub()
local r, w = h.io:pipe()
h:spawn(function()
for i = 1, 1000 do
local levee = require("levee")
local _ = levee._
local h = levee.Hub()
local r, w = h.io:pipe()
h:spawn(function()
for i = 1, 1000 do
local levee = require("levee")
local _ = levee._
local h = levee.Hub()
local r, w = h.io:pipe()
h:spawn(function()
for i = 1, 1000 do
local h = levee.Hub()
local r, w = h.io:pipe()
local len = 128*1024
local buf = d.Buffer(len)
print()
h:spawn(function()
local h = levee.Hub()
local r, w = h.io:pipe()
h:spawn(function()
local err = w:write(("X"):rep(128*1024))
print(err)
w:close()
end)
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
struct packet_t {
char uri[16];
char key[16];
};
local levee = require("levee")
local fsource = require('levix.source.file')
local h = levee.Hub()
local err, sources = fsource.watch(h, "./sources.json")
@cablehead
cablehead / s.lua
Last active January 9, 2017 21:58
r:stream():line() --> `err`, `Slice`
-- a slice is a restricted `off`, `len` window into a buffer. offers all methods buffer does.
-- is bump / growable, if `len` extends to the end of the buffer's current contents.
-- this allows you to make use of the line without incurring and additional copy
-- you call `:trim` when done with the line.
-- buffer (and so slice) will get two new methods
local ffi = require("ffi")
local levee = require("levee")
ffi.cdef([[
typedef struct { int len; } myproto_prefix_t;
]])
local ffi = require("ffi")
local levee = require("levee")
ffi.cdef([[
typedef struct { int len; } myproto_prefix_t;
]])