Skip to content

Instantly share code, notes, and snippets.

View perusio's full-sized avatar

António P. P. Almeida perusio

View GitHub Profile
local log = ngx.log
local exit = ngx.exit
local null = ngx.null
local ERR = ngx.ERR
local INFO = ngx.INFO
local DEBUG = ngx.DEBUG
local HTTP_INTERNAL_SERVER_ERROR = ngx.HTTP_INTERNAL_SERVER_ERROR
-- Setup Redis connection
local redis = require "resty.redis"
@nimaai
nimaai / macro-pitfalls.md
Last active February 4, 2024 21:37
Lisp macro pitfalls
@haggen
haggen / string.random.lua
Last active February 21, 2024 04:16
Random strings in Lua
math.randomseed(os.time())
local charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
function string.random(length)
if length > 0 then
return string.random(length - 1) .. charset:sub(math.random(1, #charset), 1)
else
return ""
end
@LinuxJedi
LinuxJedi / nginx.gdb
Created July 15, 2015 14:54
GDB functions for NGINX
define ddl
set $log = ngx_cycle->log
while ($log != 0) && ($log->writer != ngx_log_memory_writer)
set $log = $log->next
end
if ($log->wdata != 0)
set $buf = (ngx_log_memory_buf_t *) $log->wdata
dump memory debug_log.txt $buf->start $buf->end
@calio
calio / clock_gettime
Last active January 11, 2018 13:15
clock_gettime() via LuaJIT + FFI
local ffi = require("ffi")
ffi.cdef[[
typedef long time_t;
typedef int clockid_t;
typedef struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
} nanotime;
@stephan-nordnes-eriksen
stephan-nordnes-eriksen / key-value-performance-test.md
Last active February 21, 2024 03:22
Performance testing different Key-Value stores in Ruby

For a project I am on I need to use a key-value store to converts file-paths to fixnum IDs. The dataset will typically be in the range of 100 000 to 1 000 000. These tests use 305 000 file paths to fixnum IDs.

The Different Key-Value stores tested are:

Daybreak: "Daybreak is a simple and very fast key value store for ruby" GDBM: GNU dbm. "a simple database engine for storing key-value pairs on disk." DBM: "The DBM class provides a wrapper to a Unix-style dbm or Database Manager library" PStore: "PStore implements a file based persistence mechanism based on a Hash. "

Out of these, all except Daybreak are in the Ruby standard library.

var Crawler = require("simplecrawler");
var querystring = require('querystring');
var myCrawler = new Crawler("www.geocaching.com", "/login/");
myCrawler.initialProtocol = "https";
myCrawler.acceptCookies = true;
myCrawler.on("addcookie", function (cookie) {
console.log("Cookie");
});
@Wilfred
Wilfred / julia_syntax_test.jl
Last active June 19, 2019 19:33
Corner cases for Julia syntax highlighting
## Julia syntax highlighting test.
# This file is designed to test various corner cases of Julia
# syntax highlighting.
## Simple function definitions.
# Expected: `function` should be highlighted, as should `foo_bar!`.
function foo_bar!(x,y)
x + y + 1
end
@bertvv
bertvv / pandoc.Makefile
Last active November 24, 2022 08:55
Makefile for Markdown -> PDF using pandoc
# Generate PDFs from the Markdown source files
#
# In order to use this makefile, you need some tools:
# - GNU make
# - Pandoc
# - LuaLaTeX
# - DejaVu Sans fonts
# Directory containing source (Markdown) files
source := src
diff --git i/deps/Makefile w/deps/Makefile
index 5a95545..9ec62be 100644
--- i/deps/Makefile
+++ w/deps/Makefile
@@ -58,8 +58,8 @@ ifeq ($(uname_S),SunOS)
LUA_CFLAGS= -D__C99FEATURES__=1
endif
-LUA_CFLAGS+= -O2 -Wall -DLUA_ANSI $(CFLAGS)
-LUA_LDFLAGS+= $(LDFLAGS)