2012年12月24日 星期一

Openfire 開發

下載 src 的
不用裝 Tomcat,要裝Apache ant,用ant在 cmd下的
D:\openfire_src\build >  ant(需設定path、環境變數,不需安裝,即可直接執行)
去build 程式,因為openfire 是抓jar檔


用 D:\openfire_src\target\openfire\bin\openfire.bat 啟動服務

JSP

jdk和jre有什么区别?
http://zhidao.baidu.com/question/55791862
總結:開發者安裝 jdk,安裝jdk7.0後能在命令提示字元打java後有指令反應

怎样查JDK安装在哪儿的
http://zhidao.baidu.com/question/323673737.html?fr=fd

JSP开发必备:环境配置图文详解
http://tech.it168.com/a2011/0613/1203/000001203275_all.shtml
安裝Tomcat 選 "32-bit/64-bit Windows Service Installer"

裝好後Tomcat 後台 http://localhost:8080 點manager webapp
設定後台帳號密碼:
修改 C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\tomcat-users.xml
要把他的存取權限打開,確認有修改到後重新啟動Tomcat才能登入
<tomcat-users>

  <role rolename="manager-gui"/>
  <user username="tomcat" password="s3cret" roles="manager-gui"/>
</tomcat-users>
更多的Tomcat
http://amos-tsai.blogspot.tw/2010/04/javatomcat.html

2012年12月22日 星期六

win7 安裝openfire + jwchat 與 Spark通訊

先安裝 openfire,windows直接安裝.exe檔
http://blog.csdn.net/simonhe1973/article/details/3789091

安裝jwchat (直接解壓縮即可)
http://blog.csdn.net/simonhe1973/article/details/3790114
使用VM 的rename改檔名

rename ".js.zh_CN" ".js" *.js.zh_CN
rename ".html.zh_CN" ".html" *.html.zh_CN
或用 sublime 的列模式 把ls出來的檔案改成
mv xxx.js.js xxx.js


httpd.conf 底下直接新增

AddDefaultCharset UTF-8
Options +MultiViews
RewriteEngine On
ProxyPass /http-bind/ http://10.10.4.41(我的ip):7070/http-bind/


在OpemFire的管理控制台增加两个服务器属性:
xmpp.httpbind.client.requests.polling = 0
xmpp.httpbind.client.requests.wait = 10


http://www.blogjava.net/hoojo/archive/2012/05/17/378444.html

7、 如果登录出现Authorization failed验证失败,那么有以下几种可能的情况:

A、 用户没有注册 (可去後台看有無帳號)

B、 openfire的证书(C:\Program Files\openfire\resources\security)没有安装到相应的jdk的C:\Program Files\Java\jre6\lib\security目录下

如果出现这种异常信息:javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed也表明是安全证书的问题;

关于解决ssl验证,网上有人说在jsjac.js中的if(this.has_sasl) 这行前面加上this.has_sasl = false;来取消ssl安全证书的验证。 (重開電腦後才行)

C、 如果你的工程名称不是jwchat,建议把它修改成jwchat并且修改config.xml的相关链接的配置(httpbase)

D、 还有可能是你当前的用户没有注册,这个时候你可以注册一个用户或是在openfire控制台的用户组中添加一个用户,然后再等了看看是否存在这个问题。

openfire啟動時出現error:
http://community.igniterealtime.org/thread/43575
You can set it to "Run As Administrator" by default or right click and Run as administrator manually...







2012年11月22日 星期四

javascript 操作cookie

JavaScript bookmarklet to delete all cookies within a given domain
http://stackoverflow.com/questions/178263/javascript-bookmarklet-to-delete-all-cookies-within-a-given-domain
Clearing all cookies with JavaScript
http://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript

function deleteAllCookies() {
    var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++) {
     var cookie = cookies[i];
     var eqPos = cookie.indexOf("=");
     var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
     document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
}


Get URL parameter with jQuery (用純js取get值)
http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery
function getURLParameter(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
}
JavaScript删除登录用户的所有的cookie信息的 (採用)
http://www.ityoudao.com/Web/Html_JS_646_1190.html
AJAX動態內容支援回上頁-HTML5篇
http://blog.darkthread.net/post-2011-09-23-ajax-history-in-html5.aspx
使用History ,但IE8,7,6不支援,所以ivan另裝套件讓ie支援History

2012年11月16日 星期五

vim 常見問題

vim 分割視窗
http://stackoverflow.com/questions/53664/how-to-effectively-work-with-multiple-files-in-vim
:tabe filename
gt, gT  切換左右

josh:
http://superuser.com/questions/486532/how-to-open-files-in-vertically-horizontal-split-windows-in-vim-from-the-command


While running vim:
  1. :sp filename (horizontal)
  2. :vsp filename (vertical)



Ctrl-W s for horizontal splitting
Ctrl-W v for vertical splitting
Ctrl-w q to close one


^w fallowed by capital H,J,K or L will move the current window to the far left,bottom,top orright respectively like normal cursor navigation. The lower case equivalents move focus instead of moving the window.

^w  h, j, k, l 或 鍵盤右邊的上下左右 移動至相對應的分割

強制把檔案變成html highlight高亮
:set syntax=html

問:如何快速切換叫function的地方和function的內容
Chase:用m(mark)+ a 設定標記,再使用'(apostrophe)+a or `(grave or backticks ( http://stackoverflow.com/questions/5052079/move-cursor-to-its-last-position ) )+a  叫回來
問:不同的檔案能否互叫mark =>測試結果: 不行
問:'(apostrophe)+數字(左上角1,2,3,4...)有用嗎? => 測試結果如下
http://vim.wikia.com/wiki/Using_marks
`0 - jump to position in last file edited (when exited Vim)
`1 - like `0 but the previous file (also `2 etc)
或到~/.viminfo 的 # File marks: 看 0~9分別是哪些檔案
ps. /\cjumplist =>\c 可以忽略大小寫搜尋,之前都 :set ic 再搜尋

標點符號的英文念法
http://www.wretch.cc/blog/MayDog/20400547

顯示當下編輯的檔案名稱
http://vim.wikia.com/wiki/Get_the_name_of_the_current_file
:echo @% def/my.txt directory/name of file
:echo expand('%:t') my.txt name of file ('tail')
:echo expand('%:p') /abc/def/my.txt full path
:echo expand('%:p:h') /abc/def directory containing file ('head')

用vim比较文件(Using vim to compare files)
http://bbs.ednchina.com/BLOG_ARTICLE_222557.HTM
1. 使用vim的比较模式打开两个文件:
   vim -d file1 file2

   vimdiff file1 file2

