Skip to content

Instantly share code, notes, and snippets.

@majek
majek / index.html
Created March 5, 2012 12:15
Samsung TV maple skeleton
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>test</title>
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js">
{
overrideConsole: true,
startInNewWindow: false,
@majek
majek / histogram.py
Created March 6, 2012 10:53
Script for drawing histogram out of 'uniq -c' output
#!/usr/bin/env python
import re
import sys
if len(sys.argv) > 1:
columns = int(sys.argv[1])
else:
columns = 100
pattern = re.compile(r'^(\s*\S+) (.*)$')
@majek
majek / haproxy-1.5-patch
Created March 7, 2012 00:04
HAProxy port number in x-forwarded-for patch edit
--- src/proto_http-orig.c 2011-09-10 22:43:11.000000000 +0100
+++ src/proto_http.c 2012-03-07 00:06:10.000000000 +0000
@@ -3560,8 +3560,10 @@ int http_process_request(struct session
(((struct sockaddr_in *)&s->req->prod->addr.c.from)->sin_addr.s_addr & s->be->except_mask.s_addr)
!= s->be->except_net.s_addr)) {
int len;
+ unsigned int port;
unsigned char *pn;
pn = (unsigned char *)&((struct sockaddr_in *)&s->req->prod->addr.c.from)->sin_addr;
+ port = ntohs(((struct sockaddr_in *)&s->req->prod->addr.c.from)->sin_port);
@majek
majek / flood.html
Created March 12, 2012 17:12
flood
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8" />
<script type="text/javascript" src="lib/sockjs.js"></script>
<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript" src="config.js"></script>
@majek
majek / sockjs-branch.java.diff
Created March 21, 2012 14:48
spring-integration sockjs vs master
diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java
index 7b4252f..87e462d 100644
--- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java
+++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractClientConnectionFactory.java
@@ -57,6 +57,20 @@ public abstract class AbstractClientConnectionFactory extends AbstractConnection
}
}
+ /**
+ * Get a dedicated long-lived connection - regardless of single-use
@majek
majek / .gitignore
Created April 20, 2012 11:25
SockJS heroku workaround
node_modules
@majek
majek / .gitignore
Created April 23, 2012 15:24
SockJS xhr-streaming on Safari and busy indicator
node_modules
@majek
majek / README.md
Created April 24, 2012 14:05
ROUTER PROXY APP

How I would do it:

  1. ROUTER arrives
  2. it opens a tcp/ip connection to the PROXY
  3. it worms up, waits a few seconds, stretches :)
  4. it says: HELLO, I'm marek and I can accept 1k concurrent connections, and I have a cpu of a weight 2
  5. the PROXY responds with HELLO-OK
  6. The PROXY starts sending NEW_CONNECTION messages to the ROUTER
  7. messages flow in and out
  8. The ROUTER gets a SIGHUP from administrator, it should prepare to tear down
@majek
majek / README.md
Created April 26, 2012 15:15
Passing TCP socket descriptors around

Passing TCP socket descriptors around

In linux, normally, it is impossible to "bind()" to the same TCP port twice. If you try to bind to the same port from second proces unix processes you'll see:

socket.error: [Errno 98] Address already in use