This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from math import sqrt | |
import jieba.analyse | |
def cut_word(content): | |
''' | |
(u'\u65b9\u5e84', 2.4582479479) | |
(u'\u82b3\u57ce\u56ed', 1.19547675029) | |
(u'\u53ef\u6708\u4ed8', 1.19547675029) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
######################################### | |
# kNN: k Nearest Neighbors | |
# Input: newInput: vector to compare to existing dataset (1xN) | |
# dataSet: size m data set of known vectors (NxM) | |
# labels: data set labels (1xM vector) | |
# k: number of neighbors to use for comparison |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import BaseHTTPServer | |
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |
def do_FUCK(s): | |
s.send_response(200) | |
s.send_header("Content-type", "text/html") | |
s.end_headers() | |
s.wfile.write("just a kidding\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create new tiny url | |
``` | |
curl -i -X POST -H "Content-Type:application/json" -d '{"url": "http://example.com"}' 'http://t.bdaily.club' | |
Response: | |
{ | |
"msg": "ok", | |
"data": { | |
"tiny_url": "http://t.bdaily.club/ssddz", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"_id":"douban_group","startUrl":["https://www.douban.com/group/qiong/discussion"],"selectors":[{"id":"page","type":"SelectorLink","parentSelectors":["_root","page"],"selector":".paginator > a","multiple":true,"delay":0},{"id":"post","type":"SelectorElement","parentSelectors":["_root","page"],"selector":"tr:nth-of-type(n+2)","multiple":true,"delay":0},{"id":"link","type":"SelectorLink","parentSelectors":["post"],"selector":".title a","multiple":false,"delay":0},{"id":"author","type":"SelectorText","parentSelectors":["post"],"selector":"[nowrap] a","multiple":false,"regex":"","delay":0},{"id":"updated","type":"SelectorText","parentSelectors":["post"],"selector":"td.time","multiple":false,"regex":"","delay":0}]} |