This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf8 | |
import base64 | |
import io | |
import hashlib | |
from M2Crypto import RSA | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
""" | |
Tornado source code write comments in `iostream._handle_events` which links is https://github.com/tornadoweb/tornado/blob/master/tornado/iostream.py#L695: | |
``` | |
# Most IOLoops will report a write failed connect | |
# with the WRITE event, but SelectIOLoop reports a | |
# READ as well so we must check for connecting before |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env | |
# coding: utf-8 | |
import asyncio | |
import requests | |
import tornado.gen as gen | |
import tornado.httpclient as httpclient | |
import tornado.httpserver as httpserver | |
import tornado.options as options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
// 声明一个变量 aVar 类型为 string | |
var aVar string | |
fmt.Printf("aVar: %p %#v\n", &aVar, aVar) // 输出 aVar: 0xc42000e240 "" | |
aVar = "This is a aVar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
import socket | |
import sys | |
import threading | |
from itertools import chain | |
from queue import LifoQueue, Full, Empty | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"strconv" | |
"log" | |
"net/http" | |
"fmt" | |
"bytes" | |
"gopkg.in/gin-gonic/gin.v1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def main(): | |
coroutine1 = do_some_work(1) | |
coroutine2 = do_some_work(2) | |
coroutine3 = do_some_work(4) | |
tasks = [ | |
asyncio.ensure_future(coroutine1), | |
asyncio.ensure_future(coroutine2), | |
asyncio.ensure_future(coroutine3) | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_params(request): | |
if not isinstance(request, HTTPServerRequest): | |
request = request.request | |
parse_url = urlparse.urlparse(request.uri) | |
path, params, query, fragment = parse_url.path, parse_url.params, parse_url.query, parse_url.fragment | |
uri = urlparse.urlunparse((request.protocol, request.host, path, params, query, fragment)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
__author__ = 'ghost' | |
import time, uuid, functools, threading, logging | |
def next_id(t=None): | |
""" | |
""" | |
if t is None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster'); | |
if (cluster.isMaster) { | |
/* var cpu_count = require('os').cpus().length; | |
require('os').cpus().forEach(function() { | |
cluster.fork(); | |
});*/ | |
var cpu_count = 2; | |
for (var i = 0; i < cpu_count; i++){ | |
cluster.fork(); |