2. 如果已经打开了文件file1,再打开另一个文件file2进行比较:
   :vert diffsplit file2
如果没有用vert命令,diffsplit则会分上下两个窗口。

3. 如果已经用split方式打开了两个文件file1,file2,又想比较两文件的不同。
   分别在两个窗口里面输入命令:
   :diffthis

4. 如果更改了某个窗口的内容,vim又没有自动更新diff检查,可以使用如下命令更新:
   :diffupdate

5. 定位到不同点:
   [c     跳到前一个不同点
   ]c     跳到后一个不同点

6. 在窗口间跳转:
   ctrl-w w    跳到下一个窗口
   ctrl-w h    跳到左侧窗口
   ctrl-w l    跳到右侧窗口
   ctrl-w j    跳到下方的窗口
   ctrl-w k    跳到上方的窗口

7. 合并文档:
   dp          将差异点的当前文档内容应用到另一文档(diff put)
   do          将差异点的另一文档的内容拷贝到当前文档(diff get)

8. 上下文的展开和查看
    比较和合并文件的时候经常需要结合上下文来确定最终要采取的操作。Vimdiff 缺省是会把不同之处上下各 6 行的文本都显示出来以供参考。其他的相同的文本行被自动折叠。如果希望修改缺省的上下文行数为3行,可以这样设置:
    :set diffopt=context:3

可以用简单的折叠命令来临时展开被折叠的相同的文本行:

    zo          (folding open, z这个字母看上去比较像折叠的纸)

然后可以用下列命令来重新折叠:

    zc          (folding close)

一次用tabe開很多檔案
$ vim -p *.html

vim insert模式時回車鍵(Backspace)無法使用
這是重裝cygwin後產生的問題
http://stackoverflow.com/questions/11560201/backspace-key-not-working-in-vim-vi
解法:
在.vimrc中新增
set backspace=2

設定文件為log格式
:setf dosini

自動把*.log檔案視為dosini格式,編輯.vimrc:
:autocmd BufRead,BufNewFile *.log setf dosini
ps. au = autocmd




2012年11月13日 星期二

20121113 一些設定

outlook 規則分類
skype, msn 字型調 16pt - Consolas

http://werdna1222coldcodes.blogspot.tw/2012/09/programming-fonts.html

使用 Consolas 讓字體同寬 更可分辨 0, O  和 I, l

microsoft exchange 可以回收信件,讓還沒看到信的人回收郵件(例如打錯字重發)

回收郵件步驟:
打開寄件備份->打開郵件->移動->動作(規則下面)->回收此郵件

Linux的shell中"2>&1"含義

http://digdeeply.org/archives/05162025.html

在shell中,每个进程都和三个系统文件相关联:标准输入stdin,标准输出stdout和标准错误stderr,三个系统文件的文件描述符分别为0,1和2。所以这里2>&1的意思就是将标准错误也输出到标准输出当中。




2012年10月24日 星期三

ci session 在chrome, IE的bug

解法:
http://stackoverflow.com/questions/5783595/codeigniter-session-cookie-domain
http://stackoverflow.com/questions/4268823/codeigniter-cookies-working-in-ff-but-not-chrome-or-ie
http://stackoverflow.com/questions/10131824/codeigniter-session-does-not-work-in-google-chrome
http://codeigniter.com/forums/viewthread/178904/ (採用)

如同上面發言:


Try below code.
IE has a problem with the sess_cookie_name:
$config[‘sess_cookie_name’] = ‘ci_session’;
// change to:$config[‘sess_cookie_name’] = ‘cisession’;
Phil Sturgeon, sets the cookie parameters like below:
$config['cookie_prefix'] = "";$config['cookie_domain'] = ($_SERVER['SERVER_NAME'] == 'localhost' ? '' : preg_replace('/^www\./', '', $_SERVER['SERVER_NAME']));$config['cookie_path'] = BASE_URI;
Phil Sturgeon, also adds this to application/config/constants.php at the bottom.
/*
|--------------------------------------------------------------------------
| Docment root folders
|--------------------------------------------------------------------------
|
| These constants use existing location information to work out web root, etc.
|
*/

// Base URL (keeps this crazy sh*t out of the config.phpif (isset($_SERVER['HTTP_HOST'])){
    $base_url  = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
    $base_url .= '://'. $_SERVER['HTTP_HOST'];
    $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

    // Base URI (It's different to base URL!)
    $base_uri = parse_url($base_url, PHP_URL_PATH);

    if (substr($base_uri, 0, 1) != '/')
    {
        $base_uri = '/'.$base_uri;
    }

    if (substr($base_uri, -1, 1) != '/')
    {
        $base_uri .= '/';
    }
}
else{
    $base_url = 'http://localhost/';
    $base_uri = '/';}
// Define these values to be used later ondefine('BASE_URL', $base_url);define('BASE_URI', $base_uri);define('APPPATH_URI', BASE_URI.APPPATH);
// We dont need these variables any moreunset($base_uri, $base_url);
Config.php base_url
$config['base_url'] = BASE_URL;


最後修改這,才成功:

I have Just Changed on line of code and its working perfectly.
change

$config['sess_expiration'] = 7200;
to
$config['sess_expiration'] = 86400;




2012年10月6日 星期六

my CI document

使用hook 在pre_system 抓db語系列表,設全域變數將資料帶到routes和my_config.php

autoload.php 加入 my_config, my_config 陣列用 $config命名

在controller不使用全域變數,而使用$this->config->load('my_config'); 方式呼叫

2012年10月4日 星期四

各瀏覽器切換分頁自訂熱鍵

PCMan 使用 alt+z 切左分頁 、 alt+x 切右分頁 、 alt+c 關閉分頁

firefox 使用keyconfig plugin
http://forums.mozillazine.org/viewtopic.php?t=72994  (官方版本無效)
http://briian.com/?p=5653

切換至左分頁
代碼:
gBrowser.mTabContainer.advanceSelectedTab(-1);


切換至右分頁
代碼:
gBrowser.mTabContainer.advanceSelectedTab(1);

關閉目前分頁 - Close current Tab
http://kb.mozillazine.org/Keyconfig_extension:_Firefox
var tab = gBrowser.mCurrentTab; gBrowser.removeTab(tab);
原本的 closetaborwindow(?) 好像失效了

chrome 
使用 Shortcut Manager (相容性較差,例如wiki alt+z 會被網頁熱鍵先吃掉)  

