Skip to content

Instantly share code, notes, and snippets.

View pintsized's full-sized avatar

James Hurst pintsized

View GitHub Profile
t/config.t ..... ok
t/connector.t .. 6/?
# Failed test 'TEST 6: password - pattern "ERR Client sent AUTH, but no password is set" should match a line in error.log (req 0)'
# at /usr/share/perl5/site_perl/Test/Nginx/Socket.pm line 1146.
WARNING: TEST 7: Bad unix domain socket path should fail - 2020/01/24 16:37:39 [crit] 48085#0: *1 connect() to unix://GARBAGE_PATH_AKFDKAJSFKJSAFLKJSADFLKJSANCKAJSNCKJSANCLKAJS failed
@pintsized
pintsized / ledge.config.lua
Last active January 17, 2018 16:25
ledge config
init_by_lua_block {
-- This configures ledge, and can only be done during init. If you skip this, default Redis connection
-- details will be assumed.
--
-- The only things configured here are the main metadata Redis connection, and the Qless Redis DB.
-- Any unknown config will error hard on server load
require("ledge").configure({
redis_connector_params = { -- anything supported by lua-resty-redis-connector works here
url = "redis://127.0.0.1:6380/1",
},
@pintsized
pintsized / output
Created September 17, 2014 09:10
proxy cookie
location /setcookie {
content_by_lua '
ngx.header.set_cookie = { "login=test%2Ftest", "cookie2" }
ngx.say("OK")
';
}
location /getcookie {
content_by_lua '
local resty_http = require "resty.http"
@pintsized
pintsized / co_wrap.lua
Last active December 31, 2015 01:19
openresty coroutine weirdness
-- Reimplemented coroutine.wrap, returning "nil, err" if the coroutine cannot
-- be resumed.
local co_wrap = function(func)
local co = coroutine.create(func)
ngx.log(ngx.DEBUG, "co created with status ", coroutine.status(co))
return function(...)
if coroutine.status(co) == "suspended" then
return select(2, coroutine.resume(co, ...))
else
return nil, "can't resume a " .. coroutine.status(co) .. " coroutine"
@pintsized
pintsized / gist:5125598
Created March 9, 2013 20:24
Ardour build-gtk-stack patch failure
jhurst@ubuntu:~/.gtk/source$ $AD/2.0-ongoing/tools/build-gtk-stack --patch
Python 2.7.3
Testing () patches ...
patching file configure.ac
patching file gtk/Makefile.am
Hunk #1 succeeded at 760 (offset 2 lines).
patching file gtk/gtkprivate.h
patching file gtk/gtkquartz.c
patching file gtk/gtkrelocation.c
patching file gtk/gtkfilechooserbutton.c
@pintsized
pintsized / ledge_lsm.lua
Last active April 19, 2017 21:21
Ledge state machine idea
lsm_mod = require("lsm")
lsm = lsm_mod:new("checking_request_accepts_cache") -- Pass in initial state
-- ACTIONS ---------------------------------
lsm:action("redis_connect", function()
print("#a: Connecting to redis")
end)
lsm:action("redis_close", function()
@pintsized
pintsized / pledge.lua
Created November 23, 2012 11:10
Cache primer from a Redis queue
local redis = require "redis"
local socket = require "socket"
local queue = "REVALIDATE"
local redis_client = redis.connect("127.0.0.1", 6379)
function log(msg)
io.stdout:write(os.date('%c', os.time()) .. ' ' .. msg .. "\n")
io.stdout:flush()
@pintsized
pintsized / gist:2936560
Created June 15, 2012 13:49
Ledge stats
location /stats {
default_type application/json;
content_by_lua '
local redis = require "resty.redis"
local red = redis:new()
local ledge = require "ledge.ledge"
local ok, err = red:connect("127.0.0.1", 6379)
if not ok then
ngx.exit(500)