Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<style>
iframe {
margin-top:10000px;
}
</style>
</head>
<body>
@nickfishman
nickfishman / stress_sockets.py
Last active December 26, 2015 22:29
Python utility that attempts to listen on a wide range of ports. Designed to help test the OS open files limit.
#!/usr/bin/env python
"""
Python utility that attempts to listen on a wide range of ports.
Designed to stress test the OS open files limit.
"""
import argparse
import socket
parser = argparse.ArgumentParser(
@nickfishman
nickfishman / client.py
Created October 15, 2013 22:13
End-to-end example of autobahn.ws with dynamic pubsub channels. Each channel is private, even though it matches the same prefix URI defined in the server. Based on example in https://github.com/tavendo/AutobahnPython/tree/master/examples/wamp/pubsub/simple/example1.
import os, sys
from twisted.python import log
from twisted.internet import reactor
from autobahn.websocket import connectWS
from autobahn.wamp import WampClientFactory, \
WampClientProtocol
ROOM_ID = ''
@nickfishman
nickfishman / testGzipKnox.js
Created May 4, 2013 07:49
Proof of concept of streaming a file through zlib and into s3, without storing the entire file in memory. knox-mpu provides support for Amazon's multipart upload, which allows us to stream an arbitrary amount of data without specifying the content-length ahead of time.
/**
* Proof of concept of streaming a file through zlib and into s3,
* without storing the entire file in memory. knox-mpu provides support
* for Amazon's multipart upload, which allows us to stream an arbitrary
* amount of data without specifying the content-length ahead of time.
*/
var knox = require('knox'),
fs = require('fs'),
zlib = require('zlib'),
MultiPartUpload = require('knox-mpu');
@nickfishman
nickfishman / gzipRequestStreams.js
Created May 4, 2013 00:24
Third attempt at conditional gzip decoding based on the Content-Encoding response header with the mikeal/request library for Node.js. Based on Mikeal's code.
var request = require('request'),
zlib = require('zlib'),
fs = require('fs');
var headers = {
"accept-charset" : "ISO-8859-1,utf-8;q=0.7,*;q=0.3",
"accept-language" : "en-US,en;q=0.8",
"accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
"accept-encoding" : "gzip,deflate",
@nickfishman
nickfishman / gzipRequestTest.js
Last active July 21, 2021 22:16
Second attempt at conditional gzip decoding based on the Content-Encoding response header with the mikeal/request library for Node.js. This DOES work.
var request = require('request'),
zlib = require('zlib');
var headers = {
"accept-charset" : "ISO-8859-1,utf-8;q=0.7,*;q=0.3",
"accept-language" : "en-US,en;q=0.8",
"accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
"accept-encoding" : "gzip,deflate",
};
@nickfishman
nickfishman / gist:5499713
Last active December 16, 2015 21:29
Attempt to do conditional gzip decoding based on the Content-Encoding response header with the mikeal/request library for Node.js. This does not work.
var request = require('request'),
zlib = require('zlib');
var headers = {
"accept-charset" : "ISO-8859-1,utf-8;q=0.7,*;q=0.3",
"accept-language" : "en-US,en;q=0.8",
"accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
"accept-encoding" : "gzip,deflate",
};