opera 
內建設定可以設
(Arch)
點opera左上角Opera圖示=> 設定=>功能設定(ctrl + F12)=>進階=>快捷鍵=> 鍵盤設定=>點兩下編輯"Opera Standard" => 搜尋"Switch to next page" => 編輯"Platform Windows-Unix-MCE, your hot key"成 "Platform Windows-Unix-MCE, x alt"
這樣ctrl+x就可快速切換成下一個分頁,不用重開opera
切換前一個分頁則搜尋"Switch to prev page" 




Rocky的js考題

stopPropagation, preventDefault 和 return false 的区别
http://www.neoease.com/stoppropagation-and-preventdefault-and-return-false/

[javascript]Apply與Call用法說明
http://www.dotblogs.com.tw/lastsecret/archive/2010/11/30/19826.aspx

JavaScript 中的 prototype 物件是什麼?
http://myluckycolor.wordpress.com/2007/04/14/javascript-中的-prototype-物件是什麼?/

javascript setTimeout 和 setInterval 区别
http://www.cnblogs.com/ruxuan/archive/2006/07/04/442490.html

查奇怪的字

http://www.dezeen.com/2012/10/03/pelt-by-benjamin-hubert-for-de-la-espada/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+dezeen+%28Dezeenfeed%29
這網址標題有亂碼 OBJ  ( 用firefox開 )

使用
http://idaiwan.pixnet.net/blog/post/32503252-%E3%80%90%E7%B7%9A%E4%B8%8A%E5%B7%A5%E5%85%B7%E3%80%91%E5%90%84%E5%9C%8B%E8%AA%9E%E8%A8%80%E7%9A%84%E6%96%87%E5%AD%97%E6%88%96%E5%85%B6%E4%BB%96%E5%AD%97%E5%85%83%E8%88%87-16

查出其Unicode 編碼是 \ufffc

去 http://www.scarfboy.com/coding/unicode-tool?s=U%2Bfffc 查到該字

Type here  打 U+fffc   ( U要大寫 然後打+ )

或是去
http://www.tamasoft.co.jp/en/general-info/unicode.html
可以查到全部unicode

將該段文字存成檔案,使用emeditor 開,點右下角選編碼,可看到16進位碼
http://www.youtube.com/watch?v=j7x3G4JFJ1g




2012年10月3日 星期三

使用Git與Github管理軟體開發專案

http://billy3321.blogspot.tw/2009/02/github-howto.html


windows -

1.安裝與設定git


請先抓取putty-installer安裝,或至少抓取plink.exe
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
接下來抓取msysgit的安裝檔  ( 選 Git-1.7.11-preview20120704.exe - 安裝git bash )
http://code.google.com/p/msysgit/downloads/list

安裝時,選擇使用Plink,並從putty安裝資料夾或plink.exe所在資料夾點選plink。 (不知其用途)


2.設定與上傳ssh key
git使用ssh tunnel來傳遞原始碼,這個加密通道可以避免原始碼的封包被攔截而竊取。
因此要先產生與上傳ssh key到github,方便之後與伺服器之間的通訊。
在安裝好的git選單中選取git-bash,並輸入

$ ssh-keygen -C “username@email.com” -t rsa


Generating public/private rsa key pair.

Enter file in which to save the key (/home/tom/.ssh/id_rsa): <enter>

Enter passphrase (empty for no passphrase): <輸入存取此key之密碼,或直接按下enter使用空密碼>

Enter same passphrase again: <再一次輸入相同密碼>

Your identification has been saved in /home/tom/.ssh/id_rsa.

Your public key has been saved in /home/tom/.ssh/id_rsa.pub.

The key fingerprint is:

50:43:77:c6:97:af:61:82:dc:ea:9b:6b:67:d4:1b:61 tom@volcano


您的public key就存放在id_rsa.pub裡面,而id_rsa則是private key,請妥善保存以免遺失。
這個key是一對的,private key要存放於家目錄下的.ssh資料夾中。public key則複製後,貼上您github帳號中的SSH Public Keys欄位。注意小心不要複製到空格。

將Public key所有內容複製後貼上您github帳戶底下的 SSH Public Keys 欄位,一次貼上一個(注意,這邊貼上的是public key,另外請注意不要有空格。)
github設定public keys : 點右上角account settings圖示 -> 左邊點SSH Keys -> Add SSH key ( 把上面public key貼上去 )


3.設定github帳號並開啟一個repo

4. 第一次git push 時可能會遇到

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'file:///xxxxxxx.git'
這是Git 找不到你要提交的版本了.

解法:
http://blog.csdn.net/viweei/article/details/6163562

$ git push origin master

5. (optional)安裝 Github 介面軟體
https://help.github.com/articles/set-up-git 點 Download GitHub for Windows (家裏電腦不知為何點了沒反應...)

6. 錯誤訊息:

Cloning into 'amp'...
FATAL ERROR: Disconnected: No supported authentication methods available (serve sent: publickey)
fatal: The remote end hung up unexpectedly

重裝git後照 https://help.github.com/articles/generating-ssh-keys 步驟做一次

更多的git安裝配置與錯誤處理: http://wiki.7color.org/git.html


ps. 讓git-bash的git有高亮
Why does git diff on Windows warn that the “terminal is not fully functional”?
http://stackoverflow.com/questions/7949956/why-does-git-diff-on-windows-warn-that-the-terminal-is-not-fully-functional

Can be fixed by adding the following line to ~/.bashrc:
export TERM=msys

Git - how to tell which commit a tag points to
http://stackoverflow.com/questions/1862423/git-how-to-tell-which-commit-a-tag-points-to


