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
| require "shorty" | |
| shorty:get("/", function() | |
| local args = { title = "test", content = "IT WORKS" } | |
| return render("index", args) | |
| end) | |
| shorty:get("/headers", function() | |
| local out = {} | |
| for k,v in pairs(req.headers) 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
| local mod = require "mod" | |
| print(mod.func, mod.x) | |
| -- 100, function: 0xFFFFFFFF | |
| print(mod.priv, priv) | |
| -- nil, nil |
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
| PC = pkg-config | |
| LUA = lua5.1 | |
| CFLAGS = `$(PC) --cflags $(LUA)` -Wall -fPIC | |
| LDFLAGS = `$(PC) --libs $(LUA)` | |
| lsleep.so: lsleep.c | |
| gcc -shared $(CFLAGS) $(LDFLAGS) -o $@ $^ | |
| clean: | |
| -rm lsleep.so |
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
| hostname = "localhost" | |
| reconnect = true | |
| attempts = 10 | |
| ignore = { "user1", "user2" } | |
| channels = {} | |
| for i = 1, 4 do | |
| channels[i] = "#channel" .. 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
| #include <stdarg.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <sys/select.h> | |
| #include "libircclient.h" | |
| #include "ae.h" | |
| typedef struct irc_fds_t { | |
| fd_set rfd, wfd; | |
| } irc_fds_t; |
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
| static int cf_tolua(lua_State *L) { | |
| lua_pushliteral(L, "hello"); | |
| return 1; | |
| } | |
| static int cf_fromlua(lua_State *L) { | |
| const char *str = lua_tostring(L, 1); // first argument passed in; second would be at index 2 | |
| printf("%s\n", str); | |
| return 0; | |
| } |
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 function prettyprint(t, l) | |
| l = l or 0 | |
| for k, v in pairs(t) do | |
| io.write(string.rep(" ", (l * 4)), k, " = ") | |
| if type(v) == "table" then | |
| io.write("table:\n") | |
| prettyprint(v, l+1) | |
| else | |
| io.write(tostring(v), "\n") | |
| 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 function parse_url(url) | |
| local out = {} | |
| url = string.gsub(url, "#(.*)$", function(f) | |
| out.fragment = f | |
| return "" | |
| end) | |
| url = string.gsub(url, "^([%w][%w.+-]*):", function(s) | |
| out.scheme = s | |
| return "" | |
| 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
| CC = gcc | |
| LUA = luajit | |
| loader: loader.o myscript.l.o | |
| $(CC) $(LDFLAGS) -o $@ $^ | |
| %.l.o: %.lua | |
| $(LUA) -bg $^ $@ |
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
| #! /bin/sh | |
| error() { | |
| echo >&2 "$1" | |
| exit 1 | |
| } | |
| required() { | |
| command -v "$1" >/dev/null 2>&1 || error "$1 required but not installed; quitting" | |
| } |
OlderNewer