Skip to content

Instantly share code, notes, and snippets.

@dvv
dvv / uc.js
Created December 14, 2011 16:42
killer-string-for-sockjs
var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u2000-\u20ff\ufeff\ufff0-\uffff\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad
@dvv
dvv / dumb.lua
Created December 7, 2011 20:16
failing fibers
#!/usr/bin/env luvit
local Fiber = require('fiber')
local Fs = require('fs')
local Path = require('path')
--
-- mimicks find
--
local function find(path, match_fn, callback)
#!/bin/sh
test_ok() {
ls
}
test_nak() {
ls1
diff --git a/lib/emitter.lua b/lib/emitter.lua
index 4f77579..37778cb 100644
--- a/lib/emitter.lua
+++ b/lib/emitter.lua
@@ -58,7 +58,7 @@ function emitter_prototype:remove_listener(name, callback)
if not handlers then return end
local handlers_for_type = rawget(handlers, name)
if not handlers_for_type then return end
- handlers_for_type[name][callback] = nil
+ handlers_for_type[callback] = nil
======================================================================
ERROR: test_simpleSession (__main__.Protocol)
----------------------------------------------------------------------
Traceback (most recent call last):
File "sockjs-protocol-0.0.4-incomplete.py", line 446, in test_simpleSession
r2 = POST(trans_url + '/xhr')
File "/home/dvv/LUA/sockjs-protocol/utils.py", line 77, in POST
return HttpResponse('POST', url, **kwargs)
File "/home/dvv/LUA/sockjs-protocol/utils.py", line 36, in __init__
self._load()
@dvv
dvv / gist:1291039
Created October 16, 2011 15:29
sockjs-protocol-tests-fixed
diff --git a/utils.py b/utils.py
index 0eae4eb..d8369bc 100644
--- a/utils.py
+++ b/utils.py
@@ -2,6 +2,7 @@ import urlparse
import httplib
from ws4py.client.threadedclient import WebSocketClient
import Queue
+import signal
@dvv
dvv / gist:1290586
Created October 16, 2011 06:37
nodelay.diff
diff --git a/src/luv.c b/src/luv.c
index 7d40269..9bac004 100644
--- a/src/luv.c
+++ b/src/luv.c
@@ -66,6 +66,7 @@ static const luaL_reg luv_f[] = {
{"tcp_getpeername", luv_tcp_getpeername},
{"tcp_connect", luv_tcp_connect},
{"tcp_connect6", luv_tcp_connect6},
+ {"tcp_nodelay", luv_tcp_nodelay},
@dvv
dvv / parser helpers.lua
Created October 14, 2011 18:30
'end' is not fired
local HTTP = require("http")
HTTP.create_server("0.0.0.0", 8080, function (req, res)
data = ''
req:on('data', function(chunk)
data = data .. chunk
end)
req:on('end', function()
res:write_head(200, {
["Content-Type"] = "text/plain",
@dvv
dvv / gist:1281194
Created October 12, 2011 13:12
an attempt at modules in luvit
-- hack require() lookup paths
local path = '?.lua'
for i = 1,4 do
path = path .. ';' .. ('../'):rep(i) .. 'lua_modules/?.lua'
end
package.path = path .. ';' .. package.path
package.cpath = path:gsub('%.lua', '.so') .. ';' .. package.cpath
--d('package paths', package.path, package.cpath)
local pipe = FS.create_read_stream(file.name, {
offset = start,
length = stop - start + 1,
})
pipe:on('data', function(chunk, len)
if cache_it then
parts[index] = chunk
index = index + 1
end
res:safe_write(chunk)