Skip to content

Instantly share code, notes, and snippets.

View tonyseek's full-sized avatar

Jiangge Zhang tonyseek

View GitHub Profile
@tonyseek
tonyseek / base.py
Last active August 29, 2015 14:21
The base class of entity models.
__all__ = ['EntityModel']
class EntityModel(object):
"""The base class of entity models.
All entity models are comparable and hashable. There are some meta
attributes:
- ``id_attr_name``
@tonyseek
tonyseek / conrotine_task_manager.py
Created April 26, 2012 05:39
The demo of a corotine task manager.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from Queue import Queue
# ---------------------
# Corotine Task Manager
# ---------------------
@tonyseek
tonyseek / demo.php
Created June 18, 2012 07:58
Implementing observer pattern in PHP >= 5.4
<?php
require_once 'observer.php';
require_once 'subject.php';
use Common\Observer\Observer;
use Common\Observer\Subject;
class Notice
{
use Subject;
@tonyseek
tonyseek / checklink.py
Created June 25, 2012 17:41
Visit all links of a website.
@tonyseek
tonyseek / extract_captcha.py
Created July 26, 2012 13:13
Distinguish captcha with PIL and Tesseract
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import StringIO
import requests
import PIL.Image
import tesserwrap
@tonyseek
tonyseek / owdo
Created August 23, 2012 02:57
OVER GREAT FIREWALL DO ANYTHING
#!/usr/bin/env sh
if [ -n "`ifconfig | grep tun`" ]; then
export http_proxy="http://10.x.x.x:xxxx" # this proxy could only be used throught VPN.
else
export http_proxy="http://127.0.0.1:8087" # this is goagent proxy
fi
export https_proxy=$http_proxy
if [[ -n "$@" ]]; then
$@
@tonyseek
tonyseek / traversal.py
Created September 3, 2012 09:59
A traversal style dispatcher which is alike Quixote.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
def dispatch(entry_object, path, spliter="/"):
"""Starting with an entry object and dispatching the request by url path.
>>> class GroupList(object):
... exports = frozenset(["create"])
...
@tonyseek
tonyseek / test_validators.py
Created September 6, 2012 09:08
Simple validator for Quixote request input.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from functools import partial
from unittest import TestCase, main
from quixote.errors import QueryError
from validators import validate, ValidateError
@tonyseek
tonyseek / MainActivity.scala
Created September 13, 2012 10:13
Writing android demo application with Scala
package com.tonyseek.droid
import android.app.ActionBar
import android.app.FragmentTransaction
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentActivity
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.view.ViewPager
@tonyseek
tonyseek / gateway.py
Created September 18, 2012 04:55
A utility to give a object a gateway to exchange data with outside sources.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import re
import copy
import logging
from db.sqlstore import store