Skip to content

Instantly share code, notes, and snippets.

@majek
majek / test1.erl
Created Jan 27, 2012
SockJS-erlang cowboy api proposal (simple)
View test1.erl
-module(test1).
-export([start/0]).
%% Cowboy callbacks
-export([init/3, handle/2, terminate/2]).
start() ->
Port = 8081,
application:start(sockjs),
@majek
majek / test2.erl
Created Jan 27, 2012
SockJS-erlang cowboy api proposal (advanced)
View test2.erl
-module(test2).
-export([start/0]).
%% Cowboy callbacks
-export([init/3, handle/2, terminate/2]).
start() ->
Port = 8081,
application:start(sockjs),
View client-direct.js
var net = require('net');
console.log(" [.] Connecting to localhost:8000");
var conn = net.createConnection(8000, '127.0.0.1');
var data = [
"GET /echo/1/1/websocket HTTP/1.1",
"Upgrade: WebSocket",
"Connection: Upgrade",
View cowboy_http10_bug.erl
#!/usr/bin/env escript
%%! -smp disable +A1 +K true -pz ./ebin -pa deps/cowboy/ebin -input
-module(cowboy_http10_bug).
-mode(compile).
-export([main/1]).
%% Cowboy callbacks
-export([init/3, handle/2, terminate/2]).
@majek
majek / udp_server.py
Created Feb 8, 2012
Simple python udp server
View udp_server.py
import logging
import socket
log = logging.getLogger('udp_server')
def udp_server(host='127.0.0.1', port=1234):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@majek
majek / client-direct.js
Created Feb 9, 2012
Misultin haproxy websocket hixie76 bug
View client-direct.js
var net = require('net');
console.log(" [.] Connecting to localhost:8000");
var conn = net.createConnection(8000, '127.0.0.1');
var data = [
"GET /echo/1/1/websocket HTTP/1.1",
"Upgrade: WebSocket",
"Connection: Upgrade",
@majek
majek / client-raw.js
Created Feb 9, 2012
Misultin close websockets bug
View client-raw.js
var net = require('net');
console.log(" [.] Connecting to localhost:8000");
var conn = net.createConnection(8000, '127.0.0.1');
var data = [
"GET /echo/1/1/websocket HTTP/1.1",
"Upgrade: websocket",
"Connection: Upgrade",
"Host: localhost",
@majek
majek / simplequeue.py
Created Feb 18, 2012
Simplistic Queue implementation
View simplequeue.py
'''
Very simple queue implementation. Don't use it. Use collections.deque
instead.
>>> q = Queue()
>>> q.push(1)
>>> q.push(2)
>>> len(q)
2
>>> bool(q)
View bug24744.erl.diff
diff -r 3be0091c6401 src/rabbit_stomp_client_sup.erl
--- a/src/rabbit_stomp_client_sup.erl Wed Feb 08 15:53:59 2012 +0000
+++ b/src/rabbit_stomp_client_sup.erl Wed Feb 22 11:52:02 2012 +0000
@@ -18,7 +18,7 @@
-behaviour(supervisor2).
-define(MAX_WAIT, 16#ffffffff).
--export([start_link/1, start_processor/3, init/1]).
+-export([start_link/1, start_processor/5, init/1]).
@majek
majek / Makefile
Created Feb 24, 2012
Possible SockJS-erlang ws bug
View Makefile
all:
rebar get-deps
rebar compile
erl -pa ebin deps/*/ebin -s wsbug
clean:
rm -rf deps ebin