Skip to content

Instantly share code, notes, and snippets.

@Lothiraldan
Lothiraldan / direct_call.sh
Created May 18, 2013 14:16
Hello world benchmark.
&> python hello_tornado.py &
&> boom http://localhost:8888 -c 100 -n 1000
Server Software: TornadoServer/3.0.1
Running GET http://127.0.0.1:8888
Host: localhost
Running 1000 times per 100 workers.
Starting the load [======================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
@Lothiraldan
Lothiraldan / circus.ini
Created May 18, 2013 14:15
Hello world tornado, circus config
[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
stats_endpoint = tcp://127.0.0.1:5557
httpd = True
httpd_host = localhost
httpd_port = 8080
[watcher:dummy]
@Lothiraldan
Lothiraldan / hello_world_circus.py
Created May 18, 2013 14:12
Hello world tornado working with circus
import sys
import socket
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
@Lothiraldan
Lothiraldan / hello_world.py
Created May 18, 2013 14:11
Tornado hello world
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
@Lothiraldan
Lothiraldan / expected_output_0.20.6
Last active December 16, 2015 19:59
Timing issue with aliases and index status
{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}
[u'test.1.1']
[u'test.1.1']
{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}
[u'test.1.2']
[u'test.1.2']
{"ok":true,"acknowledged":true}%
@Lothiraldan
Lothiraldan / app.py
Created April 9, 2013 09:27
How to make gunicorn timeout with a simple app?
import requests
from flask import Flask
app = Flask(__name__)
app.debug=True
@app.route("/hello")
def world():
return "Hello world"
@app.route("/")
@Lothiraldan
Lothiraldan / gist:4944998
Created February 13, 2013 14:34
Queries
$ curl -XGET 'http://localhost:9200/user1/docs/_search?q=docs.path:*'
{
"_shards": {
"failed": 0,
"successful": 5,
"total": 5
},
"hits": {
"hits": [
{
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
@Lothiraldan
Lothiraldan / udp_listener.py
Created October 25, 2012 10:06
Multiple UDP listener on the same port
import socket
# Socket part
ANY = "0.0.0.0"
MCAST_ADDR = "237.252.249.227"
MCAST_PORT = 1600
#create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
#allow multiple sockets to use the same PORT number
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
@Lothiraldan
Lothiraldan / multicast.java
Created October 22, 2012 17:39
UDP Multicast Socket
InetAddress group = InetAddress.getByName("228.5.6.7");
MulticastSocket s = new MulticastSocket(6789);
s.joinGroup(group);