Skip to content

Instantly share code, notes, and snippets.

View jasom's full-sized avatar

Jason Miller jasom

  • Santa Barbara, CA
View GitHub Profile
DEBUG src/state.rl:53: --> parse(OPEN:107) State_exec:53
DEBUG src/state.rl:54: --> register_request(REQ_RECV:110) State_exec:54
DEBUG src/connection.c:487: HTTP MESSAGE
DEBUG src/state.rl:57: --> route_request(HTTP_REQ:105) State_exec:57
DEBUG src/server.c:223: Looking for target host: localhost
DEBUG src/routing.c:200: Found simple suffix: localhost
DEBUG src/routing.c:215: Searching for route: /htchat
DEBUG src/routing.c:219: Found simple prefix: /htchat
DEBUG src/host.c:127: Found backend at /htchat
DEBUG src/state.rl:60: --> http_to_handler(HANDLER:104) State_exec:60
@jasom
jasom / gist:1155870
Created August 19, 2011 02:10
hack for x-forwarded-for
int connection_proxy_deliver(Connection *conn)
{
int rc = 0;
int req_len = Request_header_length(conn->req);
int cont_len = Request_content_length(conn->req);
int total_len = req_len+cont_len;
bstring xff;
char *xffBuf;
unsigned sofar=0;
@jasom
jasom / tnetparse.lisp
Created September 7, 2011 18:27
World's Slowest tnetstring parser
(asdf:load-system :parser-combinators)
(use-package :parser-combinators)
(defparameter *true* t)
(defparameter *false* nil)
(defparameter *null* nil)
(defparameter *empty-dict* nil)
(defparameter *empty-list* nil)
(declaim (optimize (speed 3)))
(defun <tnetstring> ()
SBCL SBCL (bytes) CCL CCL(Bytes)
Encode 2.59 2.6 7.19 23.4
Decode (Alist) 2.13 2.27 2.66 11.32
Decode(HT) 2.6 2.89 4.24 13.87
Decode(oldbyte) 10.94 NA 3.03 NA
$ mkvmerge -i output.avi
File 'output.avi': container: AVI
Track ID 0: video (VP80)
Track ID 1: audio (MP3)
$ mkvmerge -o foo.webm -d 0 output.avi
mkvmerge v4.9.1 ('Ich will') built on Nov 30 2011 15:09:57
Automatically enabling WebM compliance mode due to output file name extension.
'output.avi': Using the AVI demultiplexer. Opening file. This may take some time depending on the file's size.
Error: The codec type 'VfW compatible video' cannot be used in a WebM compliant file.
request = self.receive()
print 'request received'
if request.is_disconnect():
print 'disconnect'
continue
@jasom
jasom / gist:2562681
Created April 30, 2012 21:04
Array arguments are really pointers
#include <stdio.h>
void foo(char []);
void bar(char *);
int main()
{
static char x[100];
printf("%ld\n",sizeof(x));
foo(x);
bar(x);
@jasom
jasom / gist:3232015
Created August 2, 2012 00:46
Jazzychad increment function
(defun increment (sequence val n)
(substitute (1+ val) val sequence
:from-end (< n 0)
:count (if (= n 0) nil (abs n))))
diff --git a/src/connection.c b/src/connection.c
index af84217..a313886 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -785,7 +785,10 @@ void Connection_destroy(Connection *conn)
bdestroy(Connection_deliver_dequeue(conn));
}
Connection_deliver_enqueue(conn,NULL);
- taskyield();
+ shutdown(IOBuf_fd(conn->iob),SHUT_WR); /* This should kill the deliver task */
(defparameter *true* t)
(defparameter *false* nil)
(defparameter *null* nil)
(defparameter *empty-dict* nil)
(defparameter *empty-list* nil)
(declaim (optimize (speed 3)))
(defun <isfloat> ()
(=and
(smug:int)