To figure out the function that your native library crashed within, use arm-eabi-addr2line which comes with the Android NDK.
How to use:
1. PATH_TO_ARM_EABI_ADDR2LINE/arm-eabi-addr2line -C -f -e libXXX.so
2. type in the address to look up (the address after pc in exception logs)
or in one command
PATH_TO_ARM_EABI_ADDR2LINE/arm-eabi-addr2line -C -f -e libXXX.so AddressToLookUp
Reference:
. http://www.codexperiments.com/android/2010/08/tips-tricks-debugging-android-ndk-stack-traces/
Wednesday, June 8, 2011
Memory alignment
Key points:
1. Each data element is stored at an address which is a multiple of its natural size.
2. Total size of the structure or union will be multiple of the natural size of the biggest data type in the structure or union.
To reduce the memory usage (Sets the alignment of all aggregate members to a specified byte boundary), use
. #pragma pack(1) before the declaration of the structure or union for Windows.
. __attribute__ ((packed)) after the } of the declaration for Linux.
Ex1. Windows.
#pragma pack(1)
struct alignment_test
{
char x ;
int y ;
short z ;
} ;
Ex2. Linux
. http://msdn.microsoft.com/en-us/library/aa505951.aspx
. http://www.ohse.de/uwe/articles/gcc-attributes.html#type-packed
. http://www.aleph1.co.uk/chapter-10-arm-structured-alignment-faq
. http://publib.boulder.ibm.com/infocenter/compbgpl/v9v111/index.jsp?topic=/com.ibm.xlcpp9.bg.doc/compiler_ref/pragma_pack.htm
1. Each data element is stored at an address which is a multiple of its natural size.
2. Total size of the structure or union will be multiple of the natural size of the biggest data type in the structure or union.
To reduce the memory usage (Sets the alignment of all aggregate members to a specified byte boundary), use
. #pragma pack(1) before the declaration of the structure or union for Windows.
. __attribute__ ((packed)) after the } of the declaration for Linux.
Ex1. Windows.
#pragma pack(1)
struct alignment_test
{
char x ;
int y ;
short z ;
} ;
Ex2. Linux
struct alignment_test
{
char x ;
int y ;
short z ;
} __attribute__ ((packed)) ;
For details:
. http://kezeodsnx.pixnet.net/blog/post/27585076. http://msdn.microsoft.com/en-us/library/aa505951.aspx
. http://www.ohse.de/uwe/articles/gcc-attributes.html#type-packed
. http://www.aleph1.co.uk/chapter-10-arm-structured-alignment-faq
. http://publib.boulder.ibm.com/infocenter/compbgpl/v9v111/index.jsp?topic=/com.ibm.xlcpp9.bg.doc/compiler_ref/pragma_pack.htm
Monday, March 14, 2011
Displaying a video in Flex using the NetConnection, NetStream, and Video classes
Good Adobe Flex articles!
http://blog.flexexamples.com/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/
Also, using VLC and FFMpeg with Flex to accomplish screen recording
http://www.adobe.com/devnet/air/flex/articles/air_screenrecording.html
http://blog.flexexamples.com/2008/03/01/displaying-a-video-in-flex-using-the-netconnection-netstream-and-video-classes/
Also, using VLC and FFMpeg with Flex to accomplish screen recording
http://www.adobe.com/devnet/air/flex/articles/air_screenrecording.html
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
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%
^ : 冪次方
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%)
貸款利息每一期都不一樣,因為貸款利息是以上一期的貸款餘額乘上貸款利率;
由於每一期的貸款餘額會隨著本金的攤還而愈來愈少,每一期的所繳的利息當然也會愈來愈少.
=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.
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.
Subscribe to:
Posts (Atom)
Check clients which connect to Mac OS X Wi-Fi Internet Sharing
arp -i bridge100 -a bridge100 may be different on your Mac OSX
-
1. Create an account on TestFlight ( http://testflightapp.com ) and with "Developer" option checked. 2. Log in to the TestFlight ...
-
[轉載] [Javascript] Encrypt your private blog post from the article of Kaie's Blog 今日在PPT上的Blog版逛到版友weijr所提到的一篇好文章,可以用來針對Blog中某一段文字給予加密,變成...
-
For Mac OS: Use lipo. Ex. lipo -info staticLibrary.a For Linux OS: Use file Ex. file staticLibrary.c