Summary: Since there are about 4 almost equally acceptable yet different answers I will summarise all the different ways to skin a tag.
  1. git rev-list $TAG | head -n 1 (thanks mipadi). git rev-list outputs the commits that lead up to the $TAG similar to git log but only showing the SHA1 of the commit. For non-unix heads like myself head -n 1 will show the first line of the output, which is the tip of the tag.
  2. git show-ref --tags (thanks Charles Bailey) will show all tags (local and fetched from remote) and their SHA1s.
  3. git show-ref $TAG(thanks Jakub Narębski) will show the tag and its path along with the SHA1.
  4. git rev-parse $TAG(thanks Jakub Narębski) will show the SHA1 of an unannotated tag.
  5. git rev-parse --verify $TAG^{commit} (thanks Jakub Narębski) will show a SHA1 of both annotated and unannotated tags. On Windows use git rev-parse --verify %TAG%^^^^{commit} (four hats).
  6. cat .git/refs/tags/* or cat .git/packed-refs (thanks The MYYN) depending on whether or not the tag is local or fetched from remote.






2012年9月26日 星期三

[Apache] 在URL中刪除目錄

http://lmgtfy.com/?q=url+rewrite+remove+folder

http://stackoverflow.com/questions/1314279/mod-rewrite-in-expression-engine-removing-directory-in-url

使用下面規則把目錄去掉
  
#RewriteEngine on  #可能需要打開
#RewriteBase /
RewriteCond %{THE_REQUEST} ^GET\ /website/
RewriteRule ^website/(.*) /$1 [L,R=301]
RewriteRule !^website/ website%{REQUEST_URI}

2012年9月22日 星期六

[CodeIgniter] No Input File Specified.

用ci出現 No input file specified. 錯誤:

http://tzangms.com/programming/977/

因為 http://www.codeigniter.org.tw/user_guide/installation/troubleshooting.html
伺服器可能不支援 PATH_INFO 變數

因為把 config.php
$config['index_page'] = 'index.php';
改為
$config['index_page'] = 'index.php?';

使用 helper - url 的 redirect 會有問題,所以讓url-rewrite去解

把 rewrite改掉如下
原本的 rewrite
RewriteRule ^(.*)$ index.php/$1 [L]
改成
RewriteRule ^(.*)$ index.php?/$1 [L]


2012年9月13日 星期四

我的CI模組

1. http://www.codeigniter.org.tw/  下載最新CI
2. https://github.com/Vheissu/Ci-Smarty 下載最新ci-smarty ,直接解壓縮到CI application目錄下
3. http://www.codeigniter.org.tw/user_guide/general/urls.html 設定ci url-rewrite (把index.php 拿掉),
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|robots\.txt|$)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
index.php、images、robots.txt 的全部 HTTP request 都會被當成是 request index.php 檔案。 )
如果目錄是 http://localhost/justin/amp/index.php/smartytest RewriteBase 要設定 /justin/amp/
4. http://rental.zhupiter.com/postshow_178_1_1.html 打開本機 apache - url-rewrite ( 我電腦是 win 7 - appserv )
4-1 先確定自己的 Apache web server 有設定成支援 ReWrite。
   動態載入 ReWrite engine 的設定下會在 httpd.conf 中看到這一行『LoadModule rewrite_module modules/mod_rewrite.so』。4-2 在 DocumentRoot 所屬的 Directory 設定內設定 ReWrite 參數。
RewriteEngine On
4-3 因為我設定 virualhost 所以也要到 D:\AppServ\Apache2.2\conf\extra\httpd-vhosts.conf 修改設定


<VirtualHost *:80>
    DocumentRoot "D:\AppServ\www"
    ServerName localhost      
    <Directory "D:\AppServ\www">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order allow,deny
        Allow from all
    RewriteEngine On
    </Directory>
</VirtualHost>
4-4 設定完 apache 後 去 win 7的 "服務" 重新啟動apache.
4-5 如果主機不支援url-rewrite或url-rewrite有問題且無法設定apache , 啟動CI的Query Strings
http://www.codeigniter.org.tw/user_guide/general/urls.html

CodeIgniter 也有提供這個功能,可以到 application/config.php 檔案中開啟底下的設定:
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
只要把 "enable_query_strings" 設定為 TRUE,這個功能就會啟動。
index.php?c=controller&m=method

設定encryption_key以啟動session功能
$config['encryption_key'] = 'xxx';

5. 在application\libraries\Smarty.php 中設定左分隔符和右分隔符

$this->left_delimiter = '{{';
$this->right_delimiter = '}}';

6. 在 application\config\smarty.php 調整smarty cache
$config['cache_status']         = TRUE;
設為FALSE 讓開發時不使用cache

7. application\config\autoload.php 設定
$autoload['helper'] = array('url'); 
讓前端能直接使用 {{base_url()}} 抓網站網址
$autoload['libraries'] = array('parser','database','session');
自動載入smarty、db、session 功能

8. 在linux主機上要把cache資料夾改權限
ex. $ chmod 777 -R cache

出現錯誤Only variable references should be returned by reference:
A PHP Error was encountered
Severity: Notice
Message: Only variable references should be returned by reference
Filename: core/Common.php
Line Number: 257
https://ellislab.com/forums/viewthread/244510/
解法:

return $_config[0] =& $config;
改成
$_config[0] =& $config;
return $_config[0];

2012年9月4日 星期二

CodeIgniter URL-rewrite

http://www.codeigniter.org.tw/user_guide/general/urls.html
以下是將除了像是 index.php、captcha(資料夾)、images、admin、swf檔(使用.*為任意檔名)、css檔、js檔 的全部 HTTP request 都會被當成是 request index.php 檔案。 ( ex. pond.php => index.php/pond.php )
  
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|captcha|images|admin|.*\.swf|.*\.css|.*\.js|.*\.xml|.*\.jpg|$)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

2012年8月30日 星期四

在安裝了Firebug的Firefox中打開網頁慢的原因

原出處: http://younglab.blog.51cto.com/416652/272905


      Firebug是每個Web開發者必用的調試工具,不過你有沒有發現,當Firebug處於打開狀態的時候,載入網頁變慢了,尤其是DOM結構比較複雜和JavaScript腳本比較多的網頁,有時候甚至會導致Firefox停止回應。不過關閉Firebug以後,一切又正常了。我一直被這個問題困惑著,原以為是Firebug打開時會在Firebug調試器中同步載入網頁數據,導致網頁打開很慢。
      今天終於找到原因了。Rob Campbell在其博客中闡述了FireBug使Firefox變慢的原因。文章地址是:http://antennasoft.net/robcee/2009/12/15/firebug-and-the-jit/文章比較容易理解,我就不翻譯了。

*有時js會與firefox套件衝突,當別人firefox功能正常(或自己chrome正常時->我比較少裝chrome套件)
解法:除了firebug以外的plugin都關掉,目前已知json viewer啟動後在contest上傳時會有bug

前端開發firefox的套件:
靈感:Dean的firefox畫面捷圖

Javascript Deminifier ( 可搭配firebug使用 )
[Firefox] 利用附加模組把最小化的 javascript 還原格式
http://demo.tc/Post/726
如何啟動?
選項->勾選"附加元件列"->在下方的JSD狀態開關ON/OFF ->重新刷頁(ctrl+r)
stackoverflow解法:http://stackoverflow.com/questions/5386826/how-can-i-debug-a-minified-js-in-firebug
**JS Deminifer  啟動後的BUG
<script type="text/javascript" src="global_mapping.js"></script>
如果global_mapping裡面有判斷式有註解這樣亂寫:
if (a) {
    ...
}
// 2009-10-12 10:43:18 / 1978-10-10T10:00:00Z
else if (b) {
    ...
}      
// 10/12/2009 10:12:43            
else {
    return null;

}
JS Deminifier啟動後會有bug
解法:在publish時不要勾選 Turn off javascript minifier,使得js檔壓縮,移除註解

YSlow

Fiddler

Rellik =>
WEB DEVELOPER
http://chrispederick.com/work/web-developer/installed/firefox/12/
DNSSEC Validator
http://www.dnssec-validator.cz/



perl 取現在時間並格式化

use POSIX;
my $now_time = POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime(time())); #now time

perl -e 'print localtime(time())' # 30403201111243540

OR

use Date::Format; print time2str("%Y-%m-%d %H:%M:%S", time());
perl -e 'print time()' # 1356003592

使用指令直接執行perl,
# perl -MPOSIX -e 'print POSIX::strftime( "%A, %B %d, %Y", localtime());' //顯示時間
#perl -MLWP::Simple -e 'getprint "http://www.cs.nthu.edu.tw";' //抓網站資料直接在console顯示

2012年7月19日 星期四

jQuery tools 鬼打牆

今天在寫jquery 套件時,因為我的套件會用到 http://jquerytools.org/download/ 的效果
在抓jquery tools 時不要把jquery 包進去,不然會引入兩個jquery,在套件裡面會有 $ === window.jQuery 為 false的問題

2012年7月9日 星期一

javascript 物件寫法

需產生物件後才能使用物件和其方法。
出錯:
  
var obj = {  //少var 亦會出錯
  a : {
    a : function(){
    
    } ,
    
    b : (function(){
      console.log( obj ); // 出錯
    })()
  },
  b : (function(){
    console.log( obj ); // 出錯
  })()
}
  

正常:
var obj = {}

obj.a = {

  a : '123' ,
  b : '456' ,

  c : function(){
    return this.a + this.b ;
  } ,

  init : function(){

    console.log( this ) ;
  }

}

obj.a.init() ;
出錯:

var obj = {  //少var 亦會出錯
  a : {
      a : function(){
   
      } ,
   
      b : (function(){
   
        console.log( obj )
      })()
  },

  b : (function(){

    console.log( obj ) // 出錯
  })()
}

正常:



var obj = {}

obj.a = {

  a : '123' ,
  b : '456' ,

  c : function(){
    return this.a + this.b ;
  } ,

  init : function(){

    console.log( this ) ;
  }

}

obj.a.init() ;

http://stackoverflow.com/questions/3455405/how-to-remove-a-key-from-a-javascript-object
刪除一個物件的key
delete thisIsObject[key];

2012年7月7日 星期六

union不同資料表不同型態資料到同一欄位

$sql =


(
SELECT new.new_podate AS order_date, new.new_top AS title, new.qq, new.new_add AS read_count, topname2.top2_name AS class_name, topname2.top_no, topname2.top2_no, guest_name AS author
FROM new, topname2
WHERE new.top_no = topname2.top_no
AND new.top2_no = topname2.top2_no
AND ( new.top_no=4 OR ( new.top_no=5 AND new.top2_no =1 ) OR ( new.top_no=8 AND new.top2_no =1 ) )
)
UNION ALL (
SELECT contant_date AS order_date, CONVERT(`detail`, CHAR) AS title, '' AS qq, '' AS read_count, '' AS class_name, top_no, top2_no, name AS author
FROM qanda
WHERE  `top_no` =7 AND top2_no = 1
)
ORDER BY order_date DESC
LIMIT $start, 10

qanda的detail 是text 要轉換成char才能union

2012年7月4日 星期三

absolute position的水平&垂直置中

http://birdegg.wordpress.com/2007/12/06/absolute-position的水平垂直置中/

在一已知 height & width 的 element,這個技巧蠻不錯的,原理是先設定 top: 50%; left: 50%;,設定 element 的寬與高 height: 18em, width: 30em,再利用 negative margin 把 element shift 寬/高的一半 margin-left: -15em; margin-top: -9em
  
vcard {
    border:1px solid #666666;
    height:18em;
    left:50%;
    margin-left:-15em;
    margin-top:-9em;
    position:absolute;
    top:50%;
    width:30em;
}
  

2012年6月19日 星期二

[eclipse] EPIC code assist


http://www.epic-ide.org/guide/ch05s06.php
http://www.epic-ide.org/faq.php


Currently, indirect object invocations are not recognized by code assist. This code block will not work:
$smtp = new Net::SMTP;
$smtp->[no content assist]
This one will work:
$smtp = Net::SMTP->new();
$smtp->[content assist]


似乎要在專案上新增liberary,(perl在本機的路徑)或在本機建專案,自動完成才比較正常

遠端的自動完成還要測試。





 
#!C:\strawberry\perl\bin\perl.exe

print "Content-type: text/html\n\n";

$bear = { "a" => 123, "b" => 456 };

$rocky = [];

$test = Data::Dumper->new([]);
print "aaab:",$test->Dump($bear);

#print "bb:",$rocky->Dumper($bear);

use Data::Dumper;
print Dumper $bear;
 
20130618前幾天 打開EPIC eclipse 發現設定怪怪的
後來發現之前因為要研究JSP灌了eclipse - JAVA EE版本的時候,將工作區設定為
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps
導致雖不同資料夾的EPIC受到影響(template、行號和縮排設定跑掉)
將工作區改回之前的就正常了
EPIC行號設定在 "喜好設定" -> "Perl EPIC" -> "Editor" -> check "Show line number" -> 重啟編輯器
...如圖,我將縮排也改成四格空白

讓AppServ 2.5.9 支援CGI /Perl 運作測試

http://blog.yam.com/bybsm/article/28420158

編輯:C:\AppServ\Apache2.2\conf\httpd.conf

搜尋:ScriptAlias /cgi-bin/ "C:/AppServ/www/cgi-bin/"
改為:ScriptAlias /*/ "C:/AppServ/www/"

