網頁

2016年4月26日 星期二

CSS學習筆記-控制斷行

最近遇到一個在<a>中的內容要斷行的需求,印象中以前是不行的,查了下才知道,其實可以針對擺<p>、<div>或<li>下的<a>,對其內容斷行,<p>、<div>或<li>加入word-break: break-all即可,如下設定:


<p style="word-break: break-all;"><a href="http://www.google.com">Google</a><p>

參考網址:
CSS: Line Wrap Tutorial
CSS 語法,文字換行,強迫不換行。

2016年4月24日 星期日

FB Graph API呼叫限制

記錄一下,目前FB中每個應用程式配額為在任何指定的 60 分鐘內,每一用戶有 200 次 API 呼叫。

參考網址:
限制 Graph API 速率

2016年4月14日 星期四

在CentOS 6安裝Requests及openpyxl 2.4 模組(Python 2.6.x)

最近突然想學swift及python,正好想做個小功能來玩玩,因為需要用到網路及Excel的功能,網路功能在python本身是有很多module可用,如下


不過想用方便點的,所以安裝requests模組,官網是Python Module - Requests

#安裝requests ref: http://docs.python-requests.org/en/v1.0.0/community/out-there/ 
$ yum install python-requests
oaded plugins: fastestmirror, replace
Setting up Install Process
Determining fastest mirrors
epel/metalink                                                                | 3.9 kB     00:00
 * base: centos.cs.nctu.edu.tw
 * epel: ftp.cuhk.edu.hk
 * extras: centos.cs.nctu.edu.tw
 * updates: centos.cs.nctu.edu.tw
 * webtatic: sp.repo.webtatic.com
base                                                                         | 3.7 kB     00:00
dag                                                                          | 1.9 kB     00:00
epel                                                                         | 4.3 kB     00:00
epel/primary_db                                                              | 5.9 MB     00:01
extras                                                                       | 3.4 kB     00:00
extras/primary_db                                                            |  37 kB     00:00
kbs-CentOS-Misc                                                              | 1.9 kB     00:00
updates                                                                      | 3.4 kB     00:00
updates/primary_db                                                           | 4.6 MB     00:00
webtatic                                                                     | 3.6 kB     00:00
webtatic/primary_db                                                          | 191 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package python-requests.noarch 0:2.6.0-3.el6 will be installed
--> Processing Dependency: python-urllib3 >= 1.10.2-1 for package: python-requests-2.6.0-3.el6.noarch
............
............
Dependencies Resolved

====================================================================================================
 Package                                  Arch        Version                     Repository   Size
====================================================================================================
Installing:
 python-requests                          noarch      2.6.0-3.el6                 base         95 k
Installing for dependencies:
 python-backports                         x86_64      1.0-5.el6                   base        5.5 k
 python-backports-ssl_match_hostname      noarch      3.4.0.2-4.el6.centos        extras       13 k
 python-chardet                           noarch      2.2.1-1.el6                 base        230 k
 python-six                               noarch      1.9.0-2.el6                 base         28 k
 python-urllib3                           noarch      1.10.2-1.el6                base        101 k

Transaction Summary
====================================================================================================
Install       6 Package(s)

Total download size: 472 k
Installed size: 1.9 M
Is this ok [y/N]: y
............
............
Complete!
這樣就完成了。

Excel的話則是選openpyxl,不過這個套件只支援Excel 2007以後的文件,也要注意版本,如openpyxl 1.x支援Excel 2007,但openpyxl 2.4.0是支援Excel 2010,以及Python至少要2.6以後的版本。

先使用下列指令確認Python版本
$ python -V
Python 2.6.6

下載setuptools(若沒安裝,在安裝openpyxl會出現找不到setuptools套件的訊息)
$ wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
$ tar -xvf setuptools-1.4.2.tar.gz
$ cd setuptools-1.4.2
$ python setup.py install #安裝動作必須是root權限

再來就可以安裝openpyxl 2.4.0
$ wget https://pypi.python.org/packages/source/o/openpyxl/openpyxl-2.4.0-a1.tar.gz
$ tar -xvf openpyxl-2.4.0-a1.tar.gz
$ cd openpyxl-2.4.0-a1
$ python setup.py install #安裝動作必須是root權限

這樣兩個都可以用了

參考網址:
Python Network Programming
Python Module - Requests
openpyxl 2.4.0-a1
How To Set Up Python 2.7.6 and 3.3.3 on CentOS 6.4

2016年3月18日 星期五

WP4.2移機安裝問題:Unknow collation: 'utf8mb4_unicode_ci'

一如往常的想將在電腦弄好的wp網站放上server,放入資料庫資料時卻發現回應如下圖

仔細看了下:Unknow collation: 'utf8mb4_unicode_ci'。覺得很怪,以前都是用utf8_unicode_ci,查了下資料,發現The utf8mb4 Upgrade其中提到

In WordPress 4.2, we’re upgrading tables to utf8mb4, when we can. Your site will only upgrade when the following conditions are met:
  • You’re currently using the utf8 character set.
  • Your MySQL server is version 5.5.3 or higher (including all 10.x versions of MariaDB).
  • Your MySQL client libraries are version 5.5.3 or higher. If you’re using mysqlnd, 5.0.9 or higher.
查了下自己的mysql server版本才5.1.x,看來得自行重新安裝一次了。

2016年3月17日 星期四

MariaDB中發生Cannot load from mysql.proc. The table is probably corrupted

最近改使用JetBrain的DataGrip試試,但一直發生"Cannot load from mysql.proc. The table is probably corrupted",以致於無法載入table,但其他都正常。查了下發現官網也有呈述這類問題,看起來跟mysql的版本有關,只要升級後就可以了,如下圖:

取自:MySQL to MariaDB migration: handling privilege table differences when using mysqldump

所以執行底下指令
$ mysql_upgrade --force -u root -p
Enter password:
MySQL upgrade detected
Phase 1/6: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats                                 OK
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.gtid_slave_pos                               OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
#.......忽略
Phase 6/6: Running 'FLUSH PRIVILEGES'
OK

看到回應OK後再試試就沒問題了

參考網址:
MySQL to MariaDB migration: handling privilege table differences when using mysqldump