因為從 plurk 的 getPlurks 接回來的資料被轉成 unicode 了,所以使用以下方法轉回 utf8.echo "\u6c49\u5b57" | \ref: this & this
sed 's/\\u\(..\)\(..\)/\\x\2\\x\1/g' | \
sed 's/.*/\"\\xff\\xfe&\"/g' | \
xargs printf | iconv -f utf-16 -t utf-8
| [+/-] |
convert unicode chartset to utf8 in CLI
poster:
MarlboroMoo on
15:00
tag:
bash,
command-line,
plurk
/
Comments: (0)
|
| [+/-] |
plurk.sh
poster:
MarlboroMoo on
23:22
tag:
bash,
code,
command-line,
plurk,
script,
social network
/
Comments: (2)
|
會寫這隻 script 的原因很簡單, 我想要 karma 達到 100, 然後有一隻自己的 robot, 哇哈哈, 雖然已經有高手們寫出 API 了, 可是我想要重複造輪子, 而且是用 bash script. 這隻 script 的原理很簡單, 用 curl 這個工具來登入 plurk.com 並取得 cookie, 然後 post. 就這樣.
實作功能:
- 噗它
- 噗的時候可以指定動作
- 取得自己的浪
- 取得好友的浪
- 變身成 robot
- ...
- 必須有安裝 curl, ubuntu 直接用 apt-get 來安裝
- 請先修改 script 裡的帳號密碼, 還有 uid(登入 plurk 後, 網頁原始碼裡看得見.)
- 如果無法正常發送, 可以用 -v 的選項來來 debug.
- 目前只能當"偽robot", 使用 crontab 來定時噗.
使用方式:
直接看說明吧.
chmod +x ./plurk.sh
./plurk.sh -h
ref: this
| [+/-] |
mutt plus msmtp in ubuntu 9.04
poster:
MarlboroMoo on
22:17
tag:
command-line,
msmtp,
mutt,
ubuntu
/
Comments: (0)
|
有時候單純需要 CLI 的 MUA 來發送郵件, 如果使用 sendmail 或是 postfix 那就太浪費了.可以使用 mutt 搭配 msmtp(smtp client) 來達成, smtp 伺服器用 gmail. 安裝及設定步驟如下:
- 使用 apt-get 來安裝 mutt & msmtp
- 設定 msmtp, 設定檔放在 ~/.msmtprc
- 修改 ~/.msmtprc 的權限, 不然會出現類似下方的訊息.
- 設定 mutt, 設定檔放在 ~/.muttrc
- 現在可以使用 mutt 來發郵件拉.
sudo apt-get install mutt msmtp
echo '# Smtp account gmail
account gmail
host smtp.gmail.com
from somebody@gmail.com
auth on
user somebosy@gmail.com
password gamilpassword
port 587
# Set default account
account default : gmail' > ~/.msmtprc chmod 600 ~/.msmtprc
msmtp: /home/xxx/.msmtprc: must have no more than user read/write permissions
echo 'set sendmail="/usr/bin/msmtp"
set from="somebody<somebody@gmail.com>"' > ~/.muttrc
echo 'hello' | mutt -s 'hi' somebody@gmail.comref: this, this, this & this
| [+/-] |
Linux cheatsheet
poster:
MarlboroMoo on
22:10
tag:
bash,
cheatsheet,
command-line,
editor,
linux,
resource,
screen,
terminal
/
Comments: (0)
|
不知道是缺乏安全感, 強迫症, 還是檔案松鼠 ;> 只要是關於 linux command 的任何東西, 都想要收集, 嘿嘿, 不過這些 cheatcheet 真的很好用, 對於 linux 的千千萬萬的指令來說, 有時候很容易就失憶, 把這些 cheatsheet 印在一張張的 A4 紙, 釘在 partition 上, 就無敵拉!!!!!
| [+/-] |
postwp-mu.sh |
因為工作的關係, 用 bash 寫了一隻 script 可以從 command line 直接 blogging, 原理是將資料轉換成 xml, 並使用 netcat 將 xml 透過 xml-rpc protocol 塞給伺服器, 不過是這個 script 是給 wordpress 用的.. 如果 blogger 有支援 xm-rpc 的話, 我會生一個 for blogger 的版本, 應該會很黑皮, 嘎嘎嘎 !
實作功能:
- 發佈文章
- 發佈頁面(page)
- 發佈文章 or 頁面可指定分類(Categorie)和標籤(tag)
- 列出文章 or 頁面
- 刪除頁面(page)
- 刪除文章
- ...
- 請先修改 script 裡的帳號密碼.
- 可以先編輯一篇文章, 再將檔案指定給 script.
- wordpress 支援的 html tag 都可以使用, 如 <pre> <code> <blockquote>.
直接使用以下指令來看說明.
chmod +x ./postwp-mu.sh
./postwp-mu.sh -h
ref: this, this and this