搜尋:<Directory "C:/AppServ/www/cgi-bin">
改為:<Directory "C:/AppServ/www">

搜尋:Options None
改為:Options +Indexes +ExecCGI

搜尋:#AddHandler cgi-script .cgi
改為:AddHandler cgi-script .cgi
※就是把 # 刪除

都改完以後就存檔,然後重新運作伺服器,接下來就可以在www的 目錄下直接執行CGI Game

不會有限制說*.cgi、*.pl檔案只限定在cgi-bin底下才能執行的困擾



C:\strawberry>perl --help

Usage: C:\strawberry\perl\bin\perl.exe  (perl路徑)





 
#!C:\strawberry\perl\bin\perl.exe
##
##  printenv -- demo CGI program which just prints its environment
##


print "Content-type: text/html\n\n";
print "*** Please define header of file *.pl or *.cgi with
    #!c:\\perl\\bin\\perl.exe\n\n\n";
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "${var}=\"${val}\"\n";
}


 

[git] 查歷史紀錄 ( git常見問題 )

Unable to diff files in two separate branches in Git
http://stackoverflow.com/questions/916822/unable-to-diff-files-in-two-separate-branches-in-git


git diff branch:UNREADME master:README
git difftool somebranch:UNREADME otherbranch:README  (用vim比較工具查看)

