双锂电改装超轻量大续航电动车
早上天亮龙龛码头环海西路出发
晚上天黑回大理城
精疲力尽的将传说中的洱海150+公里环行掉了
苗寨有感
自然醒来发现昨夜一场洪雨唤起了我二十年前第一次仙剑入苗时的点滴
Linux Centos7 ThinkPad X1C无线网卡问题解决记录
折腾了两天,总结下问题
不知是2015款才有的问题还是前面几代内置无线网卡型号不同而不同
话说刚装Centos7系统时
安装向导顺利适配无线网卡并顺畅连接无线网络完成整个安装过程
然而在正常启动登录后,网卡是不适配的,当然除此之外其它驱动都完美适配
初步判断是安装向导自带很多无线驱动
但这些不是全都默认安装的,不过好歹知道是肯定支持的就放心了
查阅大量相关社区讨论及文档阅读后
最终发现这款型号Intel Wireless-N 7265 BN的驱动官方yum源就有:
1 |
iwl7265-firmware.noarch : Firmware for Intel(R) Dual Band Wireless-AC 7265: Series Adapters |
由于无网络连有线口都没,只好先去台式机用yum只下载不安装
1 |
sudo yum install --downloadonly --downloaddir=/home/srj/Downloads iwl7265-firmware |
得到iwl7265-firmware-22.0.7.0-36.el7.noarch.rpm安装包后通过U盘拷贝到小C本地安装
1 |
sudo yum localinstall iwl7265-firmware-22.0.7.0-36.el7.noarch.rpm |
重启后无线网络的小图标久别重逢了
但是好景不长就发现网络虽能连接但及其不稳定
掉包效超高,断线率也不少,经常动不动就全没了
回想安装向导时那驱动还是很稳定服务的,只能怀疑驱动版本问题了,毕竟小C内置的不是双频AC网卡,当然这要在Windows下肯定是一个大驱动全包了
接着又搜寻了许久,最终在
https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi
找到了传说中Intel全系列Linux Wireless Driver下载集中地
然后根据Centos7 Kernel 3.10旧内核版本比较其实都不匹配
最终比对了下之前yum源安装的驱动
1 2 3 4 5 |
[srj@x1c firmware]$ pwd /usr/lib/firmware [srj@x1c firmware]$ ll|grep 7265 -rw-r--r--. 1 root root 690452 8月 9 23:40 iwlwifi-7265-8.ucode -rw-r--r--. 1 root root 697828 8月 9 23:47 iwlwifi-7265-9.ucode |
发现刚好就是iwlwifi-7265-ucode-22.24.8.0.tgz和iwlwifi-7265-ucode-25.228.9.0.tgz里的两同名文件
那要么先升级内核要么病马当活马医
立即下载解压覆盖重启解决所有问题
稳定顺畅的网络总算在新设备新系统的折腾上划了一个圆满的句号
开始白转黑行走江湖拥抱开源世界
ThinkPad X1 Carbon 2015款
硬件完美取代MacBook Air 13最佳选择
大小相似屏幕大一寸,轻薄相似碳纤维无静电
最关键的是支持Linux很好
可惜了自带的Win7,开箱验完货就被全格成CentOS7
Linux下的炉石传说
感谢过去一年的基础积累
Linux环境炉石传说折腾成功
提前告别迟早要决裂的盗版时代
努力拥抱开源世界
百闻不如一见华西村
tornado http basic and digest auth handler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
from tornado.web import RequestHandler from tornado.escape import utf8 from hashlib import md5 class BasicAuthHandler(RequestHandler): def get(self): realm = 'renjie' username = 'foo' password = 'bar' # Authorization: Basic base64("user:passwd") auth_header = self.request.headers.get('Authorization', None) if auth_header is not None: # Basic Zm9vOmJhcg== auth_mode, auth_base64 = auth_header.split(' ', 1) assert auth_mode == 'Basic' # 'Zm9vOmJhcg==' == base64("foo:bar") auth_username, auth_password = auth_base64.decode('base64').split(':', 1) if auth_username == username or auth_password == password: self.write('ok') else: self.write('fail') else: ''' HTTP/1.1 401 Unauthorized WWW-Authenticate: Basic realm="renjie" ''' self.set_status(401) self.set_header('WWW-Authenticate', 'Basic realm="%s"' % realm) class DigestAuthHandler(RequestHandler): def get(self): realm = 'test' opaque = 'asdf' # Real implementations would use a random nonce. nonce = "1234" username = 'foo' password = 'bar' ''' Authorization: Digest username="foo", realm="test", nonce="1234", uri="/auth/digest", response="e839337ef079c93238a4bf4f1ae712b3", opaque="asdf" ''' auth_header = self.request.headers.get('Authorization', None) if auth_header is not None: auth_mode, params = auth_header.split(' ', 1) assert auth_mode == 'Digest' param_dict = {} for pair in params.split(','): k, v = pair.strip().split('=', 1) if v[0] == '"' and v[-1] == '"': v = v[1:-1] param_dict[k] = v assert param_dict['realm'] == realm assert param_dict['opaque'] == opaque assert param_dict['nonce'] == nonce assert param_dict['username'] == username assert param_dict['uri'] == self.request.path h1 = md5(utf8('%s:%s:%s' % (username, realm, password))).hexdigest() h2 = md5(utf8('%s:%s' % (self.request.method, self.request.path))).hexdigest() digest = md5(utf8('%s:%s:%s' % (h1, nonce, h2))).hexdigest() if digest == param_dict['response']: self.write('ok') else: self.write('fail') else: self.set_status(401) # WWW-Authenticate: Digest realm="test", nonce="1234", opaque="asdf" self.set_header('WWW-Authenticate', 'Digest realm="%s", nonce="%s", opaque="%s"' % (realm, nonce, opaque)) |
python tornado微信公众号开发者认证示例代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import tornado.web import hashlib class WechatHandler(tornado.web.RequestHandler): def check(self): #微信公众平台设置 token = "renjie" #微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。 signature = self.get_argument("signature", None) #时间戳 timestamp = self.get_argument("timestamp", None) #随机数 nonce = self.get_argument("nonce", None) #随机字符串 echostr = self.get_argument("echostr", None) if signature and timestamp and nonce: #将token、timestamp、nonce三个参数进行字典序排序 param = [token, timestamp, nonce] param.sort() #将三个参数字符串拼接成一个字符串进行sha1加密 sha = hashlib.sha1("%s%s%s" % tuple(param)).hexdigest() #开发者获得加密后的字符串可与signature对比,标识该请求来源于微信 if sha == signature: if echostr: #请原样返回echostr参数内容,则接入生效,成为开发者成功,否则接入失败。 return echostr else: return True return False def get(self): self.write(str(self.check())) |
svn: E200015 error proxy servers config
SVN E200015错误代理服务器配置文件位置
WIN:%APPDATA%Subversionservers
其它:~/.subversion/servers
1 2 3 4 5 6 7 8 9 10 |
#例外不走代理 http-proxy-exceptions = *.exception.com, www.internal-site.org #代理服务器 http-proxy-host = defaultproxy.whatever.com #代理端口号 http-proxy-port = 7000 #代理用户名 http-proxy-username = defaultusername #代理密码 http-proxy-password = defaultpassword |
如果是用TortoiseSVN,还有更直观的GUI设置
urllib2 vs tornado.httpclient and proxy vs auth
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import urllib2 # set up authentication info authinfo = urllib2.HTTPBasicAuthHandler() authinfo.add_password(realm='PDQ Application', uri='https://mahler:8092/site-updates.py', user='klem', passwd='geheim$parole') proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"}) # build a new opener that adds authentication and caching FTP handlers opener = urllib2.build_opener(proxy_support, authinfo, urllib2.CacheFTPHandler) # install it urllib2.install_opener(opener) f = urllib2.urlopen('http://www.python.org/') |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import tornado.httpclient param = { "url" : "http://www.renjie.me/example", "proxy_host" : "proxy.renjie.me", "proxy_port" : 8080, "proxy_username" : "test", "proxy_password" : "welcome", "auth_mode" : "basic", "auth_username" : "renjie", "auth_password" : "CASwW8iJ" } http_request = tornado.httpclient.HTTPRequest(**param) http_client = tornado.httpclient.HTTPClient() try: response = http_client.fetch(http_request) print response.body except tornado.httpclient.HTTPError as e: print "Error:", e http_client.close() |