flog 意思為 Formatted Log
由此篇文章得到靈感。
http://blog.darkthread.net/blogs/darkthreadtw/archive/2008/12/31/jquery-logging-plugin.aspx
沒有 Firebug 時,會自動忽略此功能。
並導入了 Console.log 的 Format 字串 與 無限參數個數。
外加判斷,若第一個參數為 Format 字串 且 選擇對象為 使用者選擇之目標,則將 Format 字串後加入 ": %o" 以顯示 使用者選擇目標。
原始碼:
/*
* jQuery Formatted Log Plugin v1.0.0 @ 20111223
*
* Print formatted log to console.log with smart object display.
*
* Copyright (c) 2011 Firch Tsai
*
* Licensed under the GPL v2 licenses.
*/
jQuery.flog = jQuery.fn.flog = function(msg) {
if (typeof console != "undefined")
{
var arguments_array = [];
for (var i in arguments)
{
arguments_array[i] = arguments[i];
}
var first_arg = arguments_array.shift();
if(typeof first_arg == "string" && this.selector != $.selector)
{
first_arg += ': %o';
arguments_array.push(this);
}
arguments_array.unshift(first_arg);
var logfn = console.log;
logfn.apply(this, arguments_array);
}
return this;
};
使用範例:
item = "Book";
$.flog("This is a %s !", item);
將輸出:
This is a Book !
使用範例:
tag_name = "Links";
$('a').flog("These %s are Formatted", tag_name );
將輸出:
These Links are Formatted: +[a... , a...]
2011年12月23日 星期五
jQuery Plugin flog - Formatted Log
2011年11月9日 星期三
svn diff 使用 vimdiff
首先寫好 wrapper,明名為 .svndiff_to_vimdiff
#!/bin/sh
# Configure your favorite diff program here.
DIFF="/usr/local/bin/vimdiff"
# Subversion provides the paths we need as the sixth and seventh
# parameters.
LEFT=${6}
RIGHT=${7}
# Call the diff command (change the following line to make sense for
# your merge program).
$DIFF $LEFT $RIGHT
# Return an errorcode of 0 if no differences were detected, 1 if some were.
# Any other errorcode will be treated as fatal.
資料來源:http://blog.tplus1.com/index.php/2007/08/29/how-to-use-vimdiff-as-the-subversion-diff-tool/
接下將 .svndiff_to_vimdiff 放在 ~ 底下
再於 ~/.cshrc 中加入 alias
alias svndiff 'svn diff \!* --diff-cmd ~/.svndiff_to_vimdiff'
從此就可以開心的使用 svndiff 指令取代 svn diff 摟!
example:
# svndiff file_path
# svndiff -r N:M file_path
2011年11月8日 星期二
2011年8月4日 星期四
2011年6月29日 星期三
tmux 解決 not a terminal 問題
直接下指令改目前設定
# sysctl net.inet.udp.maxdgram=65536
# sysctl net.local.stream.sendspace=8192
或者修改 /etc/sysctl.conf 將以上的設定值放進去,以後開機即自動生效。
2011年5月15日 星期日
2011年5月11日 星期三
2011年4月21日 星期四
FreeBSD 以 csup 更新 ports
設定 csup 設定檔
#cp /usr/share/examples/cvsup/ports-supfile /etc
#vim /etc/ports-supfile
將 CHANGE_THIS.FreeBSD.org 改為 FreeBSD.twaren.net
之後開始更新 ports
#csup -g -L 2 /etc/ports-supfile
完成!