2013年3月12日 星期二

ios function parameter using block


Example:
- (void)someFunc:(void(^)(void))someBlock;

- ( void )myMethodTakingPredicate: ( BOOL ( ^ )( int ) )predicate

2013年3月2日 星期六

urban airship

Header search path - Ensure that your project’s header search path includes the Airship directory (recursive).

use:
"$(SRCROOT)/Airship/" recursive

add header:
//urban airship
#import "UAirship.h"
#import "UAPush.h"

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>