Skip to content

Instantly share code, notes, and snippets.

@parruda
parruda / nginx.conf
Created December 10, 2023 03:19 — forked from marklkelly/nginx.conf
OpenResty & ssl_certificate_by_lua_file example
#Simplified for illustrative purposes.
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
-- Setup Redis connection
local redis = require "resty.redis"
local red = redis:new()
local ok, err = red:connect("127.0.0.1", "6379")
if not ok then
ngx.log(ngx.INFO, "REDIS: Failed to connect to redis: " .. err)
return ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
end
@parruda
parruda / alarm.cr
Created April 9, 2020 11:50
Alarm() on crystal lang
lib LibC
ITIMER_REAL = 0
ITIMER_VIRTUAL = 1
ITIMER_PROF = 2
struct Itimerval
it_interval : Timeval
it_value : Timeval
end
struct Timeval
@parruda
parruda / crystal-lang-osx-catalina-sys-v-ipc-C-bindings.cr
Last active April 8, 2020 03:10
Crystal Lang C Bindings for System V IPC on OSX 10.15 (Catalina)
lib LibC
IPC_CREAT = 0o1000
IPC_EXCL = 0o2000
IPC_NOWAIT = 0o4000
IPC_RMID = 0
IPC_SET = 1
IPC_STAT = 2
IPC_INFO = 3
SHM_LOCK = 3
SHM_UNLOCK = 4