Skip to content

Instantly share code, notes, and snippets.

View ninehills's full-sized avatar

Tao Yang ninehills

View GitHub Profile
(function () {
if ("undefined" !== typeof Send2eg300) {
return
};
window.Send2eg300 = Send2eg300 = {
server: "http://send2.eg300.com/",
jQuery: "js/jquery-1.8.3.min.js",
params: {
"isLinkConverted": false
},
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/python");</script>
#!/usr/bin/env python
#coding:utf-8
import sys, os, re
import logging
from tornado.ioloop import IOLoop
from tornado.iostream import IOStream
from tornado.netutil import TCPServer
@ninehills
ninehills / backgroudmix.py
Last active December 10, 2015 17:08 — forked from methane/gist:2185380
tornado add block task to ThreadPool
from time import sleep
import tornado
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
class BackgroundMix(tornado.web.RequestHandler):
"""将block任务放入线程池中执行
EXAMPLE:
# blocking task like querying to MySQL
@ninehills
ninehills / tree.md
Created January 3, 2013 03:13 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

# Copyright (c) 2010, Philip Plante of EndlessPaths.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@ninehills
ninehills / SimpleHTTPServerWithUpload.py
Created December 12, 2012 04:19
Simple HTTP Server With Upload.
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
Usage: python -m SimpleHTTPServerWithUpload 8888
"""
# Copyright (c) 2010, Philip Plante of EndlessPaths.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@ninehills
ninehills / async_process.py
Created December 3, 2012 09:33 — forked from stephenwilley/async_process.py
Module type version of original with gen example
# Adapted from here: https://gist.github.com/489093
# Original credit goes to pplante and copyright notice pasted below
# Copyright (c) 2010, Philip Plante of EndlessPaths.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@ninehills
ninehills / vimwiki.diff
Created December 2, 2012 03:26
vimwiki.diff
diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim
index 4b5aac7..1714c72 100644
--- a/autoload/vimwiki/html.vim
+++ b/autoload/vimwiki/html.vim
@@ -1347,7 +1347,7 @@ endfunction " }}}
function! s:use_custom_wiki2html() "{{{
let custom_wiki2html = VimwikiGet('custom_wiki2html')
- return !empty(custom_wiki2html) && s:file_exists(custom_wiki2html)
+ return !empty(custom_wiki2html)