Disable the File Extension Change Warning in Mac OS X

via OSX Daily

When you try to change a filename extension, the Mac OS will always pop up a warning dialog, which can be very annoying.

First, open the Terminal, located within the /Applications/Utilities/ directory, then copy and paste in the following command:

defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
killall Finder

To reverse the change and get the warning back when you attempt to change file extensions, use the following defaults write command:

defaults write com.apple.finder FXEnableExtensionChangeWarning -bool true

Kill the Finder again for changes to take effect.

[Tip] 在 Google Reader 中加入「傳送至 Google+」的選項

via How To Share Google Reader Stories to Google Plus

右上角小齒輪 → 設定 → 傳送至 → 建立自訂連結

Name: Google+
URL: https://plusone.google.com/_/+1/confirm?hl=en&url=${url}
Icon URL: https://ssl.gstatic.com/s2/oz/images/favicon.ico

儲存後,新功能就被建立了。

順便介紹我非常喜歡的漂亮樣式 Reeder for Chrome
安裝此樣式讓 Google Reader 變得好看典雅。

如果你是 Chrome 瀏覽器,進入頁面後按右欄 Download 即可。

[Tool] igosyncdocs – 本機管理 Google Docs

via igosyncdocs

igosyncdocs 是一款可用於本機管理 Google Docs 文檔的小工具,有英文、繁簡體中文和日文版本,
支援多檔上傳,在線新建、修改、搬移、刪除文檔。

編輯檔案時則會自動打開本機的編輯器,例如你裝的是 MS Office,那麼編輯 Word 就是用該工具。

[PHP-Class] GD2 Imaging – 進階的圖檔效果

via PHP Classes GD2 Imaging – Deskew and apply other advanced image effects

Backup download: HERE

GD2 Imaging 提供簡易的圖檔處理常見功能,
包括去除噪點、色階分離、等比例縮小並填充背景、轉換特定角度等等。
下載包內附各類 example,看了就知如何用。

[Tip] UI Tool Kit – 介面設計工具箱

設計介面,你最好不要錯過的工具箱:UI Tool Kit

或者你是個蘋果手機 App 的開發者,會更需要這款 Fresh iPhone UI Kit

[jQuery] DropKick – 美化 select 選項按鈕

DropKick 讓你的 Select 選項按鈕變得精緻又典雅,通常在 IE7 以上瀏覽器能正確呈現。如果 user 關掉了 JavsScript,它仍會以普通選項的方式展開,無功能不兼容問題。
A custom drop-down jQuery plugin which degrades gracefully. If the user has JavaScript disabled, the drop-down will display normally using regular <select> elements. It works on IE7+.

[Tool] Compare Ninja – 在線製作精美的比較表格

Sometime we need to make a table like this to compare the features of several products.
With Compare Ninja, you may make a beautiful table just in a few minutes.

[Tool] Patternizer – 在線生成條紋CSS代碼

Patternizer 是一款在線生成條紋代碼的工具,
支援 HTML5,介面簡潔,操作方便,反應速度快,最要緊的,生成的不是圖片,而是 CSS 代碼。

[PHP+jQuery] 將文字區域點擊後變成可編輯狀態

Facebook 或現在一些 Web 2.0 網站流行讓文字即點即編輯的功能,
網上有已做好的 jQuery 庫可利用,或是如果你希望更了解其中奧秘,無妨親自動手做一個。

One of the most popular feature of the Web 2.0 sites such as Facebook is making it editable wherever you click. There are plenty of jQuery libraries on the internet. But you may create your own one, since you want to figure out the secret.

想要做成的效果:滑鼠點擊後,文字區域立刻變為可編輯區域,並多出一個送出結果的按鈕。
Now, I’d like to have a text span that will turn to editable once clicked, and a button for sending the data will appear.

HTML 的部分分為三塊去寫:
Remember to design your title span, text input area, and edit button.

1
2
3
<span class="titleTxt" id="title_<?php echo $sn?>" title="<?php echo $title?>"><?php echo $ttitle?></span>
<input type="text" size="40" id="toTitle_<?php echo $sn?>" value="<?php echo $title?>" style="display:none;" />
<input type="button" class="editBtn" id="editBtn_<?php echo $sn?>" style="display:none;" value="修改" />

$sn 是序列號,$title 是標題文字。
未點擊 titleTxt 的 span 區域時,把 toTitle_? 和 editBtn_? 兩個元素隱藏起來。

$sn is serail number, and $title means title.
Hide your editable area and button when it has not been clicked.

然後在 jQuery 語法寫入:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$(".titleTxt").click(function(){
var this_ID=$(this).attr("id");
var idValue=this_ID.split('_');
var this_SN=idValue[1];
var this_toTitle="#toTitle_"+this_SN;
var this_BTN="#editBtn_"+this_SN;
$(this).empty(); //將 span 內清空,或是也可以用 hide()
$(this_toTitle).css('display',''); //顯示可編輯區域
$(this_BTN).css('display',''); //顯示按鈕
});

