發表文章

Python | SMTP,明文、TLS、SSL一次完成

近期有利用到 Python 透過 smtplib 發送電子郵件,因此寫了個簡單的 class 方便使用。 import smtplib from os.path import basename from email.mime.text import MIMEText from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.header import Header from email.utils import formatdate import html class SendMail: def __init__(self, send, receiver, subject, body, files): self.mail = MIMEMultipart() self.mail['Date'] = formatdate(localtime=True) # 設定發信時間 self.mail['Subject'] = subject # 設定信件標題 self.mail.attach(MIMEText(html.unescape(body), 'html', 'utf-8')) # HTML解碼 for f in files or []: # 載入附件 with open(f, "rb") as fil: part = MIMEApplication( fil.read(), Name=basename(f) ) # After the file is closed part['Content-Disposition'] = 'attachment; filename="%s"...

Python | 解決 Pandas 套件無法解析文件的編碼

最近在透過 pandas 學習如何匯入 csv 資料到 python 中,但是總是出現 UnicodeDecodeError 的警告視窗,網路上也有解法,我也進行了嘗試。 # 原本是這樣的結構 pd.read_csv(file_csv, parse_dates=True) # 之後後面加入 encode="utf-8" pd.read_csv(file_csv, parse_dates=True, encoding="utf-8") 但是你還是會發現,有時候依然會出現 UnicodeDecodeError 的警告,這個原因在於, Source 的 Encoder 並不是 utf-8,所以你必須把來源資料轉換成 utf-8 ,才不會出現 Encode 錯誤。

Android | SplashScreen 建置

本次目的是為建置在執行主程式前的 Splash Screen ,此效果在許多 App 上都有實踐,其目的有幾種:顯示團隊 LOGO、作為載入資源的前置作業並顯示進度。 此次需要建立三個檔案。 分別是: SplashScreen.java ( 和 MainActivity 同資料夾 ) activity_splash.xml ( 和 activity_main.xml 同資料夾 ) 圖檔 ( 置於 mipmap 註1 ) 需要修改以下檔案內容。 分別是: MainActivity.java ( 避免畫面返回 Splash Screen ) AndroidManifest.xml ( 修改初始啟動畫面 ) 1.建立 activity_splash.xml @mipmap/load 為圖檔 <relativelayout   android:layout_height="match_parent"   android:layout_width="match_parent"   xmlns:android="http://schemas.android.com/apk/res/android"> <imageview     android:id="@+id/imgLogo"     android:layout_centerinparent="true"     android:layout_height="wrap_content"     android:layout_width="wrap_content"     android:scaletype="fitCenter"     android:src="@mipmap/load" /> <textview     android:gravity="center_horizontal"     android:layout_alignparentbottom="true"     and...

jQuery | 利用 Google Spreadsheet 作資料庫

圖片
_/_/_/_/_/_/資料自拉普菲斯轉移_/_/_/_/_/_/最終更新時間 2012/11/12 _/_/_/_/_/_/ 本篇分為兩部分,一是從Google spreadsheet中讀取資料,二是從網頁端向表單發送需建立資料。

JavaScript | Google Visualization 簡化

_/_/_/_/_/_/資料轉移自拉普菲斯_/_/_/_/_/_/最終更新時間 2013/10/27 _/_/_/_/_/_/ 本次利用 Google Visualization 來製作新番表和搜尋,而新番表內容包含了以 AJAX 方式,向 Google 表單送出請求來達成快速增加新番。(成品見左方Website欄位) 當然對於我這個笨蛋來講,若能把整體結構給簡化便可以更好利用,於是我便開始此作業,本次是對 Google Visualization 的單純 JSON 資料進行簡化,原試算表不包含任何圖形或顏色,僅有簡單的資料。 不過在進行簡化,我們首先必須取得 Google Visualization 的 API 載入下面網址的 Script <script type="text/javascript" src='//www.google.com/jsapi?autoload={"modules":[{"name":"visualization","version":"1"}]}'></script> 而以下便減化後的 Google Visualization 的 JavaScript GetDataFromGoogleVisualization(表格Key, 資料表號, 搜尋Key, 開始位置, 顯示數量);

莫耳計算機@APP

圖片
本工作室隆重推出簡潔、乾淨、清楚、不留痕跡,只為提供不喜歡化學或不想算莫耳質量和莫耳數的人一種方便的工具。沒錯就是莫耳計算機! 前往PLAY商店

Genymontion 無法開啟虛擬機@解決

圖片
Unable to start the virtual device. VirtualBox cannot start the virtual device. To find out the cause of the problem, start the virtual device from VirtualBox. For more information, check the log files. Please refer to:  https://www.genymotion.com/#!/support?chapter=collapse-logs#faq 這是我這次遇到的問題,簡單來說,連Genymotion也不知道原因為什麼開不起來。所以我嘗試到處找了幾個方法,逛過 Stack overflow 和一些中文部落格,把所有的可能解決的方法都記錄下來,當作一個經驗或筆記。