Skip to content

Instantly share code, notes, and snippets.

facert

View GitHub Profile
View douban_group_sitemap
{"_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}]}
View Dtinyurl api docs
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",
View simplehttpserver.py
# 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")
@facert
facert / knn.py
Created Mar 6, 2017
python k 近邻实现
View knn.py
# 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
@facert
facert / cosine_similarity.py
Last active Apr 16, 2019
python 余弦相似度代码示例
View cosine_similarity.py
# 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)
You can’t perform that action at this time.