- 添加IMAP賬戶,如圖所示

- 添加賬戶之後Airmail表示收不到任何郵件
- 打開這個網址http://config.mail.163.com/settings/imap/[email protected],將uid後面改成自己的郵箱
- 按照頁面提示,解除對第三方客戶端對屏蔽
我為什麼還在用這麼辣雞的網易郵箱


我為什麼還在用這麼辣雞的網易郵箱

在開發mpv的插件時,需要發起http請求,但是mpv並沒有提供HTTP的api。
因此我們可以用VBScript或者PowerShell來發起請求。
運行cscript /nologo httpget.vbs “http://example.com”
|
1 2 3 4 5 6 7 8 9 10 11 12 |
args = WScript.Arguments.Count if args <> 1 then wscript.Quit end if URL = WScript.Arguments.Item(0) Set xmlhttp = CreateObject("Microsoft.XmlHttp") xmlhttp.open "GET", URL, false xmlhttp.setRequestHeader "User-Agent", "cscript/1.0" xmlhttp.send WScript.Echo xmlhttp.responseText |
或者:
|
1 |
powershell (Invoke-WebRequest -UserAgent Ps/1.0 -URI "http://example.com").content |
這兩種方法均可以將響應輸出到stdout。Windows會將輸出的內容都重新編碼為系統默認代碼頁,比如簡體中文系統中會被編碼為CP936。但是我們有時只想獲得原始的內容,而不是便於顯示在屏幕上的內容(比如下載文件或者不便於進行編碼轉換的時候)。
所以我們可以將響應輸出到文件:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
args = WScript.Arguments.Count if args <> 1 then wscript.Quit end if URL = WScript.Arguments.Item(0) Set xmlhttp = CreateObject("Microsoft.XmlHttp") xmlhttp.open "GET", URL, false xmlhttp.setRequestHeader "User-Agent", "cscript/1.0" xmlhttp.send Set oStream = CreateObject("ADODB.Stream") With oStream .Type = 1 'adTypeBinary .Open .Write xmlhttp.responseBody 'to save binary data .SaveToFile "out.txt", 2 'adSaveCreateOverWrite End With Set oStream = Nothing Set ret = Nothing |
或者:
|
1 |
powershell Invoke-WebRequest -UserAgent Ps/1.0 -URI "http://example.com" -Outfile out.txt |
然後我們讀取out.txt就可以獲得響應內容了。
有時候用ngx.shared的時候想看一下到底存進去的值是什麼,或者想列一下滿足條件的鍵,或者想批量操作,所以這個項目就是用來解決這個問題的。
除了支持ngx.shared提供的操作以外,學習Redis增加了PING(測試連通性),KEYS(列出符合條件的鍵)和EVAL(在服務器上執行Lua腳本)。
已上傳到opm,可以通過
opm install fffonion/lua-resty-shdict-server
一鍵安裝。
由於目前stream和http子系統是兩個獨立的Lua VM,因此不能通過全局變量來共享數據。另外兩個子系統的shdict是分別定義的,因此也不能互擼。所以如果想用這個模塊來在redis-cli里擼http子系統下定義的shdict,需要這個補丁。
示例配置:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
http { lua_shared_dict dog 10m; } stream { lua_shared_dict dog 10m; server { listen 6380; require "resty.core.shdict" require "resty.shdict.redis-commands" local srv = require("resty.shdict.server") local s = srv:new("a-very-strong-password", "dog") s:serve() } |
然後
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ redis-cli -h 127.0.0.1 -p 6380 127.0.0.1:6380> set doge wow (error) ERR authentication required 127.0.0.1:6380> auth a-very-strong-password OK 127.0.0.1:6380> set doge wow OK 127.0.0.1:6380> get doge wow 127.0.0.1:6380> keys dog* 1) "doge" 127.0.0.1:6380> eval "return shdict.call('del', unpack(shdict.call('keys', ARGV[1])))" 0 dog* OK 127.0.0.1:18002> keys * (empty list or set) |
最近碰到這麼個問題,有這麼個函數,用來將HTML轉義字符變回原來的字符:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
def htmlescape(s): if sys.version_info[0] == 3: # python 3.x unichr = chr def replc(match): dict={'amp':'&','nbsp':' ','quot':'"','lt':'<','gt':'>','copy':'©','reg':'®'} if len(match.groups()) >= 2: if match.group(1) == '#': return unichr(int(match.group(2))) else: return dict.get(match.group(2), '?') htmlre = re.compile("&(#?)(\d{1,5}|\w{1,8}|[a-z]+);") return htmlre.sub(replc, s) |
其中unichr用來將一個整數轉換成Unicode字符,僅在Python2中存在。Python3中,chr可以同時處理ASCII字符和Unicode字符。所以我們在Python3環境中將unichr映射到chr上。
運行這段代碼會在第8行報錯:NameError: free variable ‘unichr’ referenced before assignment in enclosing scope。而且只有Python2會報錯,Python3不會。
首先從問題上看,報錯的原因是在閉包replc里unichr沒有定義。
但是Python2明明是有unichr這個內置函數的,為啥就變成未定義呢?
![]()
在cidr.me中使用這個模塊時,返回了類似這樣的輸出:
Canada, Quebec, Montr�al
![]()
發現有人提過PATCH。於是去喵了一眼源碼,發現有一個文檔里沒有提到的隱藏參數。
可以使用
|
1 |
geoip_city /path/to/geoip_city.dat utf8; |
這樣來啟用utf8。默認是iso-8859-1,或者叫latin-1。
MySQL默認也是latin-1。大概因為是單位元組的,所以大家都愛默認用它;可是除了肉眼可見的字符,別的控制符除了會在終端里用以外並沒有什麼卵用。
還有libzip里默認用的是CP437,是DOS版的單位元組編碼。因為大概只有中文版的windows自帶的壓縮功能會生成GB18030編碼的zip文件,所以還魔改過一個中國特色的libzip。
This patches include work from nzinfo (add mmseg support) and my patch for Hiragana and Katagana support (see this blog post). The changes can be viewed here.
For Sphinx 2.11.1:Github dl.yooooo.us
For Sphinx 2.3.2:Github dl.yooooo.us