$(".editBtn").click(function(){
var this_ID=$(this).attr("id");
var idValue=this_ID.split('_');
var this_SN=idValue[1];
var input_toTitle="#toTitle_"+this_SN;
var this_toTitle=$(input_toTitle).val();
var this_BTN="#editBtn_"+this_SN;
var show_ID="#title_"+this_SN;
$.ajax({
type:"POST",
url: "ajax/comic_chapter_edit.php",
data: "title="+this_toTitle+"&amp;sn="+this_SN,
success: function(response){
$(show_ID).empty().html(response); //把所得結果填入 span 內
$(input_toTitle).css('display','none'); //隱藏可編輯區域
$(this_BTN).css('display','none'); //隱藏按鈕
}
});
});

前端的部分這樣做就大功告成,最後記得將編輯標題的 php 程式寫入 ajax/comic_chapter_edit.php
並要 echo 出修改後的 title,以便前端順利接收到 response。

You should continue to write the php file "ajax/comic_chapter_edit.php", complete the programming.
Remember to echo the changed title in php, in order to send the response to the front end.

[Tool] FLV Extract – 輕鬆提取 FLV 檔案影音

via Moitah.net
Backup Download Link: HERE

FLV Extract 能夠把 flv 檔案中的影音個別分離出來,有時從網路上下載的影片只想保存音樂的話,
這個小工具特別有用。操作簡捷便利,只需把檔案拖拉進視窗即可。

[PHP-Class] 快速獲取簡易表單的值

via Capturing data in a simplified form post
Backup Download Link: Here

PHP 中要獲取表單的值通常用 $_POST['fieldname'] 來做,
Capturing data in a simplified form post 這個 Class 可以讓寫法稍微簡單一些。
用法:把 method.class.php 引入到處理程式的 php 檔案中,新建類。
例如你的 html form 如果是

1
2
3
<form action="captura.php" method="post">
NAME: <input type="text" name="name" id="name" /><br />
SURNAME: <input type="text" name="surname" id="surname" /><br />

那麼你在 captura.php 裡這樣寫

1
2
3
4
5
6
7
8
9
10
11
12
require_once("method.class.php");
$Post=new UnicPost($_POST);

$Post->Empty = 'name;surname';

if($Post->CheckEmpty()){
$Post->DefineName();

echo name."<br>";
echo surname."<br>";

}

[jQuery] 改變表格中勾選後的欄位底色

做網站時想要達到一個這樣的效果:選中幾筆資料後,改變其底色。

HTML 的代碼部分是這樣

1
2
3
<tr id="tr_<?php echo $sn?>" >
        <td><input type="checkbox" class="ckbox" id="ck_<?php echo $sn?>" value="<?php echo $sn?>" /></td>
</tr>

其中 $sn 是從資料庫撈出來的序列號。

jQuery 程式的設計邏輯:當背景色為 A 時,切換到 B,反之則切換到 A。
這裡需要特別注意的是,Chrome 瀏覽器吃的色碼是 rgb,而 IE 是吃 HEX,
所以在寫條件時要把兩種顏色都寫進去才能正確判斷。

1
2
3
4
5
6
7
8
9
10
11
$(".ckbox").click(function(){
        var this_ckID=$(this).attr("id");
        this_SN=this_ckID.substring(3);
        var this_tID="#tr_"+this_SN; //獲取TR的ID
        var bkc=$(this_tID).css("background-color");
        if(bkc=='rgb(249, 231, 231)' || bkc=='#f9e7e7'){
            $(this_tID).css("background-color","#FFFFFF");
        }else{
            $(this_tID).css("background-color","#F9E7E7");
        }
});

[Tip] Using sessions in Uploadify

之前介紹過的 Uploadify – 一款帶進度條的 jQuery 上傳套件,在使用時遇到了點小問題 -
在 uploadify.php 文件內無法正常調用 session 參數。查了下資料,需要通過特殊方法解決。

