Discuz ~ 發佈新文章未即時顯示

這是因為緩存的問題...........

進後台

全局 -> 性能優化 -> 內存優化

我把主題相關的勾都拿掉.......確實是有working

Javascript ~ format numbers as money

Number.prototype.formatMoney = function(c, d, t){
var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
   return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
 };


(123456789.12345).formatMoney(2, '.', ',');

source
http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript

Yii ~ use CKEditor

到這裡下載ckeditor-integration
http://www.yiiframework.com/extension/ckeditor-integration/

解壓縮丟到extensions裡

然後下載ckeditor丟到root

http://ckeditor.com/download

像我就是丟到yii/xxxxx/底下


在View裡面使用ckeditor的sample code

$this -> widget('ext.ckeditor.CKEditorWidget', array("model" => new Event,
"attribute" => 'content',
"defaultValue" => $item['content'],
"config" => array("height" => "400px", "width" => "80%", "toolbar" => "Full")));

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


再開啟模擬器就好了~~

Android ~ export apk


在輸出apk前要先產生key

不然選擇Export Unsigned Application Package

手機是不能安裝的

產生key很簡單

開cmd, 要用系統管理員身分開啟

到JDK目錄 C:\Program Files\Java\jdk1.7.0_03\bin

輸入

keytool -genkey -v -keystore android.store -alias android.keystore -keyalg RSA -validity 20000

照問題一直輸入

最後打yes

他就產生了my-release-key.keystore


接著就可以用這key產生apk

在專案右鍵->Export Signed Application Package


選剛剛產生的key輸出


此為手機上的執行結果~




關於apk傳至手機安裝的方式

比較建議用dropbox

輸出出來直接丟進dropbox, 手機再用dropbox去點那個apk就可以安裝


reference
http://hatsukiakio.blogspot.tw/2009/05/eclipseandroidapk.html

Android ~ Unable to resolve target 'android-3'

這問題發生在我專案弄好好的..

下次再開啟就出現一堆錯誤= =

連import android.app.Activity;

這樣的code都錯...

錯誤訊息

Unable to resolve target 'android-3'

上網google才知道這問題是設定檔的問題

不過我google到的是說改default.properties

我是要改project.properties才有作用


原本設定是

target=android-3

改成

target=android-15

會找不到3也是正常的

因為我的SDK裡面沒有API Level 3



reference
http://androcat316.blogspot.tw/2010/10/unable-to-resolve-target-android-5.html

Discuz ~ config files need modify when moving server

不知道為什麼不把config統一弄一個檔案就好= =


config/config_global.php

config/config_ucenter.php

uc_server/data/config.inc.php

Android NDK install

照這網頁上的做就好~~~~

我是android-ndk-r8b

所以把這部分改成android-ndk-r8b就好

可以working

http://cheng-min-i-taiwan.blogspot.tw/2010/06/android-ndk-hellojni.html

Eclipse Adnroid ~ The connection to adb is down, and a severe error has occured.

鳥問題 = =

模擬器打不開無法run.......

靠XD

[2012-09-06 17:18:44 - test] ------------------------------
[2012-09-06 17:18:44 - test] Android Launch!
[2012-09-06 17:18:44 - test] The connection to adb is down, and a severe error has occured.
[2012-09-06 17:18:44 - test] You must restart adb and Eclipse.
[2012-09-06 17:18:44 - test] Please ensure that adb is correctly located at 'C:\android-sdk-windows\platform-tools\adb.exe' and can be executed.


http://fecbob.pixnet.net/blog/post/36105987-android%E4%B8%ADthe-connection-to-adb-is-down%E8%A7%A3%E6%B1%BA%E6%96%B9%E6%B3%95

我用方法3依然不行

整個就是詭異.......工作管理員也殺光光了

eclipse有重開兩次了

後來我直接執行C:\android-sdk-windows\platform-tools的adb.exe

再run就有了= =

Ubuntu ~ vsftp add user account to www root


不像windows用ftp程式架ftp

是在程式裡新增account跟指定目錄

vsftp是新增一個系統的user


sudo adduser YOUR_USER_NAME

像我新增使用者bitty就是

sudo adduser bitty

然後登入的目錄是在/home/bitty/

要修改成在/var/www/

下指令

sudo vim /etc/passwd

把剛新增的user

我是叫bitty.....

後面的目錄改成

/var/www/



這樣用bitty登入就會直接到網頁上的跟目錄

reference
http://blog.udn.com/nigerchen/2261345

http://www.berecursive.com/2011/amazon-ec2/installing-vsftpd-on-an-amazon-ec2-ubuntu-instance

yii ~ set timezone, taiwan

return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Test',

'timeZone'=>"Asia/Taipei",


reference
http://www.yiiframework.com/forum/index.php/topic/5976-convert-time-into-different-timezones/