View the change history of a file using Git versioning
http://stackoverflow.com/questions/278192/view-the-change-history-of-a-file-using-git-versioning
git log -p filename ( to let git generate the patches for each log entry )
git show HEAD ( get just the diff for a specific commit )

將所有新增的檔案加入:
$ git add .
http://stackoverflow.com/questions/572549/difference-of-git-add-a-and-git-add

將檔案移除
$ git rm filename

將整個資料夾移除
$ git clean -f -d
http://stackoverflow.com/questions/61212/removing-untracked-files-from-your-git-working-copy

讓某個目錄不再追蹤
$ git rm -r --cached <your directory>
http://stackoverflow.com/questions/1329291/ignoring-an-already-checked-in-directorys-contents

git移除所有刪除的檔案
Removing multiple files from a Git repo that have already been deleted from disk
http://stackoverflow.com/questions/492558/removing-multiple-files-from-a-git-repo-that-have-already-been-deleted-from-disk
http://stackoverflow.com/questions/1402776/how-do-i-commit-all-deleted-files-in-git
$ git add -u
OR
$ git add -A

在本地端還原成某個commitID狀態
$ git reset --soft HEAD^

查哪個紀錄改了什麼檔案
http://stackoverflow.com/questions/2557564/how-do-i-identify-files-directories-that-were-added-or-removed-in-a-git-commit
$ git whatchanged -n 1


http://kevyu.blogspot.tw/2011/10/git-stash.html
使用 $ git stash 暫存現在改的狀態再checkout 其他branch 繼續做其他事

查這個commit是哪個branch
How to list branches that contain a given commit?
http://stackoverflow.com/questions/1419623/how-to-list-branches-that-contain-a-given-commit
$ git branch -a --contains commit_tag

查git commit是否含有該文字
$ git log --all --grep='XXX'
--all 會查所有branch

查專案中檔案是否含有該文字(比直接grep快)
$ git grep -e XXX -e OOO

http://stackoverflow.com/questions/215718/how-do-i-reset-revert-a-specific-file-to-a-specific-revision-using-git
取出某個版本的某個檔案
Assuming the commit you want is abcde:
$ git checkout abcde file/to/restore

20130717
在checkout另個branch時,因為用ctrl+c中斷掉了,使得git reset --hard後留下一堆untracked files
如何刪除這些untracked files和資料夾:
http://stackoverflow.com/questions/61212/removing-untracked-files-from-your-git-working-copy
git clean -f -d to be sure that also directories are gone! you can check with git status if they are really gone.

顯示這個commit有哪些檔案被改過
http://stackoverflow.com/questions/424071/list-all-the-files-for-a-commit-in-git
$ git diff-tree --no-commit-id --name-only -r bd61ad98
$ git show --pretty="format:" --name-only bd61ad98
但無法顯示是新增、修改還是刪除,也無法像git pull時顯示+++-- 的示意符號

只移除某commit的修改(不是把該commit之後的commit改變都移除)
$ git revert commmitId

GIT複製別人本地端的branch
http://www.ptt.cc/bbs/Linux/M.1387124688.A.38A.html
方法1:
    $ git remote add jack ssh://jack.s.ip/home/jack/repo # 使用git remote rm jack 移除jack這個remote
    $ git fetch jack
    $ git checkout -b local_branch jack/local_branch # 在本地開local_branch,內容為jack/local_branch
    若jack和master裡面有同樣名字的branch(ex. dev_branch),在git pull時pull到master(之前加入)的dev_branch
方法2:
    $ git diff master local_branch > local_branch.diff # git diff commitId_old commitId_new
    $ git checkout -b local_branch master
    $ git apply local_branch.diff
    $ git commmit -am "Apply patch from Jack's local_branch" # -am 自動add且commit


復原 'git add .' 在提交(commit)之前
http://stackoverflow.com/questions/348170/undo-git-add-before-commit
$ git reset .
復原某個已經被git add的檔案
$ git reset HEAD <file>

讓git diff 有顏色
http://stackoverflow.com/questions/10998792/how-to-color-the-git-console-in-ubuntu
$ git config --global color.ui auto

git push時需要輸入帳號密碼
Git push requires username and password ( github )
http://stackoverflow.com/questions/6565357/git-push-requires-username-and-password
解:把remote的url設成ssh
$ git remote set-url origin git@github.com:username/repo.git
git remote set-url origin xxx 也是設定fetch網址的方法

查某兩個版本之間改過(新增)了哪些檔案
http://stackoverflow.com/questions/6879501/filter-git-diff-by-type-of-change
$ git diff 8702591419104918304ea46dc02ec65e3a8830a4 0136fef0d24d2fd3f1a8c83633e3cef7e7fdcaab --diff-filter=A

git diff時忽略空白(如用tab和space縮排方式改變不顯示出來)
$ git diff -w

被.gitignore的檔案已經被commit了,如何讓他真的被ignore
http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository
$ git rm -r --cached .
$ git add .
$ git commit -m ".gitignore is now working"
如果是配置文件被git rm --cached,線上更新時該commit會把該文件刪掉

忽略檔案模式(chmod)改變
如果chmod 檔案權限而不改內容,git status仍然會列出差異
http://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes
$ git config core.fileMode false
這樣只改變權限就不會被列出來了

列出所有被刪除過的檔案
http://stackoverflow.com/questions/6017987/is-there-a-way-in-git-to-list-all-deleted-files-in-the-repository
列出log中哪個commit刪除了哪些檔案
$ git log --diff-filter=D --summary

git diff 只列出某檔名的差異
http://stackoverflow.com/questions/8554776/what-option-should-be-used-restrict-the-git-diff-to-a-given-set-of-file-extensio
列出html檔差異
$ git diff -w commit_old commit_new -- *.html
只列出index.html檔差異
$ git diff -w commit_old commit_new -- *index.html

git diff 忽略新增和刪除的檔案
http://stackoverflow.com/questions/6894322/how-to-make-git-diff-and-git-log-ignore-new-and-deleted-files
$ git diff -w commit_old commit_new --diff-filter=M

revert多個commit
http://stackoverflow.com/questions/1463340/revert-multiple-git-commits
假設 log 是 A -> B -> C -> HEAD
要回復到A
$ git revert --no-commit D    # commit由新到舊
$ git revert --no-commit C
$ git commit -m 'revert B and C commit'