首先在網頁上 $(document).ready(function() { 下的部分寫入:

1
2
3
4
var start = document.cookie.indexOf("PHPSESSID=");
  var end = document.cookie.indexOf(";", start); // First ; after start
  if (end == -1) end = document.cookie.length; // failed indexOf = -1
  var cookie = document.cookie.substring(start+10, end);

然後在 $(‘#someID’).uploadify({ 下多加一個參數設置:

1
'scriptData'     : { 'PHPSESSID': cookie },

最後在 uploadify.php 開頭加上

1
2
session_id($_POST['PHPSESSID']);
session_start();

修改完後 session 能夠正常取用。

[jQuery] thickbox 的 tb_remove() 關閉時自動重整母視窗

via jQuery: Thickbox Hack to refresh parent window on tb_close() event

thickbox.js 有一個應用 tb_remove(),用於關閉打開的小視窗
如果你在小視窗中送出過資料,可能會需要它在關閉同時 refresh 母視窗
該做法在 thickbox.js 文檔內做一些小改動可實現。

首先在 thickbox 內找到

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function tb_remove() {
//加入代碼的地方
$("#TB_imageOff").unbind("click");
$("#TB_closeWindowButton").unbind("click");
$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
$("#TB_load").remove();
if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
$("body","html").css({height: "auto", width: "auto"});
$("html").css("overflow","");
}
document.onkeydown = "";
document.onkeyup = "";
return false;
}

這裡分為兩個方案走

(1) 根據參數判斷是否在關閉時 refresh 母視窗,則加入代碼

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function tb_remove(closeparentwindow) {
if(closeparentwindow){
parent.location.reload(1);
}
$("#TB_imageOff").unbind("click");
$("#TB_closeWindowButton").unbind("click");
$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
$("#TB_load").remove();
if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
$("body","html").css({height: "auto", width: "auto"});
$("html").css("overflow","");
}
document.onkeydown = "";
document.onkeyup = "";
return false;
}

當 closeparentwindow 為真時,關閉後自動重整。
注意那麼在執行 function 的時候要填入參數,否則失效。

(2) 無論何時都 refresh 母視窗,則省去判斷
要做的是在 function tb_remove() { $("#TB_imageOff").unbind("click"); 之間插入代碼

1
parent.location.reload(1);

將 js 檔保存,修改完成。

[Tip] Windows 下 vim 亂碼的解決方案

我從前幾天開始修練 Vim,這是一個學習曲線極陡峭的文本編輯器,但一旦你掌握了它將受益無窮。

剛開始學,我遇到的第一個問題不是記命令或習慣 mode 的跳躍,而是亂碼問題
希望在 Windows 系統下練 Vim,於是特地去找了中文檔案在 Vim 也能正確顯示的解決方案

原本的 _vimrc 配置如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &amp;diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &amp;diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &amp;sh =~ '\ endfunction

behave mswinset diffexpr=MyDiff() 之間加入以下 code

1
2
3
4
5
6
7
8
9
10
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1
if has("win32")
set fileencoding=chinese
else
set fileencoding=utf-8
endif
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
language messages zh_CN.utf-8

保存,done

[Tool] CLOC – 程式碼行數計算工具

Official Webiste: http://cloc.sourceforge.net/
Backup Download: HERE

拷貝 cloc-1.53.exe 這個檔案到你想要統計的目錄下
進入命令提示字元模式,輸入 cloc-1.53.exe .

將按照不同檔案類型進行分別計算和總計。

[Tool] JpgToPDF 圖片轉電子書格式工具

JPG to PDF Converter is a small utility which can be used to convert one or more jpg/jpeg files into PDF document. It uses reports.net opensource PDF component to do the conversion.

Features of JPG to PDF Converter :

PDF to JPG conversion
Automatic Image scaling to fit the PDF page
Standalone executable

JpgToPDF 是一款小巧易用的 JPEG to PDF 轉檔工具,綠色免安裝,一鍵達成目的。

需要特別注意的是它的順序,如果你要一次批次選定,後選定的文件會排在前面。

[HTML] Mastering the HTML5 <audio> tag

html5 標準下 audio 標籤的用法
從這篇文章你可學會

1. using a tag audio to insert a sound file on your website
2. play sound in loop
3. display browser controls
4. multiple file formats
5. specify MIME types
6. fallback for old browsers
7. buffer files
8. control HTML5 audio with javascript

via http://www.catswhocode.com/blog/mastering-the-html5-audio-property

[Tip] Upgrading GoDaddy Hosting to PHP 5.x

剛準備安裝新的 wordpress 時竟發現 PHP 版本過低
一檢查 server detail,看到 PHP 版本為 4.3
因為我的 GoDaddy 是比較久以前買的一直續購到現在所以也沒有升級過
好在網上找得到升級方法 (GoDaddy 開設的 Unix server 允許自由 install software,滿方便)

I found the PHP version too old when I install a new wordpress application on my server. The PHP version was 4.3, ’cause it was a long time since I bought this host service from GoDaddy and haven’t updated yet. Fortunately, there is an updating solution. The Unix server provided by Godaddy allows users to install essential software as they have needs.

升級方法是在 server 的根目錄下新建一個 .htaccess 檔案,在裡面寫入
create (if not exsits) a .htaccess file in the root folder of your website server

AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4

保存,完工。
save it, done.

More details at http://help.godaddy.com/article/1082

[PHP] Call to undefined function curl_init 解決方法

1. 打開php.ini,找到extension=php_curl.dll,然後去掉前面的「;」註釋 重啟apache
2. 檢查php.ini的extension_dir值是哪個目錄,在那個目錄下檢查有無 php_curl.dll
沒有的話就去下載 php_curl.dll
再把php目錄中的libeay32.dll,ssleay32.dll拷到c:\windows\system32里面,重啟apache

Login