Skip to content

Instantly share code, notes, and snippets.

Avatar

Roy Binux binux

View GitHub Profile
View script.js
// vim: set et sw=2 ts=2 sts=2 ff=unix fenc=utf8:
// Author: Binux<i@binux.me>
// http://binux.me
// Created on 2013-11-11 18:50:58
(function(){
function getOffset(elem) {
var top = 0;
var left = 0;
do {
@binux
binux / demo.py
Created Mar 8, 2014
demo script for douban.com
View demo.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Created on 2014-02-28 00:15:53
from libs.pprint import pprint
from libs.base_handler import *
class Handler(BaseHandler):
'''
View timeout3
#!/bin/bash
#
# The Bash shell script executes a command with a time-out.
# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal
# is blocked, then the subsequent SIGKILL (9) terminates it.
#
# Based on the Bash documentation example.
# Hello Chet,
# please find attached a "little easier" :-) to comprehend
View tools.sh
#!/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
View douban.py
#!/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 / TODO.md
Created Dec 11, 2014
pyspider TODO
View TODO.md

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

View websocket.py
import threading
import tornado
import tornado.httpserver
import tornado.websocket
wss = []
class WSHandler(tornado.websocket.WebSocketHandler):
def check_origin(self, origin):
View parse_dblp.py
#!/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:
@binux
binux / background.html
Created Apr 23, 2011
ip2loc for byr forum (http://bbs.byr.cn) chrome extension
View background.html
<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;
@binux
binux / gist:1369949
Created Nov 16, 2011
call any function asynchronous in tornado
View gist:1369949
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())