Skip to content

Instantly share code, notes, and snippets.

import socket
import select
import sys
# Start this server locally as follows
# python server.py 127.0.0.1 4444 1
BACKLOG = 1
def cmd_help(user, msg):
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.admin import Admin
from flask.ext.admin.contrib.sqla import ModelView
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
db = SQLAlchemy(app)
# Recursively check all combinations with +-
def check(step, acc, ops, digits):
if step >= len(digits):
if acc == 100:
row = ''
for pair in zip(digits, ops):
row += '%s %s ' % pair
print '%s%s' % (row, digits[-1])
from flask import Flask
from mongoengine import connect
from flask.ext.admin import Admin
from flask.ext.admin.contrib.mongoengine import ModelView
from flask.ext.mongoengine import MongoEngine
class Config(object):
DEBUG = True
from urlparse import urlparse, urljoin
from flask import request, url_for, redirect
from myapp.app import app
def is_safe_url(target):
ref_url = urlparse(request.host_url)
test_url = urlparse(urljoin(request.host_url, target))
<?xml version="1.0" encoding="utf-8"?>
<ISBoxerToolkitProfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="41" VersionMinor="1" BuildDate="9/1/2015 12:32:02 AM">
<CharacterSet>
<ExecuteOnLoad>
<RoundRobin>false</RoundRobin>
</ExecuteOnLoad>
<Name>Diablo III</Name>
<Description>Generated by ISBoxer 41 Quick Setup Wizard - 2/1/2015</Description>
<DisableFPSIndicator>false</DisableFPSIndicator>
<DisableForceWindowed>false</DisableForceWindowed>
@mrjoes
mrjoes / demo.py
Last active September 9, 2015 14:17
import os.path as op
from flask import Flask
from flask.helpers import locked_cached_property
from jinja2 import FileSystemLoader
class BubbleApp(Flask):
def __init__(self):
@mrjoes
mrjoes / gist:1462720
Created December 11, 2011 21:01
Dummy server
from tornado import web, websocket, ioloop
class Test(websocket.WebSocketHandler):
clients = set()
def open(self):
self.clients.add(self)
def on_message(self, msg):
for c in self.clients:
@mrjoes
mrjoes / gist:1462715
Created December 11, 2011 21:00
Dummy websocket client
import websocket
import threading
import random
import time
import sys
class Worker(threading.Thread):
def __init__(self, *args, **kwargs):
self.lock = threading.RLock()
self.packets_sent = 0
sent: number of messages sent by one client per second
recv: total number of messages received per one second
pings: in milliseconds
node.js echo server with commented log output:
clients: 5, sent: 8759.521709, recv: 43795.308466, min_ping: 0, max_ping: 4, avg_ping: 0.399996, errors: 0
clients: 25, sent: 1998.742675, recv: 49938.586699, min_ping: 0, max_ping: 20, avg_ping: 1.998743, errors: 0
clients: 50, sent: 1051.625850, recv: 52363.271976, min_ping: 0, max_ping: 59, avg_ping: 5.885065, errors: 0
clients: 100, sent: 514.820466, recv: 50273.736734, min_ping: 0, max_ping: 233, avg_ping: 22.884596, errors: 0
clients: 150, sent: 365.081970, recv: 52460.994307, min_ping: 0, max_ping: 473, avg_ping: 46.202689, errors: 0