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 h = levee.Hub() | |
| _.fcntl_nonblock(0) | |
| h.stdin = h.io:r(0) | |
| _.fcntl_nonblock(1) | |
| h.stdout = h.io:w(1) | |
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
| const struct rd_kafka_group_list *grplist; | |
| err = rd_kafka_list_groups(rk, NULL, &grplist, 5000); | |
| assert (!err); | |
| for (i = 0 ; i < grplist->group_cnt ; i++) { | |
| const struct rd_kafka_group_info *gi = &grplist->groups[i]; | |
| printf("%s\n", gi->group); | |
| } | |
| rd_kafka_group_list_destroy(grplist); |
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 h = levee.Hub() | |
| local err, serve = h.http:listen(8099) | |
| for conn in serve do | |
| h:spawn(function() | |
| for req in conn do |
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> |