Yii ~ use Upload class

想當初做網站處理圖片的部分

我都是包Upload這個class來做圖片的處理

http://www.verot.net/php_class_upload_docs.htm

現在用yii的framework

想不到也可以用Photobucket


這邊下載
http://www.yiiframework.com/extension/upload/

安裝方法就是整包丟進extension

然後這邊是我的sample code

        Yii::import('application.extensions.upload.Upload');
        // receive file from post
        if (isset($_FILES['pic'])) {
            $Upload = new Upload($_FILES['pic']);

            $Upload -> jpeg_quality = 100;
            $Upload -> no_script = false;
            $Upload -> image_resize = true;
            $Upload -> image_x = 700;
            $Upload -> image_y = 500;
            $Upload -> image_ratio = true;

            // some vars
            $destPath = Yii::app() -> getBasePath() . '/../img/origin/' . $this -> id . '/';
            $destName = $item -> id;

            // verify if was uploaded
            //origin img
            if ($Upload -> uploaded) {
                $Upload -> file_new_name_body = $item -> id;
                $Upload -> file_new_name_ext = 'png';
                $Upload -> file_auto_rename = false;
                $Upload -> file_overwrite = true;
                $Upload -> process($destPath);
            }
            //thumb
            $destPath = Yii::app() -> getBasePath() . '/../img/thumb/' . $this -> id . '/';
            if ($Upload -> uploaded) {
                $Upload -> file_new_name_body = $item -> id;
                $Upload -> file_new_name_ext = 'png';
                $Upload -> file_auto_rename = false;
                $Upload -> file_overwrite = true;
                $Upload -> image_resize = true;
                $Upload -> image_x = 120;
                $Upload -> image_y = 180;
                $Upload -> image_ratio = true;
                $Upload -> process($destPath);
            }

        }


Yii ~ load config

'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
'myParam'=>'myValue',
),


$param=Yii::app()->params['myParam'];


reference
http://www.yiiframework.com/forum/index.php/topic/10559-how-to-load-configuration-set-in-configmainphp/

Javascript ~ get json key value

for (var key in p) {
if (p.hasOwnProperty(key)) {
alert(key + " -> " + p[key]);
}
}



reference
http://stackoverflow.com/questions/684672/loop-through-javascript-object

MilkShape3D


http://www.wretch.cc/blog/gtaiv/8547734

3dsmax ~ another way to export md2, export to MilkShape3D ms3d

上網找的輸出md2的script.....

輸出的東西似乎都不能用......打不開= =

所以才找到這東西

作法就是先輸出成,ms3d給MilkShape3D

再從MilkShape3D開啟再輸出md2

關於3dsmax輸出ms3d

到這邊下載
http://www.maxplugins.de/r2009_files/collberg/max2ms3d_v112_Max2009.zip

解壓縮放到3dsmax裡的plugins目錄

開啟3dsmax就可以輸出ms3d檔了




reference
http://forums.cgsociety.org/archive/index.php/t-721754.html

3dsmax ~ import md2

到此連結下載plugin

http://www.scriptspot.com/3ds-max/scripts/quake-ii-md2-importer

下載後解壓縮

把importmd2.ms貼到Script裡的startup目錄

像我是
C:\Program Files\Autodesk\3ds Max 2009\Scripts\Startup

丟進去開啟3dsmax

進Utilities

點MAXScript


選Quake2 MD2 Importer

Load all frames打勾

在按Import MD2就可以匯入到3dsmax裡




3dsmax ~ Keys may not be set when in figure mode. exit figure mode


這是移動骨架並設定key時發生的問題

離開figure mode

點motion的tab

選骨架

把Figure Mode按掉就好



reference
http://forums.3dtotal.com/showthread.php?t=82892

Javascript ~ convert number display format

var num = 12345678;
var str = num + ""; // cast to string
var out = [];
for (var i = str.length - 3; i > 0; i -= 3) {
out.unshift(str.substr(i, 3));
}
out.unshift(str.substr(0, 3 + i));
out = out.join(','); // "12,345,678"


reference
http://stackoverflow.com/questions/1943828/convert-digital-display-format

Javascript ~ set cookie, get cookie

reference
http://www.w3schools.com/js/js_cookies.asp


function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

Android ~ Android Virtual Device (AVD) use graphics acceleration, enable emulator graphics acceleration


reference
http://www.getsteps.com/view.php?oid=5132ea37258d97bd


我覺得不管是不是因為寫OpenGL而開啟這功能

都應該開啟這功能

因為速度差超多

原本噸到爆炸

開了之後順得跟飛一樣XD


我是安裝這些東西

開啟Android SDK Manager

安裝這兩個




開啟AVD Manager

我的設定是選擇Interl Atom(x86)

還有要開啟GPU emulation, Value要設為Yes


再開啟模擬器就好了~~