2013年2月24日 星期日

ruby on rails 相關更新指令


brew update
Updates your local database of available (and no longer available) installable packages otherwise know in brew terminology as Formulae.
brew upgrade
Updates all the installed packages on your system currently. E.g. Upgrading PHP 5.3.20 to 5.3.21.
brew search 搜尋套件
brew info 查詢套件資訊
brew list 已經裝了哪些套件
brew update 更新 homebrew 自己
brew install 安裝套件



sudo gem update
will update all your gems.
Later, if you want, you can do some 'cleaning'
sudo gem cleanup
what will delete all the previous versions and keep only the latest ones. In case of existing dependencies, you will be prompted before deleting.

2012年9月5日 星期三

ios 加密

final use
https://github.com/Gurpartap/AESCrypt-ObjC
https://github.com/Gurpartap/aescrypt

useful url
http://publib.boulder.ibm.com/infocenter/initiate/v9r5/index.jsp?topic=%2Fcom.ibm.einstall.doc%2Ftopics%2Ft_einstall_GenerateAESkey.html
http://www.brentsowers.com/2007/12/aes-encryption-and-decryption-in-ruby.html
http://stuff-things.net/2007/06/11/encrypting-sensitive-data-with-ruby-on-rails/

http://aminby.net/2010/06/the-mothed-of-base64-coding-for-objc/
http://developer.apple.com/library/mac/#DOCUMENTATION/Darwin/Reference/ManPages/man3/CCCrypt.3cc.html
http://stackoverflow.com/questions/5564641/how-to-use-cccrypt-to-encrypt-a-file
http://stackoverflow.com/questions/2039940/any-cocoa-source-code-for-aes-encryption-decryption

2012年8月25日 星期六

vim and bash setting

~/.bash_profile


#enables color in the terminal bash shell
export CLICOLOR=1

#sets up the color scheme for list
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx

export PS1="\[\e[01;34m\][\u]\[\e[01;33m\]\W \`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]:)'; else echo -e '\[\e[01;31m\]:('; fi\` \[\e[01;34m\]$\[\e[00m\] "


~/.vimrc

" 檔案編碼                                                                    
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

syntax on "語法上色顯示
"set ai "自動縮排
set shiftwidth=2 "設定縮排寬度(使用>> <<時)
set tabstop=2 "tab的字元數
set expandtab "將tab轉換為空白
set ru "第幾行第幾個字
set hlsearch "設定高亮度顯示搜尋結果
set incsearch "在關鍵字還沒完全輸入完畢前就顯示結果
set smartindent "比ai更好的自動縮排
set confirm "操作過程有衝突時,以明確的文字來詢問
set cursorline "顯示目前的游標位置
highlight CursorLine term=underline cterm=underline guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE

set laststatus=2
set statusline=%4*%<\%m%<[%f\%r%h%w]\ [%{&ff},%{&fileencoding},%Y]%=\[Position=%l,%v,%p%%]

2012年7月23日 星期一

javascript用createElement產生button


var body = $('body') ;
var bt = document.createElement('input');
bt.id = "setTagBt";
bt.value = "Set Tag";
bt.type = "button";
bt.onclick = function(){handleSetTag();}
//比較奇怪的就是在上面這一行,如果已經寫好一個function,卻不能直接
//bt.onclick=handleSetTag();,反而一定要另外再新增一個function,否則就
//會直接執行你所指定的那個函式,不知道有沒有人知道為什麼?
body.appendChild(bt);

另外onclick也有
document.addEventListener( 'mousedown', setTag, false );
這種寫法

2012年7月22日 星期日

html5圖片預覽


<body id="body" onload="">
        <input id="fileInput" type="file" multiple onchange="handleFiles(this.files)">
        <br />
        <img id="bd" style="position:absolute; top:20px; left:0px;"></img>
    </body>
    <script type="text/javascript">
    /*<![CDATA[*/
        function $(id){
            return document.getElementById(id);
        }
        function displayImage(container,dataURL){
            container.src = dataURL;
        }
        function handleFiles(files){
            for (var i = 0; i < files.length; i++) {
                var file = files[i];
                var imageType = /image.*/;
               
                if (!file.type.match(imageType)) {
                  continue;
                }

                var reader = new FileReader();
                reader.onload = function(e){
                    displayImage($('bd'),e.target.result);
                }
                reader.readAsDataURL(file);
            }
            var body = $('body') ;
            var input = $('fileInput');
            body.removeChild(input);
        }
    //]]>
    </script>

2012年7月18日 星期三

opengles with iphone using color coding for picking object

正常來說在opengl是需要有兩的frame buffer
然後把color的資訊放在back buffer,不要swap過去,
如此user就不會看到。

但是在iphone上使用glkview我卻一直做不出來
原本想要用
http://mickyd.wordpress.com/2012/05/20/creating-render-to-texture-secondary-framebuffer-objects-on-ios-using-opengl-es-2/

glGenFramebuffers
glBindFramebuffer



來達成效果,但是卻始終不成功。

之後便改用
http://stackoverflow.com/questions/7861316/ios-5-glkview-how-to-access-pixel-rgb-data-for-colour-based-vertex-picking

只是我在draw in rect多加一個flag,只有在要snapshot的時候,才畫出color,
結果終於成功......


有用的參考資料:
http://stackoverflow.com/questions/9746602/getting-default-frame-buffer-id-from-glkview-glkit
http://stackoverflow.com/questions/6774197/opengl-es-2-0-object-picking-on-ios
http://stackoverflow.com/questions/7861316/ios-5-glkview-how-to-access-pixel-rgb-data-for-colour-based-vertex-picking
http://mickyd.wordpress.com/2012/05/20/creating-render-to-texture-secondary-framebuffer-objects-on-ios-using-opengl-es-2/
http://developer.apple.com/library/ios/#documentation/GLkit/Reference/GLKView_ClassReference/Reference/Reference.html
http://stackoverflow.com/questions/10958081/ios-render-to-and-read-from-depthbuffer-for-offscreen-processing

glDepthFunc


from:
http://blog.csdn.net/shuaihj/article/details/7230780

OpenGL函数思考-glDepthFunc

函数原型:

       void glDepthFunc(GLenum func)

参数说明:

      func:指定“目标像素与当前像素在z方向上值大小比较”的函数,符合该函数关系的目标像素才进行绘制,否则对目标像素不予绘制。可取以下值:

      GL_NEVER:永不绘制
      GL_LESS:如果目标像素z值<当前像素z值,则绘制目标像素
      GL_EQUAL:如果目标像素z值=当前像素z值,则绘制目标像素
      GL_LEQUAL:如果目标像素z值<=当前像素z值,则绘制目标像素
      GL_GREATER :如果目标像素z值>当前像素z值,则绘制目标像素
      GL_NOTEQUAL:如果目标像素z值<>当前像素z值,则绘制目标像素
      GL_GEQUAL:如果目标像素z值>=当前像素z值,则绘制目标像素\
      GL_ALWAYS:总是绘制
函数说明:

       通过目标像素与当前像素在z方向上值大小的比较是否满足参数指定的条件,来决定在深度(z方向)上是否绘制该目标像素。该函数只有启用“深度测试”时才有效,参考glEnable(GL_DEPTH_TEST)和glDisable(GL_DEPTH_TEST)