Wednesday, March 9, 2011

Excel financial formulas - PMT

Pmt function returns the payment amount for a loan based on an interest rate and a constant payment schedule.

Pmt( interest_rate, number_payments, PV )
PV : Present Value

To find out the monthly payment on a 1,000,000 loan at an annual rate of 7.5%. The loan is paid off in 2 years (ie: 2 x 12). All payments are made at the beginning of the period.

=Pmt(7.5%/12, 2*12, 1000000)

Reference:
http://www.techonthenet.com/excel/formulas/pmt.php
http://www.masterhsiao.com.tw/ExcelFinance/PMT/PMT.htm

年化報酬率公式

年化報酬率公式 = ( (期末金額 / 期初金額) ^ (1 / 年期) ) - 1
^ : 冪次方

Ex. 一開始以10萬元去投資, 3年後結束投資, 拿回 14萬. 年化報酬率為:
( 140000 / 100000 ) ^ ( 1 / 3 ) - 1 = 約 11.87%

貸款利率

貸款利率. 用 Excel 套入公式
=RATE( 期數, -月繳款金額, 貸款金額 ) * 12 = 年利率

Ex. 貸款 100 萬, 分4年(48期)攤還, 每個月繳 23000
則年利率是: RATE( 48, -23000, 1000000 ) * 12 = 0.04935 (4.935%)

貸款利息每一期都不一樣,因為貸款利息是以上一期的貸款餘額乘上貸款利率;
由於每一期的貸款餘額會隨著本金的攤還而愈來愈少,每一期的所繳的利息當然也會愈來愈少.

Monday, January 3, 2011

Steps to install Bugzilla on CentOS 5.4

1. Disable selinux
vi /etc/selinux/config
set SELINUX=disabled

2. Add one iptables rule to allow TCP port 80 for httpd
vi /etc/sysconfig/iptables
add following rule
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
service iptables restart

3. Install required components
yum install perl
yum install httpd
yum install mysql-server
yum install mysql
yum install php-mysql
yum install gcc
yum install cvs
yum install patchutils
yum install mysql-devel

4. Install bugzilla
cd /var/www
rmdir html
wget http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-3.6.3.tar.gz
tar xzvf bugzilla-3.6.3.tar.gz
mv bugzilla-3.6.3 html

5. Apache configuration
vi /etc/httpd/conf/httpd.conf
find < directory "/var/www/html" > section and ..
1. Append ExecCGI to "Optoins"
2. Add "DirectoryIndex index.cgi index.html" under "Options"

Uncomment AddHandler cgi-script .cgi
service httpd start

6. Check if all the required perl modules are installed
./checksetup.pl --check-modules
to install all missing modules, run following command
perl install-module.pl --all
once doen, check modules again to see if it's ok
if DBD-mysql is not ok, run "perl install-module.pl DBD:mysql" to install it

7. Create localconfig
./checksetup.pl
modify the $db_pass of localconfig
vi ./localconfig
$db_pass = "howard"

8. Increase attachment size to 3MB, for example.
vi /etc/my.cnf
add "max_allowed_packet=3M"
service mysqld restart

9. Create mysql user
mysql -u root -p
GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.*TO bugs@localhost IDENTIFIED BY 'howard';
FLUSH PRIVILEGES;

10. Create bugzilla database and administrator account
run ./checksetup.pl and follow the instructions to create the administrator account
once done, run ./checksetup.pl again to make sure everything is ok

Now bugzilla should be ready to go, connect to it via browser and complete the one time setup.
That's all.

Notes:
. To fix "Error when close pipe to /usr/lib/sendmail (while creating account), you have to allow SMTP connection in SELinux by run "setsebool -P httpd_can_sendmail 1" without quotes.

Tuesday, December 14, 2010

Android NDK r5 modification for ffmpeg-android

Change asm to __asm__ at line 25 in android-ndk-r5/platforms/android-3/arch-arm/usr/include/asm/byteorder.h

Environment variable PATH location

Environment variable PATH location: /etc/paths

To export other variable, ie. NDK, adding it to ~/.profile. something like this
export NDK=~/Library/android-ndk-r4b

Or

vi ~/.bashrc
PATH=/opt/crosstool/arm-none-linux-gnueabi-4.4.0_ARMv5TE/bin:$PATH

Check clients which connect to Mac OS X Wi-Fi Internet Sharing

arp -i bridge100 -a bridge100 may be different on your Mac OSX