2018/04/08

買書同時在 mooink 跟 kindle paperwhite 上閱讀 (進度同步就別想了)

雖然 Kindle 有家庭共享機制,但是不容易買到正體中文書。而在讀墨上面買的書只能在 mooink 閱讀,無法下載轉到 kindle 上閱讀。最終只能在 Kobo 上面買書,檔案下載回來,再經過幾道程序,就能同時在 kindle 和 mooink 上面閱讀。

所需工具:



處理過程:


上 Kobo 買書,購買時可以留意電子書詳細資料裡面的下載選項,如果是 EPUB 3 (Adobe DRM) 就要經過解鎖。

將書籍下載。Adobe DRM 的書籍下載回來是一個描述檔,副檔名是acsm (在 Google 圖書購買的也是這個格式)。

使用 Adobe Digital Editions 打開 *.acsm,就會自動下載該書籍。

執行 Epubor Ultimate,點選 Adobe 頁籤,就可以看到 ADE 管理的書籍清單,依照畫面指示,將書籍拖曳到右邊,看到已解密就完成了。

執行 calibre
-> 點選偏好設定
-> 點選外掛
-> 勾選址顯示使用者已安裝的外掛 
-> 展開檔案類型外掛 
-> 雙擊 DeDRM
-> 點擊 Adobe Digital Editions ebooks

-> 點擊 Import Existing Keyfiles
-> 開啟 user/.Epubor_Keys,選取要匯入的檔案 *.der,然後按下開啟
這時已經匯入所需的DRM金鑰,退回 calibre 主畫面
回到 ADE,在要處理的書籍典籍滑鼠右鍵,點選項目資訊

點擊位置右邊的箭頭(以檔案總管顯示)
從檔案總管將書籍拖曳到 calibre 主畫面,由於 DeDRM 已經匯入相對應的 Key,所以可以開始轉換至所需的格式。要注意的是放進去的書籍是有 DRM 的,無法直接從 mooink 讀取,所以仍然需要從 EPUB 轉 EPUB。

2018/04/02

git 筆記

只是筆記而已,用到才備忘。找工作很重要,從 svn 要再回到 git 還是有點燒腦。

檢查改了哪些檔案
    #git status

恢復各別回未修改前的狀態,其中 filename 可以是 * 來恢復所有檔案,概念就是重新 checkout 檔案
    #git checkout -- <filename>

看看這次改了什麼
    #git diff -- <filename>

本地提交
    #git commit 

單行列出紀錄
    #git log --oneline

顯示 commit 的詳細內容
    #git show commit_id

只顯示本地工作副本的提交紀錄
    #git reflog

增加追蹤檔案
    #git add filename

停止追蹤
    #git update-index --assume-unchanged filename

繼續追蹤
    #git update-index --no-assume-unchanged filename

Merge 其他分支的某個 commit
    #git cherry-pick commit-hash

++++++++++ 分支相關 ++++++++++
列出分支
    本地
    #git branch --list
    遠端
    #git branch --remotes
    全部
    #git branch --all

切換分支
    #git checkout branch

建立分支
    #git branch branch

在 branch_name_father 建立分支 branch_name_son 並直接切過去
    #git checkout -b branch_name_son branch_name_father

將本地分支 push 成遠端分支
    #git push remote_name branch_name

將本地目前分支掛勾到遠端分支
    #git push --set-upstream-to=remote/branch_r branch_l

直接 Checkout 遠端分支到本地分支
    #git checkout -b branch_l remote/branch_r

將分支 branch 併入 master
    #git checkout master
    #git merge branch

如果有衝突 (conflict) 可以使用 mergetool 進行排除
    #git mergetool

設定 mergetool (使用 kdiff3 會有更好的介面)
    #git config merge.tool vimdiff
    #git config merge.conflictstyle diff3
    #git config mergetool.prompt false

刪除已 merge 過的 branch 分支
    #git branch -d branch

捨棄並刪除 branch 分支
    #git branch -D branch

刪除 remote_name 遠端 branch 分支
    #git push --delete remote_name branch

同步遠端分支清單
    #git fetch

++++++++++ 分支相關 ++++++++++

捨棄前一次提交 (限定未 push,發現前次提交還有問題,可以捨棄前一次提交,working tree 仍會保留修改過後的內容,其中 ^ 表示前一版)
    #git reset HEAD^

現有的專案建立新的 git 管理,然後 push 到空的 repository.
    #git init
    #git add .
    #git commit -m "First commit"
    #git remote add remote_name remote_repository_URL
    #git remote -v
    #git push remote_name master

本地建立分支,將分支推到遠端新分支,並建立連結
    #git checkout -b branch_name_son branch_name_father
    #git push remote_name branch_name
    #git push --set-upstream remote_name branch_name

在 sdk 分支進行修改,然後併入分支 develop
    先確保分支 develop 已經乾淨(完成 commit)且同步
        #git status
        #git fetch --all
        #git pull
    切換到分支 sdk
        #git checkout sdk
    修改後 commit 並 push
        #git commit -a -e
        #git push
    切回分支 develop
        #git checkout develop
    合併分支 sdk 的修改 (如果有衝突需要手動修正)
        #git merge sdk
        #git commit -a -e
        #git push

要存取 GitLab 建立的repository 會需要 ssh key 跟 password,所以請記得去設定 password,產生 ssh key 的指令如下:
    #ssh-keygen -t rsa -b 4096 -C "email address"

merge 衝突處理
    #git checkout br2
    #git merge br1
        Auto-merging file
        CONFLICT (content): Merge conflict in index.html
        Automatic merge failed; fix conflicts and then commit the result.
    #git add file
    #git commit -m "conflict fixed"

修復 .gitignore 有列出卻還出現在 modified 清單上的問題
    #git rm --cached filename


++++++++++ Repository 相關 ++++++++++

建立完整的 repository 鏡像
    一個 repository 在運行一段時間之後,可能會有很多分支。遇到需要移植到新的伺服器的狀況時,直接鏡像整個 repository 是比較單純的做法。
    #git clone --mirror src_git_url target_folder
    #cd target_folder
    #git push --mirror dst_git_url


更新 remote url
    #git remote set-url remote_name new_url

    更新後檢查 url 有沒有改成功
    #git remote -v

建立 tag 並推送到 remote
    #git tag -a tag_name -m 'tag_comment'
    #git push remote_name tag_name

++++++++++ 修改剛剛提交而且已經 push 的 message ++++++++++

先修改本地的提交
    #git commit --amend

重新 push 內容
    #git push --force-with-lease remote branch

例如使用 git bracnh --all 顯示為 remotes/origin/develop 的分支, 就執行 git push --force-with-lease origin develop

如果在重新 push 之前就已經 pull 回來, 就需要 hard reset,但是本地端的修改會消失, 執行前最好先透過 git status 找出修改過的內容並且備份
    #git fetch origin
    #git reset --hard remote/branch