Skip to content

Instantly share code, notes, and snippets.

View binux's full-sized avatar

Roy Binux binux

View GitHub Profile
@binux
binux / mem_cache.py
Created January 6, 2012 11:39
一个通用的python function cache
# -*- coding: utf-8 -*-
#
# Copyright(c) 2010 poweredsites.org
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@binux
binux / jsfunctionParser.py
Created December 14, 2011 13:12
xunlei lixian plugin for flexget
# jsonParser.py
#
# Implementation of a simple JSON parser, returning a hierarchical
# ParseResults object support both list- and dict-style data access.
#
# Copyright 2006, by Paul McGuire
#
# Updated 8 Jan 2007 - fixed dict grouping bug, and made elements and
# members optional in array and object collections
#
@binux
binux / gist:1384677
Created November 22, 2011 02:10
a diff function base on Advanced Dynamic Programming
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on 2011-6-7
Modified on 2011-11-22
a diff function base on Advanced Dynamic Programming
http://www.avatar.se/molbioinfo2001/dynprog/adv_dynamic.html
@author: binux
@binux
binux / gist:1369949
Created November 16, 2011 12:21
call any function asynchronous in tornado
class AsyncProcessMixin(object):
def call_subprocess(self, func, callback=None, args=[], kwargs={}):
self.ioloop = tornado.ioloop.IOLoop.instance()
self.pipe, child_conn = Pipe()
def wrap(func, pipe, args, kwargs):
try:
pipe.send(func(*args, **kwargs))
except Exception, e:
logging.error(traceback.format_exc())
@binux
binux / background.html
Created April 23, 2011 02:24
ip2loc for byr forum (http://bbs.byr.cn) chrome extension
<html>
<head>
</head>
<body>
<script>
function fetchLocation(callback,ip) {
var req = new XMLHttpRequest();
req.open("GET","http://www.youdao.com/smartresult-xml/search.s?type=ip&q="+ip,true);
req.onload = function() {
var response = req.responseText;
#!/usr/bin/python
# filename: parse_dblp.py
# author: ivanchou
import codecs, os
import xml.etree.ElementTree as ET
paper_tag = ('article','inproceedings','proceedings','book',
'incollection','phdthesis','mastersthesis','www')
class AllEntities:
import threading
import tornado
import tornado.httpserver
import tornado.websocket
wss = []
class WSHandler(tornado.websocket.WebSocketHandler):
def check_origin(self, origin):
@binux
binux / TODO.md
Created December 11, 2014 14:14
pyspider TODO

v0.3.0

[x] as a package [x] run.py parameters [x] sortable projects list #12 [x] Postgresql Supported via SQLAlchemy (with the power of SQLAlchemy, pyspider also support Oracle, SQL Server, etc) [x] benchmarking [ ] pypi release version

v0.4.0

@binux
binux / douban.py
Last active August 29, 2015 14:08
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Created on 2014-09-10 12:05:42
import os
import re
import json
import datetime
from libs.pprint import pprint
@binux
binux / tools.sh
Last active August 29, 2015 14:08
#!/bin/bash
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-10-23 23:26:46
PROCESSOR=`uname -p`
# make tools dir
mkdir -p $HOME/tools