網頁

2014年5月27日 星期二

SQL學習筆記-資料中單引號問題

一個蠻白痴的問題,若要做insert,而你的資料中正好又有單引號('),如:'123'456這時要怎寫?

insert into table_name (val1,val2) values ('''123''456','789');

還真是有夠怪的寫法,要記錄一下

2014年5月14日 星期三

WordPress開發筆記-如何得知目前在Admin的哪個頁面

有時在自訂post type的管理時,需要知道目前正在哪個管理頁面,針對那個頁面做特別處理,之前都是去看post type的值,後來發現其實用get_current_screen比較準確,他的id值就可以知道目前在管理列表或在編輯post,如:

post type為abc
在管理列表頁時,get_current_screenid=edit-abc
在編輯post時,get_current_screenid=abc

若是編輯使用者時,則為
在管理列表頁時,get_current_screenid=users
在編輯post時,get_current_screenid=user-edit

另外,也可以用$pagenow,不過在post type上就不像screen那麼明確,同上例的結果如下
post type為abc
在管理列表頁時,$pagenow=edit.php
在編輯post時,$pagenow=post.php

若是編輯使用者時,則為
在管理列表頁時,$pagenow=users.php
在編輯post時,$pagenow=user-edit.php

2014年5月9日 星期五

CentOS筆記-Postfix fail: connect to aspmx2.googlemail.com[2607:f8b0:4001:c03::1b]:25: Network is unreachable

出現底下的問題:
connect to aspmx2.googlemail.com[2607:f8b0:4001:c03::1b]:25: Network is unreachable

Google了一下看到這篇[SOLVED] Postfix Connection failure (outbound)?,看起來是CentOS 6才有問題,修改了vim /etc/postfix/main.cf裡頭的資訊

vim /etc/postfix/main.cf
inet_interfaces = all //原設定為localhost
inet_protocols = ipv4 //原設定為all

重新啟動即可
/sbin/service postfix restart

參考網址:
[SOLVED] Postfix Connection failure (outbound)?

2014年4月24日 星期四

Mac學習筆記-MySQL on Mac啟動Log file

在Mac中裝好MySQL後,想說寫程式時能看到正在執行的sql,不過我用的是mac的dmg檔直接安裝,看起來跟一般Linux設定不同,做法如下:

Step1. 新增~/.my.cnf

touch ~/.my.cnf
vim ~/.my.cnf

Step2. 加入底下的內容

general_log_file = /tmp/mysql.log
general_log = 1

Step3. 重啟MySQL

/usr/local/mysql/support-files/mysql.server restart

參考網址:
How and When To Enable MySQL Logs
MySQL 設定 記錄執行過的 SQL 語法

一份不錯的socket program的文件

一份不錯的socket program的文件“Beej's Guide to Network Programming”,在這邊做個紀錄

中文網站:Beej's Guide to Network Programming 正體中文版
PDF: https://drive.google.com/file/d/0Bw4lG0-ie2P6UGw4OXdlOE9scTg/edit?usp=sharing