Skip to content

Instantly share code, notes, and snippets.

View pocketwalker's full-sized avatar

Bill Yeu pocketwalker

View GitHub Profile
@pocketwalker
pocketwalker / watchop.py
Created September 1, 2012 01:06 — forked from anonymous/watchop.py
making it easy to watch one piece
#!/usr/bin/python
#coding=utf-8
from bs4 import BeautifulSoup
import sys, re
import urllib, urllib2
import xml.etree.ElementTree as ET
import webbrowser
#import codes, Queue, threading, time
def spider(net):
@pocketwalker
pocketwalker / scrapper.py
Created September 23, 2012 03:48
Compassionate Screen Scraping
import httplib2,time,re
from BeautifulSoup import BeautifulSoup
SCRAPING_CONN = httplib2.Http(".cache")
SCRAPING_DOMAIN_RE = re.compile("\w+:/*(?P<domain>[a-zA-Z0-9.]*)/")
SCRAPING_DOMAINS = {}
SCRAPING_CACHE_FOR = 60 * 15 # cache for 15 minutes
SCRAPING_REQUEST_STAGGER = 1100 # in milliseconds
SCRAPING_CACHE = {}
def fetch(url,method="GET"):
@pocketwalker
pocketwalker / BloomFilter
Created October 13, 2012 17:13
使用BloomFilter过滤用户long型IDs
import java.io.Serializable;
import java.util.BitSet;
import java.util.Random;
//MD5算法最为基础来构造哈希函数
/*
*for (int i = 0; i < funNum; i++){
* //输入URL地址拼接上Hash函数的编号
* String input = url+i.toString();
* //散列值取MD5摘要的后64位与比特向量大小的的余数
@pocketwalker
pocketwalker / GetParser.pm
Created November 24, 2012 10:36
memcached's perl binding
package Cache::Memcached::GetParser;
use strict;
use warnings;
use integer;
use Errno qw( EINPROGRESS EWOULDBLOCK EISCONN );
use constant DEST => 0; # destination hashref we're writing into
use constant NSLEN => 1; # length of namespace to ignore on keys
use constant ON_ITEM => 2;
#include <pthread.h>
#include <stdlib.h>
#define MAX_THREADS 512
void *compute_pi (void *);
//....
int main() {
//...
pthread_t p_threads[MAX_THREADS];
pthread_attr_t attr;
pthread_attr_init (&attr);
@pocketwalker
pocketwalker / rinkeby-account
Created December 6, 2017 06:18
rinkeby-account
0x1b4655326a78363fEE23b268D010499203641b47