[MySQL] 必要修正一些預設值 (performance tunning)
Posted on November 20, 2009
| 1 minutes
| 86 words
| appleboy
參考了一篇:『Fixing Poor MySQL Default Configuration Values』,裡面提到了四個 MySQL 預設值相當沒有意義,所以 Jeremy Zawodny 提出了修改,也解釋了為什麼這四個會降低 MySQL 的效能。 1. max_connect_errors: 當使用者連接 MySQL 出現錯誤,伺服器就會根據 connect_timeout 所設定時間之後,而放棄等待,放棄之後會有 counter 來紀錄連接失敗的次數,當達到 max_connect_errors 設定值,伺服器就會 locked out client 端,這會衍生一個問題,那就是可以惡搞同一台網站,把 MySQL 搞爛,造成封鎖,不過解決方法就是把 max_connect_errors 設定成 (max_connect_errors=1844674407370954751) 2. connect_timeout: 這跟上面 max_connect_errors 是有相當大的關係,MySQL 預設 connect_timeout 是五秒,可是在網路繁忙的時候,也許需要花費比較多的時間來做連接, 但是預設值是五秒的話,這樣會一直 time out,造成 counter 持續增加,屆時會超過 max_connect_errors 設定值,所以必須把 connect_timeout 設定提高到 15 or 20,這樣就可以了 (connect_timeout = 20) 3. skip-name-resolve: 在每次的 MySQL 連線,伺服器端會偵測 Client 的 DNS 反解,這步驟真的有點多餘 綜合上面結論,請加入 my.cnf 一些設定
max_connect_errors = 1844674407370954751
connect_timeout = 20
skip-name-resolve
slave_net_timeout = 30
Reference:
無論如何都應該修改的 MySQL 預設值 線上環境的 MySQL 預設值修改(Jeremy 建議)
[FreeBSD] port committer 快速建立 pkg-plist
Posted on November 18, 2009
| 2 minutes
| 319 words
| appleboy
在 FreeBSD 系統裡,最常使用就是管理安裝 ports,之前寫過一篇如何 commit update ports :『[FreeBSD] send-pr porter committer 需要注意事項』,根據 FreeBSD Porter’s Handbook 裡頭,寫到 pkg-plist 檔案內容是根據 ports 所產生的檔案列表,可以參考 Automated package list creation 這篇來快速產生,而我自己把該篇寫成 shell script 來直接產生,再來利用 diff 的方式來看看有無需要修改或者是增加,底下就是 shell script 內容:
#!/usr/local/bin/bash
###############################################
#
# Date: 2009.11.18
# Author: appleboy ( appleboy.tw AT gmail.com)
# Web: http://blog.wu-boy.com
# Ref: http://www.freebsd.org/doc/en/books/porters-handbook/plist-autoplist.html
#
###############################################
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
export PATH
if [ "$#" -lt "2" ]; then
echo "please give two argument"
echo "
[Read More][Gmail] offline Gmail 根據 Labels 自訂選擇下載郵件備份
Posted on November 17, 2009
| 1 minutes
| 38 words
| appleboy
在 Gmail Lab 裡面講到這篇:『Choose which messages get downloaded for offline use』,內容是說之前 Gmail 開發出來可以離線瀏覽 Email 信件的 Offline Gmail 功能,不管你在任何地方您都可以任意去瀏覽之前收過的 mail 郵件,我想這功能相當方便,但是如果您的信件如果很多,有些不想同步到自己私人電腦,是不是覺得有些不方便,而想根據 Gmail 設定的 Label 來同步郵件呢,所以 Gmail 幫您考慮到的此點,也針對 Offline 做了設定改善。首先你必須先啟動 Offline Gmail 的功能,接下來在 Settings 的 Offline tab 裡面進行設定您想要下載同步的 Labels 郵件,畫面大致上如下,我想非常容易設定。 
[Linux] VirtuBox ssh 遠端控制,Windows 資料夾分享 [On Ubuntu]
Posted on November 15, 2009
| 1 minutes
| 189 words
| appleboy
VirtualBox 是一套可以模擬虛擬作業系統的軟體,目前 Release 到 3.0.10 版本,可以去官網查看 Changelog,它可以 run 在各種不同的作業系統,例如:Windows, Linux, Macintosh and OpenSolaris etc. 可以看 guest operating systems,每次只要新的 OS Release 出來,就要先用 VirtualBox 模擬一下,還有如果需要 IE6,也是需要另一套 Windows XP,在教學方面也是相當方便的,底下紀錄一下如何 pietty 去連接 VirtuBox 裡面的 Ubuntu Server。
[Read More][SQL] Microsoft SQL Server 2008 Management Studio 防止儲存需要資料表重建的變更
Posted on November 11, 2009
| 1 minutes
| 32 words
| appleboy
最近要寫 ASP.Net 專案,弄 MSSQL Server 2008 當作 Database,利用 SQL 2008 SQL Server Management Studio 管理資料庫,有點類似 MySQL Navicat Lite 軟體,或者是 Web 介面的 phpMyAdmin,在資料表填入欄位新增第一次之後,接下來要去修改資料表,發現會出現錯誤訊息:『防止儲存需要資料表重建的變更』
解決方法其實很簡單:工具->選項->左邊選單 Designers,裡面把**防止儲存需要資料表重建的變更**,取消掉,就可以了
參考資料:[SQL]使用SQL 2008 SQL Server Management Studio 更改資料表結構 出現錯誤訊息不允許儲存變更
[網站] 好站連結 (六)
Posted on November 5, 2009
| 1 minutes
| 195 words
| appleboy
C#
C# DataGridView Tips and Secrets
[C#]WinForm解決ComboBox在下拉選單Width的AutoSize{#viewpost_ascx_TitleUrl} javascript
Use jQuery’s select() function to automatically select text in an input field
How to get and set form element values with jQuery
How to check and uncheck a checkbox with jQuery
jQuery Animated Information Box
jQuery Facebox dialog with opaque background
Save Web Form Content Using Control + S
Javascript Copy to Clipboard
Dynamically Create Charts Using MooTools MilkChart and Google Analytics
[Read More][Perl&PHP] time() and Class::Date 日期轉換運算
Posted on November 3, 2009
| 2 minutes
| 247 words
| appleboy
為了看個 MLB 美國職棒,寫了一個網站:美國職棒影片收集站,裡面的內容影片連結,以及連結說明,都是利用 Perl 搭配 MySQL 資料庫,以及 CodeIgniter PHP Framework 寫出來的,美國 MLB 開打時間,會比台灣晚一天的時差,所以在 PHP 跟 Perl 都要針對時間作修改以及轉換運算,那底下會寫 PHP 跟 Perl 如何控制時間,還有資料庫如何設計,會比較適當。
PHP 日期轉換 MySQL 在資料庫時間格式方面,最主要常見的兩種儲存方式,一種就是 MySQL 預設 datetime,顯示的格式就會像是
2009-11-03 20:10:43,另一種就是存成 UNIX time 格式,可以設定為 int(11),這兩種其實都可以使用,在 phpBB2 是採用後者的方式,因為 open source 要支援多種資料庫,但是又要統一程式碼,所以乾脆用 UNIX 的時間標記,這樣比較好轉換時區,如果使用 UNIX 格式,可以利用 time() 函式來取的。
[Read More][高雄美食] 高雄-TON 卡茲日歐風尚食堂
Posted on October 31, 2009
| 1 minutes
| 29 words
| appleboy
在
mobile01 發現【Catanna食記】高雄-TON 卡茲日歐風尚食堂 這篇文章,之前答應宗翰要請他吃一次飯,原因是我找到了第一份工作,所以凹了我一頓飯,這次也拖了很久,從我畢業到現在都半年超過了,才一起出來吃飯,宗翰也寫了一篇食記:[Food]TON 卡茲日歐風尚食堂 - 高雄,先不多說,來介紹一下美食吧,我跟宗翰還有他高中同學總共一起吃了 693 元(炸豆腐 炸野菇 藍帶雙起士豬排 雙人海陸稱霸餐),吃到我們快撐死了,其實點餐點就會附上白飯跟高麗蔡絲,很大一盤,請看底下的圖:


[Read More][CodeIgniter] 解決 CI 下載函數 force_download 在 IE 底下檔案標題亂碼
Posted on October 26, 2009
| 1 minutes
| 181 words
| appleboy
CodeIgniter 底下提供了 force_download 函數,讓使用者可以直接下載檔案,但是會遇到中文的問題,IE 底下開起來檔名會是亂碼,force_download(‘filename’, ‘data’) 如果 filename 使用中文,測試 FireFox 跟 Chrome 都是沒問題的,唯獨 IE 開起來就是有問題,所以麻煩請修改 helpers/download_helper.php 這隻程式。
if ( ! function_exists('force_download'))
{
function force_download($filename = '', $data = '')
{
if ($filename == '' OR $data == '')
{
return FALSE;
}
// Try to determine if the filename includes a file extension.
// We need it in order to set the MIME type
if (FALSE === strpos($filename, '.'))
{
return FALSE;
}
// Grab the file extension
$x = explode('.
[Read More]WordPress 2.8.5 Hardening Release
Posted on October 22, 2009
| 1 minutes
| 93 words
| appleboy
WordPress 在10月20號發出安全性的更新,大家快把 2.8.4 升級到 2.8.5,可以參考 WordPress 2.8.5: Hardening Release,這次更新最主要是在安全性的議題,Wordpress 團隊在過去幾個月已經開始針對 2.9 進行新功能上的開發,但是在 2.8 branch 的版本如果有安全性的漏洞,官方網站還是會提出修正的,以增加網站的安全。 底下是一些 Release 的安全性改良:
A fix for the Trackback Denial-of-Service attack that is currently being seen. Removal of areas within the code where php code in variables was evaluated. Switched the file upload functionality to be whitelisted for all users including Admins. Retiring of the two importers of Tag data from old plugins 假如您的網站最近有受到攻擊,那可以利用官網提供的弱點掃描工具 WordPress Exploit Scanner 來針對網站檔案以及資料庫內容文章,還有 comment 的資料表,以及所裝的 plugin 檔案進行漏洞檢查。 升級方式很容易,可以參考之前寫的 [wordpress] 快速升級 Upgrade 2.
[Read More]