Skip to content

Instantly share code, notes, and snippets.

View ezmobius's full-sized avatar

Ezra Zygmuntowicz ezmobius

View GitHub Profile
{"VMC_APP_HOST"=>"172.30.49.47",
"VMC_APP_NAME"=>"foofoo",
"VMC_APP_INSTANCE"=>
"{\"droplet_id\":961,\"instance_id\":\"9ee7e0e281086789a25da4d7dc0d31c9\",\"instance_index\":0,\"name\":\"foofoo\",\"dir\":\"/var/vcap/data/dea/apps/foofoo-0-9ee7e0e281086789a25da4d7dc0d31c9\",\"uris\":[\"foofoo.cloudfoundry.com\"],\"users\":[\"[email protected]\"],\"version\":\"d2be92bfa13967e61e9d0e6d54ff4fa6dee718ba-1\",\"mem_quota\":134217728,\"disk_quota\":2147483648,\"fds_quota\":256,\"state\":\"STARTING\",\"runtime\":\"ruby18\",\"start\":\"2011-04-15 23:22:19 +0000\",\"state_timestamp\":1302909739,\"secure_user\":\"vcap-user-14\",\"resources_tracked\":true,\"port\":54071}",
"SHELL"=>"/bin/sh",
"VMC_APP_PORT"=>"54071",
"VCAP_APP_PORT"=>"54071",
"NO_PROXY"=>".cloudfoundry.com, localhost, 127.0.0.1",
"http_proxy"=>"http://squid.las01.emcatmos.com:3128",
"USER"=>"vcap-user-14",
# GET /recur?num=5
location /recur {
# MIME type determined by default_type:
default_type 'text/plain';
content_by_lua '
local num = tonumber(ngx.var.arg_num) or 0
ngx.say("num is: ", num)
if num > 0 then
# pseudocode
redis = Redis.new
# whenever a client connects:
connections_count = redis.scard('connected:clients')
if connections_count < MAX_CONNECTIONS
redis.sadd('connected:clients', request.remote_ip)
case "$NGX_PLATFORM" in
Darwin:*)
case "$NGX_MACHINE" in
amd64 | x86_64 | i386)
echo "adding extra linking options needed by LuaJIT"
ngx_feature_libs="$ngx_feature_libs -pagezero_size 10000 -image_base 100000000"
;;
*)
;;
def on_msg(subject, sid, reply, msg) #:nodoc:
return unless subscriber = @subs[sid]
if cb = subscriber[:callback]
case cb.arity
when 0 then cb.call
when 1 then cb.call(msg)
when 2 then cb.call(msg, reply)
else cb.call(msg, reply, subject)
end
end
MSG = /^MSG\s+(\S+)\s+(\S+)\s+((\S+)\s+)?(\d+)$/i #:nodoc:
OK = /^\+OK/i #:nodoc:
ERR = /^-ERR\s+('.+')?/i #:nodoc:
PING = /^PING/i #:nodoc:
PONG = /^PONG/i #:nodoc:
INFO = /^INFO\s+(.+)/i #:nodoc:
# Responses
CR_LF = ("\r\n".freeze) #:nodoc:
CR_LF_SIZE = (CR_LF.bytesize) #:nodoc:
@ezmobius
ezmobius / gist:807334
Created February 2, 2011 06:37
Run this script on a mac osx box running 10.6 and you will get a luajit with batteries included and all the good libs
#!/bin/bash
# have to hand install this one sorry http://www.cmake.org/files/v2.8/cmake-2.8.3-Darwin-universal.tar.gz
if [ "$1" == "cleanup" ]; then
echo "Cleaning up old luajit install"
cd /usr/local/share
sudo rm -rf lua luajit-2.0.0-beta6
[1] % grep EINPROGRESS **/*
apr-1/apr_errno.h:/** @see APR_STATUS_IS_EINPROGRESS */
apr-1/apr_errno.h:#ifdef EINPROGRESS
apr-1/apr_errno.h:#define APR_EINPROGRESS EINPROGRESS
apr-1/apr_errno.h:#define APR_EINPROGRESS (APR_OS_START_CANONERR + 17)
apr-1/apr_errno.h:#define SOCEINPROGRESS (SOCBASEERR+36) /* Operation now in progress */
apr-1/apr_errno.h:#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
apr-1/apr_errno.h: || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS)
apr-1/apr_errno.h:#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
apr-1/apr_errno.h: || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
module('NATS', package.seeall)
require('list')
require ("datadumper")
NATS = {}
NATS.client = require('socket').tcp()
NATS.url = require('socket.url')
NATS.pending = {}
% nc -l -p 4222
fdf
dfdasf
Can't grab 0.0.0.0:4222 with bind