Apache ~ .htaccess not read .htaccess not working

會找這問題是因為......

yii的/user/login連結跑不出來

not found

就覺得應該是rewrite沒開

跑去開了rewrite

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart


發現連結依然找不到......

燈愣.....

為此我還實際測試.htaccess倒底是否working

結果working...

上網找找找

才看到有人說是Allowoverride的問題

修改過後才真的可以了 = =

sudo vi /etc/apache2/sites-available/default

把DocumentRoot /var/www

裡面的AllowOverride改成All

AllowOverride All

<Directory /var/www/>

裡面也要改

AllowOverride All

儲存

再下指令重開apache就好了

sudo /etc/init.d/apache2 restart


Ubuntu ~ set user, vsftp authority, vsftp can't write file

這是在我用AWS時候遇到的問題= =

就是成功把user登入的目錄換到/var/www/

可是沒權限寫入檔案XD


下這指令就解決了~

我的user名稱是bitty

chown -R bitty /var/www

修改vsftpd.conf

guest_username=btty


reference
http://blog.csdn.net/debehe/article/details/4154755

yii ~ Simple Authentication, user login

照著做

沒意外應該OK

我是參考這網址做的~~

http://www.larryullman.com/2010/01/04/simple-authentication-with-the-yii-framework/

yii ~ disable debug

in project folder

index.php

defined('YII_DEBUG') or define('YII_DEBUG', true);

modify to

defined('YII_DEBUG') or define('YII_DEBUG', false);


reference
http://puskin.in/blog/2011/05/enabledisable-debug-in-yii/

AWS EC 2 ~ Free Usage Tier (Per Month)


750 hours of Amazon EC2 Linux† Micro Instance usage (613 MB of memory and 32-bit and 64-bit platform support) – enough hours to run continuously each month*

750 hours of Amazon EC2 Microsoft Windows Server‡ Micro Instance usage (613 MB of memory and 32-bit and 64-bit platform support) – enough hours to run continuously each month*

750 hours of an Elastic Load Balancer plus 15 GB data processing*

30 GB of Amazon Elastic Block Storage, plus 2 million I/Os and 1 GB of snapshot storage*

source
http://aws.amazon.com/free/

Amazon EC2 ~ vsftp can't connect

因為amazon的防火牆擋住了port 21

去NETWORK & SECURITY的Security Groups

在底下Inbound

Custom TCP rule

Port range輸入21

再Add Rule

再Apply Rule Changes


reference
http://maxivak.com/setting-up-ftp-server-on-ubuntu-%E2%80%93-amazon-ec2/

Ubuntu ~ install LAMP


sudo apt-get install tasksel

sudo tasksel

select LAMP server

and install


reference
http://www.unixmen.com/install-lamp-with-1-command-in-ubuntu-1010-maverick-meerkat/

Ubuntu ~ remove php

sudo apt-get -y purge php*

reference
http://askubuntu.com/questions/59886/how-to-compelety-remove-php

Ubuntu ~ enable apache mod_rewrite

sudo a2enmod rewrite

然後再restart apache

sudo /etc/init.d/apache2 restart

reference
http://thinkdiff.net/ubuntu-linux/ubuntu-enable-mod_rewrite-in-apache-server/

vi command

以下是我今天用vi使用到的指令.......

會這三招應該簡單的修改都可以辦到了XD


i為進入編輯模式

按Esc打:w為儲存

按Esc打:q!為離開


http://www.washington.edu/computing/unix/vi.html

FileZilla ~ 伺服器以無法路由的 IP Address 送出了被動式回應. 改為使用伺服器 IP Address.

指令: PASV
回應: 227 Entering Passiv Mode (192,168,0,101,8,4)
狀態: 伺服器以無法路由的 IP Address 送出了被動式回應. 改為使用伺服器 IP Address.
指令: LIST
回應: 150 Data connection created for directory listing
錯誤: 連線逾時
錯誤: 無法取得目錄列表

 是FileZilla 設定上出了問題

按照以下步驟

編輯-> 設定 -> 連線 -> FTP -> 被動模式 -> 回覆主動模式

即可取得目錄列表


source
http://blog.xuite.net/ha126269/94113267/43020801

Ubuntu ~ list folder files command

ls - list

reference
http://manpages.ubuntu.com/manpages/lucid/man1/ls.1.html

3dsmax ~ export ASE

http://q3a.ath.cx/level_design/aseexport/

yii ~ findAll example

$model=Auction::model()->findAll(array(
'condition'=>'status=:status AND starttime >= :date',
'params'=>array(':status'=>1, ':date'=>$date),
));


reference
http://stackoverflow.com/questions/7314284/yii-findbyattributes-with-greater-than-attribute

jQuery ~ move element

$("#source").appendTo("#destination");


reference
http://stackoverflow.com/questions/1279957/how-to-move-an-element-into-another-element