Skip to content

Instantly share code, notes, and snippets.

rsj217 rsj217

Block or report user

Report or block rsj217

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View python-m2crypto.py
# coding=utf8
import base64
import io
import hashlib
from M2Crypto import RSA
@rsj217
rsj217 / connect_event.py
Last active Jan 16, 2019
python socket
View connect_event.py
#!/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
View tornado-uvloop.py
#!/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
View go-poiter-new-make-nil.go
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"
View redis-block-pool.py
#!/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
View golang-gin-mysql-curd.go
package main
import (
"database/sql"
"strconv"
"log"
"net/http"
"fmt"
"bytes"
"gopkg.in/gin-gonic/gin.v1"
View asyncio-as-complete.py
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)
]
View extract_params.py
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))
@rsj217
rsj217 / db.py
Created May 6, 2014
a python class to use mysql. mysql 的连接关闭查询的python封装
View db.py
# -*- coding: utf-8 -*-
__author__ = 'ghost'
import time, uuid, functools, threading, logging
def next_id(t=None):
"""
"""
if t is None:
View node-cluse-expressr-production-session.js
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();
You can’t perform that action at this time.