2015年4月30日 星期四

FCITX + libgooglepinyin 簡繁轉換錯誤

fcitx + libgooglepinyin,libgooglepinyin 爲簡體輸入法,fcitx 透過 OpenCC 將簡體字轉繁體,會有一些非繁體中文的常用字
 
debian 目前維護的 OpenCC 版本爲 0.4.3-2,OpenCC 目前最新 release 爲 1.0.2
 
社羣 -> 社群
剛纔 -> 剛才
裏 -> 里 (鄰里)
幹 -> 干 (干擾)




References :
 


2015年4月22日 星期三

SQLAlchemy use unicode

engine = create_engine('mysql://root:password@localhost/test?charset=utf8&use_unicode=0')




References :
sqlalchemy中文问题解决方案 - 江湖 - 51CTO技术博客

2015年4月21日 星期二

scrooloose/syntastic flake8 ignore E501

$ vi .vimrc.bundles
Bundle 'scrooloose/syntastic'
let g:syntastic_python_checkers=['flake8']
let g:syntastic_python_flake8_args='--ignore=E501'




References :
vim - Disable pep8 check in syntastic for python files - Stack Overflow
let g:syntastic_python_flake8_args doesn't work · Issue #508 · scrooloose/syntastic

2015年4月18日 星期六

MongoDB 筆記

名詞對應

MySQL / Databases / Tables / Rows / Columns
MangoDB / Databases / Collections / Documents / Fields
Elasticsearch / Indices / Types / Documents / Fields  


使用 Docker 安裝 MongoDB
$ vi fig.yml
mongo:
  image: mongo
  ports:
    - "27017:27017"
  volumes:
    - /home/user/DOCKER_DATA/mongodb:/data/db
$ fig up

基本指令

連線到 MongoDB
$ mongo --host 172.17.0.2 --port 27017 
顯示目前的 database (預設爲 test)
> db;
列出所有 databases
> show dbs;
切換資料庫
> use test;
列出所有 collections;
> show collections;
建立 collection (若不存在,insert 資料時會自動建立)
> db.createCollection("myCollection");
插入一筆資料
> j = { name: "xxx" };
> db.testData.insert(j);
列出所有資料
> db.testData.find();
限制傳回的資料筆數
> db.testData.find().limit(4);
條件搜尋
> db.testData.find({ name: "xxx" });
使用 LIKE %% 條件式
> db.testData.find({ name: /.*x.*/ });

Cheat Sheet
MongoDBSpain-CheatSheet-p1.jpg
Migrating from SQL to MapReduce with MongoDB | QuicklyCode


後續工作
Mongodb的安全性設定:帳戶設定、登入IP設定 | 逐風技術誌

MongoDB 教學 – 如何備份與還原 MongoDB - Soul & Shell Blog



References :
MongoDB 教學 - Linux 安裝 NoSQL MongoDB - Soul & Shell Blog 
How to query mongodb with "like"? - Stack Overflow

2015年4月15日 星期三

MYSQL UPDATE with WHERE SELECT subquery

update foo
set bar = bar - 1
where baz in
(
  select baz from
  (
    select baz
    from foo
    where fooID = '1'
  ) as arbitraryTableName
)
 
 
 
 
References : 
MYSQL update with WHERE SELECT subquery error - Stack Overflow

2015年4月6日 星期一

Error: Cannot find kernel "/usr/lib/xen/boot/hvmloader"

try :
kernel = '/usr/lib/xen-4.1/boot/hvmloader'

2015年4月5日 星期日

reference requirements.txt for the install_requires in setup.py

from pip.req import parse_requirements

# parse_requirements() returns generator of pip.req.InstallRequirement objects
install_reqs = parse_requirements(<requirements_path>)

# reqs is a list of requirement
# e.g. ['django==1.5.1', 'mezzanine==1.4.6']
reqs = [str(ir.req) for ir in install_reqs]

setup(
...
    install_requires=reqs
)

* 若 requirements.txt 裏有網址會有問題




References :
python - How can I reference requirements.txt for the install_requires kwarg in setuptools' setup.py file? - Stack Overflow

2015年4月4日 星期六

ImportError: No module named setuptools

# apt-get install python-setuptools

## for python 3.x
# apt-get install python3-setuptools




References :
Python 3: ImportError "No Module named Setuptools" - Stack Overflow