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.