Skip to content

Instantly share code, notes, and snippets.

@Chairo
Chairo / ElasticConstant.java
Last active October 3, 2019 12:12
Elastic Spring Boot Starter
package com.au92.common.elastic;
/**
* @author: p_x_c
*/
public class ElasticConstant {
/**
* 配置文件中多cluster分割符号
*/
public static final String CLUSTER_SPLIT = ",";
@Chairo
Chairo / file_info.py
Created August 28, 2013 14:48
Python搭建BT资源搜索站(四)
# -*- coding:utf-8 -*-
import libtorrent as lt, hashlib
from pymongo import Connection
def file_path(info_hash):
'''get new file path and name'''
_md5 = hashlib.md5(info_hash).hexdigest()
return {'path':'%s/%s/'%(_md5[0:2], _md5[2:5]), 'file_name':'%s.torrent'%_md5}
#解析BT文件并更新对应信息到Mongo数据库
@Chairo
Chairo / down_torrents.py
Created August 24, 2013 17:17
Python搭建BT资源搜索站(三)
# -*- coding:utf-8 -*-
import requests, os, hashlib
from pymongo import Connection #引入Mongo支持
#连接Mongo
mongo = Connection(host='127.0.0.1', port=27017)
db = mongo.bt #连接bt这个数据库,没有会自动新建
#保存下载的BT种子
def save_file_to_disk(content, info_hash):
@Chairo
Chairo / txt.py
Created August 22, 2013 12:56
Python搭建BT资源搜索站(二)
# -*- coding:utf-8 -*-
from pymongo import Connection #引入Mongo支持
#连接Mongo
mongo = Connection(host='127.0.0.1', port=27017)
db = mongo.bt #连接bt这个数据库,没有会自动新建
#读取下载的文件内容
def read_data():
_file = open('20130820.txt', 'rb').readlines()
@Chairo
Chairo / torrage.py
Last active December 21, 2015 08:59
Python搭建BT资源搜索站(一)
# -*- coding:utf-8 -*-
import requests #引入requests第三方库支持
#定义一个函数,下载torrage.com上的文件
def download():
_url = 'http://torrage.com/sync/20130820.txt' #要下载的文件
_content = requests.get(_url, timeout=3).content #通过requests抓取到要下载的文件的具体内容
open('20130820.txt', 'wb').write(_content) #保存到e:\python\01hg\bt-search\这个目录下(需提前建好这个目录)
if __name__ == "__main__":
@Chairo
Chairo / blogrolls.py
Created November 2, 2012 13:16
blogrolls.py
# -*- coding:utf-8 -*-
import libxml2dom, sys, requests
reload(sys)
sys.setdefaultencoding('utf-8')
def affect(points, keep_ratio, ratio, power):
keep = points * keep_ratio
if ratio >= 1.: return points
return keep + (points - keep) * pow(ratio, power)
@Chairo
Chairo / varnish
Created November 1, 2012 08:33
varnish
# Configuration file for varnish
#
# /etc/init.d/varnish expects the variables $DAEMON_OPTS, $NFILES and $MEMLOCK
# to be set from this shell script fragment.
#
# Should we start varnishd at boot? Set to "yes" to enable.
START=yes
# Maximum number of open files (for ulimit -n)
@Chairo
Chairo / default.vcl
Created November 1, 2012 07:57
default.vcl for version 2.x
backend au92 {
.host = "www.au92.com";
.port = "80";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
.max_connections = 800;
}
@Chairo
Chairo / default.vcl
Created November 1, 2012 07:52
default.vcl
include "vhost/au92.vcl";
#允许刷新缓存的 ip
acl purgeAllow {
"127.0.0.1";
"172.16.101.33";
}
#/acl iplist##############################################################
@Chairo
Chairo / fetion.py
Created July 20, 2012 03:02 — forked from liuzhoou/fetion.py
fetion
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cookielib
import urllib
import urllib2
import re
url_login = 'http://f.10086.cn/im/login/inputpasssubmit1.action'
url_logout = 'http://f.10086.cn//im/index/logoutsubmit.action?t='