Skip to content

Instantly share code, notes, and snippets.

View pingf's full-sized avatar
💭
waiting for delivery!

Makefile君 pingf

💭
waiting for delivery!
View GitHub Profile
@pingf
pingf / processify.py
Created April 26, 2019 03:22 — forked from schlamar/processify.py
processify
import os
import sys
import traceback
from functools import wraps
from multiprocessing import Process, Queue
def processify(func):
'''Decorator to run a function as a process.
Be sure that every argument and the return value
@pingf
pingf / simple_lang.js
Created February 21, 2019 02:18 — forked from JustinSDK/simple_lang.js
simple_lang.js - this gist has evolved into https://github.com/JustinSDK/toy_lang
// === Tokenizer
class Tokens {
constructor(tokens) {
this.head = tokens[0];
this.tail = tokens.slice(1);
}
}
class Tokenizer {
@pingf
pingf / psycopg2_performance.py
Created February 15, 2019 03:57 — forked from wizzat/psycopg2_performance.py
Psycopg2 vs Psycopg2cffi, Python 2.7.3 vs Pypy-2.0.1 benchmark
try:
from psycopg2cffi import compat
compat.register()
except ImportError:
pass
from pyutil.decorators import *
import tempfile, psycopg2, psycopg2.extras
def setup_test_table(conn):
#!/usr/bin/python2
# -*- coding:utf-8 -*-
import requests
import time
import hashlib
from Crypto.Cipher import AES
import base64
import json
@pingf
pingf / logging.yaml
Created November 10, 2018 06:25 — forked from JesseBuesking/logging.yaml
Testing MultiProcessingLog on both Windows 7 Enterprise and Ubuntu Developers Version 10.04_20121120.
---
version: 1
disable_existing_loggers: False
formatters:
simple:
format: "%(name)-20s%(levelname)-8s%(message)s"
handlers:
console:
class: logging.StreamHandler
level: DEBUG
@pingf
pingf / aiohttp+websockets.md
Created January 15, 2018 07:17
aiohttp server with websocket

** aiohttp now supports in its webframework websocket **

http://aiohttp.readthedocs.org/en/v0.14.1/web.html#websockets

This is a quick hack (ported from django-c10k) to get websocket working along side classic http with aiohttp web server. I think it would be better to inherit the aiohttp.web.RequestHandler and add the code to handle the upgrade in RequestHandler.start instead of overriding RequestHandler.transport.close in WebsocketResponse.

Anyway, it seems like it works.

requirements:

@pingf
pingf / aiohttp+websockets.md
Created January 15, 2018 07:17
aiohttp server with websocket

** aiohttp now supports in its webframework websocket **

http://aiohttp.readthedocs.org/en/v0.14.1/web.html#websockets

This is a quick hack (ported from django-c10k) to get websocket working along side classic http with aiohttp web server. I think it would be better to inherit the aiohttp.web.RequestHandler and add the code to handle the upgrade in RequestHandler.start instead of overriding RequestHandler.transport.close in WebsocketResponse.

Anyway, it seems like it works.

requirements:

@pingf
pingf / aiohttp+websockets.md
Created January 15, 2018 07:17
aiohttp server with websocket

** aiohttp now supports in its webframework websocket **

http://aiohttp.readthedocs.org/en/v0.14.1/web.html#websockets

This is a quick hack (ported from django-c10k) to get websocket working along side classic http with aiohttp web server. I think it would be better to inherit the aiohttp.web.RequestHandler and add the code to handle the upgrade in RequestHandler.start instead of overriding RequestHandler.transport.close in WebsocketResponse.

Anyway, it seems like it works.

requirements:

@pingf
pingf / dom-to-json.js
Created August 29, 2017 08:51 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
node = node || this;
var obj = {
nodeType: node.nodeType
};
if (node.tagName) {
obj.tagName = node.tagName.toLowerCase();
} else
if (node.nodeName) {
obj.nodeName = node.nodeName;