Skip to content

Instantly share code, notes, and snippets.

@fur-q
fur-q / irc.c
Created December 13, 2013 04:30
libircclient and a proper event loop (specifically ae)
#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;
@fur-q
fur-q / config.cfg
Last active December 14, 2015 06:59
the best lua config loader idst
hostname = "localhost"
reconnect = true
attempts = 10
ignore = { "user1", "user2" }
channels = {}
for i = 1, 4 do
channels[i] = "#channel" .. i
end
@fur-q
fur-q / Makefile
Last active December 14, 2015 03:29
example C extension for Lua
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
@fur-q
fur-q / main.lua
Created October 10, 2012 01:19
stop using module() ok
local mod = require "mod"
print(mod.func, mod.x)
-- 100, function: 0xFFFFFFFF
print(mod.priv, priv)
-- nil, nil
@fur-q
fur-q / app.lua
Created September 14, 2012 12:03
shorty
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