2019年2月4日 星期一

BeautifulSoup 中 find_all contents children descendants select 的使用時機

初學者常看到的網路上文件或程式碼通常是這樣取得一個節點

tr.td.ul.li.table.tbody.tr

但是有一行很不起眼的註解出現在文件中:

Using a tag name as an attribute will give you only the first tag by that name:

所以如果你要存取的是同層級的第二個 tr 或 td 呢? 嘿嘿嘿…

2019年1月26日 星期六

java style humor

in fact... just showcasing my new code highlighting ;)

ref. http://ffcc626.blogspot.com/2018/04/blogger-code-highlighting.html & https://github.com/google/code-prettify for further info about the config

import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;

class SortingString {
 public static void main(String args[]){
  System.out.println("Start Time: " + new Date().toString()); //I wonder how long CompileBot goes for

  String s = "typewriter";
  int i = 0;
  int iterationCount = 0;
  for(i = 0; i <= Integer.MAX_VALUE && s != "eeiprrttwy"; i++){
   s = randomSort(s);
   
   if(i == Integer.MAX_VALUE - 1){
    i = 0;
    iterationCount++;
   }
   //if(i % 100000 == 0) //Prevent TOO much console spam... he.
    //System.out.println(s); //Should probably disable this for CompileBot... hehe.
  }
  System.out.println("End Time: " + new Date().toString());
  System.out.println(s);
  System.out.println("Had " + iterationCount + " iterations over Integer.MAX_VALUE, with an ending i of " + i);
 }
 
 public static String randomSort(String x){
  ArrayList chars = convertStringToArraylist(x);
  Random rand = new Random();
  String rtn = "";
  while(rtn.length() < x.length()){
   int pos = rand.nextInt(chars.size());
   rtn += chars.get(pos);
   chars.remove(pos);
  }
  return rtn;
 }

 

2019年1月21日 星期一

git push 時發生以下錯誤的解決方式:fatal: TypeLoadException encountered. 類型 'Atlassian.Bitbucket.Authentication.Authentication' (來自組件 'Bitbucket.Authentication, Version=1.2.0.0, Culture=neutral, PublicKeyToken=null') 中的方法 'DeleteCredentials' 沒有實作。

請到 https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.16.2

下載 GCMW-1.16.2.exe 並執行安裝即可

原始討論串在 https://github.com/git-for-windows/git/issues/1711

(章魚貓表示:喵的怪我囉?)


2019年1月12日 星期六

Mirgrate projects from Heroku to Google Cloud Platform(GCP) 將專案從Heroku轉移到GCP的流程

因為某些機緣發現GCP在台灣的機房使得網站的響應速度超快,雖花了快一天try但還是值得

可以參考一下這個專案說明,大概流程如下:
  1. 首先要有個GCP帳號
  2. 再來準備好信用卡,開通計費。目前有一年300刀的放長線釣大魚送政策
  3. 建立你的專案,記得機房選east-asia-1或east-asia-2
  4. requirements.txt 必需做一些修改,因為GCP似乎不吃 -r 這個參數
  5. 打開雲端命令列環境(GC shell)。這是跟 heroku 最不一樣的地方,他允許你在不安裝任何程式的狀況下作業,乍看會有點不習慣,但這個 shell 跟 ubuntu 操作習慣很一致,在 windows 筆電上作業可說是無縫接軌,而且也與小組形態的 git 工作流程很合拍。可以看看預裝的 gcloud 工具的說明檔
  6. git clone(首次)或git pull你的原始碼。git clone 結束的話要進入以專案為名的那個子目錄
  7. 建立所需的各種資源,如 postgresql 等。各種 proxy 及連線字串的坑請小心XD
  8. "本地測試"。之所以用雙引號的原因是,你其實是可以在自己的實體機器上測試,也可以在剛才的雲端 shell 作測試,後者會附上一個連結讓你開啟,否則你也不知道他的IP在哪XD
  9. 撰寫對應的 app.xml 檔,heroku  中是叫做 Procfile 。這個設計初看沒什麼,但其實這避免了將 app.xml 放到 git 而將帳密等資料外流的危險
  10. 下達發佈指令 gcloud app deploy(這一步超久…)
主要會卡關就是在資料庫各種連線字串的對應,以及測試時必需經過 proxy 這個奇怪的動作。我在猜是想避免有人只裝個 db 然後給別的網站使用之類的。anyway 搬好家後,打開網頁的爽感真是筆墨難以形容,有時甚至比本機測試的速度還快,不誇張。試試又不花錢,花時間而已XD


2018年12月16日 星期日

win10 上安裝 Flask-MongoAlchemy 的 "Subprocess output does not appear to be encoded as cp65001" 解決方法

參考討論串 https://bugs.python.org/issue27179

實際錯誤是發生在安裝 pymongo 時

總之執行 cmd /u 即可



2018年11月16日 星期五

Google新自然語言處理模型--BERT!!屌打微軟亞洲研究院,復旦+流利說團隊、國防科大團隊、阿里巴巴團隊,中國平安旗下金融壹賬通GAMMA LAB,韓國江原大學

BERT 的原始碼已釋出,參 https://github.com/google-research/bert

2小時前團隊剛更新程式碼,表示已經在 Stanford SQuAD 問答集上再推進 3.0%,根本上屌打其它對手


谷哥大神滿佛心的其實,第二、三名其實也是借了谷哥所釋出的 BERT 之力,否則正確來說 BERT 已經屌打非 BERT 技術達到 12% 之多!!

但是文意的理解是否是答題的基礎呢? 打個問號囉~~

2018年11月2日 星期五

"此環境變數太大"的原因和解法

原理詳 https://blog.miniasp.com/post/2015/09/07/Maximum-length-of-PATH-environment-variable.aspx

文中論及解法,感覺上 regedit 可以用用。

使用者環境變數:HKEY_CURRENT_USER\Environment