This file contains hidden or 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
import functools | |
def common(accepts): | |
def wrap(f): | |
f.__doc__ += """ | |
*token* i take a token | |
""" | |
d = {} |
This file contains hidden or 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 levee = require("levee") | |
local p = levee.p | |
local h = levee.Hub() | |
local err, serve = h.stream:listen(9000) | |
for conn in serve do | |
h:spawn(function() | |
local stream = conn:stream() |
This file contains hidden or 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 ffi = require("ffi") | |
local upper = 2^48 | |
print("UPPER:", upper) | |
for i = 0, upper do | |
if i % (10*1000*1000*1000) == 0 then | |
print(i) | |
end |
This file contains hidden or 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 levee = require("levee") | |
local d = levee.d | |
local h = levee.Hub() | |
local K1 = ("."):rep(1024) | |
local err, serve = h.stream:listen() | |
local err, addr = serve:addr() |
This file contains hidden or 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 ffi = require("ffi") | |
local C = ffi.C | |
ffi.cdef([[ | |
unsigned int | |
sleep(unsigned int seconds); ]]) | |
local function foo(no) |
This file contains hidden or 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
#include <assert.h> | |
#include <pthread.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netdb.h> | |
#include <string.h> |
This file contains hidden or 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
#include <assert.h> | |
#include <pthread.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netdb.h> | |
#include <string.h> |
This file contains hidden or 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
conf.service:location("/a", [[ | |
local c = require('foo') | |
local b, err = c.bar() | |
if err == nil and type(b) == 'table' then | |
ngx.say('good') | |
else | |
ngx.say(err) | |
end | |
]]) |
This file contains hidden or 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
h = vanilla.Hub() | |
uri = 'ws://localhost:%s' % serve.port | |
ws = h.http.connect(uri).websocket('/') |
This file contains hidden or 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 levee = require("levee") | |
local _ = levee._ | |
local function main(h) | |
while true do | |
local err, n = h.thread:call( | |
function() | |
local _ = require("levee._") | |
local err, no = _.connect("127.0.0.1", 8007) |