git diff 顯示方法名稱而不是class名稱
http://stackoverflow.com/questions/7344577/is-there-a-way-to-ask-git-diff-to-show-the-method-name-instead-of-the-class-name
新增 .gitattributes(放到你家目錄下即可)或 .git/info/attributes 的倉庫中,並加入下面這行
*.php diff=php
( git version >= 1.4 )
1. 將  這行放到 ~/.gitattributes
2. 執行 git config --global core.attributesfile "~/.gitattributes"
如果你想要讓他便全局,將上面那行放到 /etc/gitattributes ( 未測 )
最後git diff 結果就會顯示修改的部份是在哪個function內,而不是在哪個class內

新增空資料夾在git倉庫
http://stackoverflow.com/questions/115983/how-can-i-add-an-empty-directory-to-a-git-repository
因為git存放的是檔案,在.gitignore中寫下
tmp/
忽略整個tmp/資料夾下的檔案同時也忽略了tmp資料夾,但是不想忽略tmp資料夾又想忽略tmp資料夾下檔案,要怎麼做呢?
在每個你要忽略的資料夾下寫下 .gitignore ,內容為
# Ignore everything in this directory
*
# Except this file
!.gitignore
!test/  # 不忽略tmp下的test資料夾,但同時test資料夾下也必須新增同樣的.gitignore檔案
或是使用.gitkeep
https://stackoverflow.com/questions/7229885/what-are-the-differences-between-gitignore-and-gitkeep
.gitkeep 不是git的特性,因為git不能新增空目錄,所以人們通常將.gitkeep放到空目錄使得能將該目錄加到版本庫

