Skip to content

Instantly share code, notes, and snippets.

View ktosiu's full-sized avatar

Marcin Boćkowski ktosiu

View GitHub Profile
@jsheedy
jsheedy / README.md
Created December 2, 2016 20:47
asyncio + uvloop echo server benchmark

asyncio + uvloop echo server benchmark

This is an attempt at a bare minimum client/server benchmark of asyncio with optional use of uvloop. On my 2015 macbook pro, I get almost 2.5X improvement using uvloop in the server.

The client runs PARALLEL tasks at once. Running only a single task results in about 1/8 the throughput of 100 simultaneous tasks.

# with uvloop
$ python client.py
satisfied 100000 requests in 1.41021 seconds (70911.42 reqs/s)
@kracekumar
kracekumar / ws_app.py
Last active September 5, 2024 17:04
Simple websocket server with uvloop.
# -*- coding: utf-8 -*-
import asyncio
import uvloop
from aiohttp.web import Application, MsgType, WebSocketResponse
def add_socket(app, socket, user_id):
if user_id in app['connections']:
pass
@hartfordfive
hartfordfive / locust_basic_auth_test.py
Created June 18, 2015 15:55
Sample LocustIO testing script with basic auth
'''
Simple LocustIO testing script with basic auth
'''
import random, gzip, StringIO, threading, urllib2, re, getpass
from locust import HttpLocust, TaskSet, task, web
from random import randint
from urlparse import urlparse
#resource.setrlimit(resource.RLIMIT_NOFILE, (999999, 999999))
USER_AGENTS = [
@guyzmo
guyzmo / simple-example-login-principals.py
Last active February 2, 2021 15:32
Simple example of Flask/Presst with Login and Principals (not working!)
#!/usr/bin/env python
from base64 import b64decode
from flask import Flask, current_app
from flask_sqlalchemy import SQLAlchemy
from flask_presst import PresstApi, ModelResource
from flask_presst.principal import PrincipalResource
from flask.ext.principal import UserNeed, RoleNeed
@softwaredoug
softwaredoug / gevent_http.md
Last active October 5, 2016 06:22
gevent_http

A response to Preetam Jinka's nice little Go demo.

Similar basic HTTP server using Gevent/Python

from gevent import pywsgi
import md5

def md5_body(environ, start_response):
    md5Hash = md5.new()
@xjdrew
xjdrew / echo.py
Created August 5, 2014 04:08
gevent echo service
import gevent
from gevent import monkey;monkey.patch_all()
import socket
def handle_client(csock):
while True:
data = csock.recv(1024)
csock.sendall(data)
csock.close()
@jfryman
jfryman / Links.md
Last active August 29, 2015 14:01
Links for OpenSourceDays
####################################
# echo.py
####################################
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, division
import functools
import os
import socket
import time
import pyuv
def on_connection(message, handle, loop):
@robschmuecker
robschmuecker / README.md
Last active March 28, 2025 14:54
D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing.

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.