Skip to content

Instantly share code, notes, and snippets.

View SeavantUUz's full-sized avatar
💭
I may be slow to respond.

AprocySanae SeavantUUz

💭
I may be slow to respond.
View GitHub Profile
# coding: utf-8
__inspired__ = 'jimmyislive <https://github.com/jimmyislive/hg-pylint-commit-hook>'
__author__ = 'AprocySanae'
import os
import subprocess
from hgapi import hgapi
import re
from StringIO import StringIO
@SeavantUUz
SeavantUUz / gist:8916681
Last active August 29, 2015 13:56
fresh to network programming
import socket,select
CONNECTION_LIST = []
RECV_BUFFER = 4096
PORT = 5000
server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server_socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
server_socket.bind(("0.0.0.0",PORT))
server_socket.listen(10)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="http://cdn.bootcss.com/twitter-bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="pull-left">
<p class="muted">向上弹出的子菜单</p>
from BasePool import BasePool
class TaskPool(BasePool):
def __init__(self, *args, **kwargs):
from gevent import spawn_raw
from gevent.pool import Pool
self.Pool = Pool
super(TaskPool, self).__init__(*args, **kwargs)
def on_start(self):
def line_resize(lines, width):
count = len(lines)
index = 0
while index < count:
line = lines[index]
line_lenth = len(line)
if line_lenth > width:
s_width = 0
while s_width < line_lenth:
yield line[s_width:s_width+width]
def func_environment():
env = dict()
def symbol(identify, bp=0, auto_commit = True):
try:
s = env[identify]
except Exception:
class s(Token):
pass
if auto_commit:
s.__name__ = 'symbol-{}'.format(identify)
<!DOCTYPE html>
<head>
<script type="text/javascript">
var evtSrc = new EventSource("/test");
evtSrc.onmessage = function(e) {
console.log(e.data);
};
function send(){
var xhr = new XMLHttpRequest();
# coding: utf-8
from tornado.ioloop import IOLoop
import tornado.web
from tornado import gen
import time
import settings as Settings
class TestHandler(tornado.web.RequestHandler):
@gen.coroutine
function createXHR(){
if (typeof XMLHttpRequest != "undefined"){
return new XMLHttpRequest();
}
else {
throw new Error("No XHR object available");
}
}
<div class="l-content">
<div class="pricing-tables pure-g">
<div class="pure-u-1 pure-u-md-1-4">
<button type="button" class="button-success pure-button" onclick="test_start()">启动</button>
</div>
<div class="pure-u-1 pure-u-md-1-4">
<button type="button" class="button-error pure-button" onclick="test_stop()">停止</button>
</div>