修改commit內容
http://stackoverflow.com/questions/179123/edit-an-incorrect-commit-message-in-git
$ git commit --amend
$ git commit --amend -m "New \`commit\` message"
反引號 grave/backticks( ` ) 必須要跳脫
設定git預設編輯器為vim
http://stackoverflow.com/questions/6098742/using-git-commit-a-with-vim
$ git config core.editor "vim"

合併兩個不同repos但code 類似的專案
http://stackoverflow.com/questions/13040958/merge-two-git-repositories-without-breaking-file-history/20974621#20974621
因為code管控,手上的較舊的code (old_project)改動,現在要依功能(如:留言板)分批合併到另一個repos(new_project)上正式的code上面
先在 old_project 上回復到比較舊的版本後開一個branch(guestbook),將留言板功能的commit從master 分批cherry-pick到guestbook分支上,並commit成一個記錄
先將舊的old_project加入新new_project庫的remote上
$ git remote add old_project file:///var/www/html/old_project
fetch
$ git fetch old_project
old_project的guestbook分支在new_project上生成
$ git branch guestbook old_project/guestbook
old_project/guestbook 的留言板功能commit cherry-pick到new_project 的master上
$ git cherry-pick commit_id
這時候已經成功一半了,但仍有少部分檔案會有衝突,在git status的 Unmerged paths中,此時要手動解決,我的方法是:保留舊版本衝突的檔案,然後參考 old_project/guestbook 上留言板功能的git diff分別進去手動加入更動

只將有實際更改(不含空白差異)的檔案做git add
http://stackoverflow.com/questions/3515597/add-only-non-whitespace-changes
$ git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero -

git add untracked 的檔案
http://stackoverflow.com/questions/7446640/adding-only-untracked-files
$ git add -i
第一個詢問選 a ( add untracked )
第二個詢問選* ( 全選 )
地三個詢問選q ( quit )

push 到gerrit的庫失敗
http://stackoverflow.com/questions/16586642/git-unpack-error-on-push-to-gerrit
$ git push origin master
Counting objects: 1, done.
Writing objects: 100% (1/1), 199 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
error: unpack failed: error Missing tree 2d0d7370fe441e2c2439c0e5a523ad55bc5a0731
fatal: Unpack error, check server log
To ssh://bear@gerrit.test.com:29418/project.git
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'ssh://bear@gerrit.test.com:29418/project.git'
解法:
$ git push --no-thin origin master

cherry-pick 後出現both added的檔案
http://stackoverflow.com/questions/9823692/resolving-a-both-added-merge-conflict-in-git
使用原本的檔案
$ git checkout --ours src/MyFile.cs
使用commit-id新的檔案
$ git checkout --theirs src/MyFile.cs

從比較舊的commit id 開始,開一個新的分支
http://stackoverflow.com/questions/18054057/git-checkout-commit-id-is-changing-branch-to-no-branch
$ git checkout -b <new_branch_name> commit_id

僅打包兩個commit id之間更改的檔案
http://stackoverflow.com/questions/4541300/export-only-modified-and-added-files-with-folder-structure-in-git
http://tosbourn.com/using-git-to-create-an-archive-of-changed-files/
http://stackoverflow.com/questions/424071/how-to-list-all-the-files-in-a-commit
假設git log 是這樣 A -> B -> C
列出B,C 一共改了哪些檔案
$ git diff --name-only A C

$ git diff-tree --no-commit-id --name-only -r A C
將B,C 改的檔案打包
$ git archive -o update.zip HEAD $( git diff-tree --no-commit-id --name-only -r A C)

$ git archive -o update.zip C $( git diff-tree --no-commit-id --name-only -r A C) =>如果不是打包最新版的內容的話
或 如果只打包新增(A)和修改(M)的檔案(打包刪除的發生錯誤)
$ git archive -o update.zip HEAD $( git diff-tree --diff-filter=AM --no-commit-id --name-only -r A C)

新建檔案其內容為某版本檔案的內容
https://stackoverflow.com/questions/888414/git-checkout-older-revision-of-a-file-under-a-new-name
$ git show HEAD^:main.cpp > old_main.cpp
ex.
$ git show commit_id:test.php > test2.php

無法開新分支
$ git checkout -b test
fatal: Unable to write new index file
https://stackoverflow.com/questions/16064513/git-fatal-unable-to-write-new-index-file
原因:主機硬碟滿了,刪不必要的檔案

git diff 的tab使用4個空白
https://stackoverflow.com/questions/10581093/setting-tabwidth-to-4-in-git-show-git-diff
$ git config --global core.pager 'less -x1,5'

統計所有開發者某段時間內commit數量
https://stackoverflow.com/questions/9839083/git-number-of-commits-per-author-on-all-branches
$ git shortlog -s -n --all --no-merges --since="10 Feb 2019" --before="01 Sept 2099"

git pull報錯 There are no candidates for merging among the refs that you just fetched.
https://stackoverflow.com/questions/13799108/git-wildcard-refspec-with-no-match-on-remote-when-pulling
$ git pull
There are no candidates for merging among the refs that you just fetched.
Generally this means that you provided a wildcard refspec which had no
matches on the remote end.
原因:硬碟滿了。清硬碟就好

git log -p /path/file 或git show時搜尋忽略大小寫
https://stackoverflow.com/questions/16666009/how-do-i-use-vim-as-git-log-editor
https://serverfault.com/questions/11736/gnu-less-how-can-i-search-while-ignoring-case-sensitivity-without-using-less-i
git log 使用的是 linux 的 less, less 忽略大小寫是 -I -i
所以
$ git config --global core.pager 'less -I'
千萬不要用vim去看,會有亂碼
$ git config --global core.pager 'vim -'

用正則刪除多個分支
https://medium.com/@rajsek/deleting-multiple-branches-in-git-e07be9f5073c
$ git branch | grep "<pattern>" | xargs git branch -D

revert多個commit

https://stackoverflow.com/a/1470452  How to revert multiple git commits?
A -> B -> C -> D -> HEAD
一次revert  D+C+B的commit,回到A
$ git reset --hard A
$ git reset --soft @{1}  # (or ORIG_HEAD), which is D
$ git commit





























2012年6月18日 星期一

[perl] 算參照陣列的count


print Dumper $results;
results:$VAR1 = [
          {
            'num' => '118',
            'bday' => '1972-01-25'
          },
          {
            'num' => '123',
            'bday' => '1978-08-16'
          }
        ];
法1:
print "count:",scalar( @$results );
法2:
my $count = 0;

foreach my $r ( @$results ) {

    $count ++;

}

print "count:",$count;



[CI]多個檔案上傳


Single, Multiple and Multiple array upload library
http://codeigniter.com/forums/viewthread/110130/

2012年6月17日 星期日

ECLIPSE + aptana + pdt

Aptana Plugin for Eclipse and jQuery code assist
http://stackoverflow.com/questions/1351847/aptana-plugin-for-eclipse-and-jquery-code-assist

Aptana Code Assist-jQuery
http://eoffice.im.fju.edu.tw/phpbb/viewtopic.php?t=4029

google search - jquery bundle aptana
How to enable jQuery support in Aptana Studio 3 
http://stackoverflow.com/questions/4721124/how-to-enable-jquery-support-in-aptana-studio-3

Studio 3 jQuery support is lacking
https://aptanastudio.tenderapp.com/discussions/problems/2006-studio-3-jquery-support-is-lacking

Installing Smarty PDT into Zend Studio
http://www.web2works.co.uk/blog2works/install-smartypdt-plugin-into-zend-studio/
http://code.google.com/p/smartypdt/

Can PHP and HTML code assist happen in the same file?
http://stackoverflow.com/questions/3445392/can-php-and-html-code-assist-happen-in-the-same-file

[Eclipse]Web development tools & Aptana + jQuery Support
http://blog.xuite.net/ahdaa/blog1/36934153

Aptana Studio 3: Code Assist does'nt work after installing PDT - aptana 和PDT 似乎有衝突,有人是裝比較舊的aptana
https://aptanastudio.tenderapp.com/discussions/problems/3032-aptana-studio-3-code-assist-doesnt-work-after-installing-pdt
https://aptanastudio.tenderapp.com/discussions/questions/346-fully-functional-code-assist-between-pdt-aptana

-- Zen Coding

eclipse + aptana 在分頁上點右鍵 -> 新建編輯器 => 兩個同樣的檔案,可拉開兩邊,改一邊另外一邊會直接改變
按上面的圖示( show preview editor) 開瀏覽器預覽,一儲存就改變畫面






2012年5月14日 星期一

如何在blogger上加上syntax highlight


<script type="text/javascript">
alert(1);
alert(2);

var Bear = {};
</script>
http://jimchung1221.pixnet.net/blog/post/9425133-如何在blogger上加上syntax-highlight

如果網站的不知援外部運算
那就土法煉鋼
連上下面那個網站

http://www.tohtml.com/html/

 
把你的source code貼上後
按下"Highlight"
再把產生對應的HTML貼到網頁即可

How to Add Syntax Highlighter(v3) to Blogger Blogs
http://www.way2blogging.org/2011/03/how-to-add-syntax-highlighterv3-to.html 
http://www.way2blogging.org/widget-generators/syntax-highlighter-scripts-generator (checkbox在字的右邊)


SyntaxHighlighter Configuration
http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration/
 
<pre class='brush:[brushname];'>
 

 
</pre>
 
 
<pre class="brush: js; ruler: true; first-line: 10; highlight: [2, 4, 6]">...</pre>
 
12345
各個語言的brush對照表
http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/

Brush nameBrush aliasesFile name
ActionScript3as3, actionscript3shBrushAS3.js
Bash/shellbash, shellshBrushBash.js
ColdFusioncf, coldfusionshBrushColdFusion.js
C#c-sharp, csharpshBrushCSharp.js
C++cpp, cshBrushCpp.js
CSScssshBrushCss.js
Delphidelphi, pas, pascalshBrushDelphi.js
Diffdiff, patchshBrushDiff.js
Erlangerl, erlangshBrushErlang.js
GroovygroovyshBrushGroovy.js
JavaScriptjs, jscript, javascriptshBrushJScript.js
JavajavashBrushJava.js
JavaFXjfx, javafxshBrushJavaFX.js
Perlperl, plshBrushPerl.js
PHPphpshBrushPhp.js
Plain Textplain, textshBrushPlain.js
PowerShellps, powershellshBrushPowerShell.js
Pythonpy, pythonshBrushPython.js
Rubyrails, ror, rubyshBrushRuby.js
ScalascalashBrushScala.js
SQLsqlshBrushSql.js
Visual Basicvb, vbnetshBrushVb.js
XMLxml, xhtml, xslt, html, xhtmlshBrushXml.js

上面那個表格製作方法:
複製網址內的表格到sublime,用正規搜尋\t把第一、二、三行切開分別複製到Excel上,
然後複製整個表格到blog上即自動對齊


20200415 修正https時syntax highlight 失效問題

找出當時這些外連資源在哪加入的
https://support.google.com/blogger/answer/176245?hl=zh-Hant
主題 => 「網誌即時狀態(...)」之下,按一下 [編輯 HTML]
將 http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js 改成  https://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shCore.js
其他亦同
避免 http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js 轉跳到 https://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shCore.js 時瀏覽器報mixed content 的錯誤

20220811 換成 cloudflare CDN

因為 https://agorbatchev.typepad.com/pub/sh/3_0_83/scripts/shBrushPhp.js  404 ,所以換成 https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushPhp.js

參考資料: