Friday, February 28, 2014

GNU Cash (Perl Finance::Quote) Failed to Retrieve Stock Price Quotes

I have been GNU Cash for a couple of years. I set up Perl Finance::Quote to automatically update stock price quotes. GNU Cash suddenly reports that it cannot retrieve stock price quotes.

Using this opportunity, I updated GNU Cash to 2.6.1 and reinstalled Finance::Quote module. However, the problem remains.

I am running GNU Cash on both a Windows XP box and a Windows 8.1 box. On both machines I observe the same problem. The detailed problem description is as follows,

(1) Version of Perl

C:\>perl --version
This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x86-multi-
thread (with 1 registered patch, see perl -V for more detail)

Copyright 1987-2012, Larry Wall

Binary build 1603 [296746] provided by ActiveState http://www.ActiveState.com
Built Mar 13 2013 11:29:21


(2) Perl Finance::Quote with GNU Cash

C:\Program Files\gnucash\bin>perl gnc-fq-check
("1.18" "vwd" "yahoo_nz" "australia" "amfiindia" "usfedbonds" "canada" "yahoo" "
adig" "bux" "aiahk" "bsero" "yahoo_australia" "unionfunds" "lerevenu" "asia" "ts
x" "sixfunds" "indiamutual" "bse" "hungary" "known_currencies" "fidelity_direct"
 "goldmoney" "tdwaterhouse" "trustnet" "ftportfolios_direct" "cominvest" "mornin
gstar" "ftportfolios" "tdefunds" "hu" "za" "fundlibrary" "stockhousecanada_fund"
 "yahoo_europe" "platinum" "maninv" "tsp" "financecanada" "usa" "france" "trowep
rice" "nasdaq" "bmonesbittburns" "yahoo_asia" "tiaacref" "troweprice_direct" "se
b_funds" "yahoo_brasil" "greece" "fidelity" "fetch_live_currencies" "romania" "d
wsfunds" "finland" "hex" "brasil" "asegr" "deka" "nyse" "canadamutual" "asx" "fi
nanzpartner" "fool" "dutch" "uk_unit_trusts" "sixshares" "nzx" "aex" "nz" "vangu
ard" "europe" "bourso") 
 

(3) Problem: when Finance::Quote in GNU Cash is being installed, the installation script actually reports an error despite that it states the process was successful. See below,

C:\Program Files\gnucash\bin>install-fq-mods.cmd
GNU Cash
......
* Run gnc-fq-helper

Use of uninitialized value within %info in string eq at C:/Perl/site/lib/Finance
/Quote/Yahoo/Base.pm line 222, <> line 1.
Use of uninitialized value $info{"Missing Symbols List.\34p_change"} in substitu
tion (s///) at C:/Perl/site/lib/Finance/Quote/Yahoo/Base.pm line 238, <> line 1.

Use of uninitialized value within %info in pattern match (m//) at C:/Perl/site/l
ib/Finance/Quote/Yahoo/Base.pm line 243, <> line 1.
(#f)

* Installation succeeded

(4) gnc-fq-dump and gnc-fq-helper fails. Now I try GNU Cash's gnc-fq-dump, it actually fails. It is perhaps the result of some issue with Active Perl. For instance,

C:\Program Files\gnucash\bin>echo (yahoo "TGT") | perl gnc-fq-helper
Use of uninitialized value within %info in string eq at C:/Perl/site/lib/Finance
/Quote/Yahoo/Base.pm line 222, <> line 1.
Use of uninitialized value $info{"Missing Symbols List.\34p_change"} in substitu
tion (s///) at C:/Perl/site/lib/Finance/Quote/Yahoo/Base.pm line 238, <> line 1.

Use of uninitialized value within %info in pattern match (m//) at C:/Perl/site/l
ib/Finance/Quote/Yahoo/Base.pm line 243, <> line 1.
(#f)

which is the same error I saw during the installation of the Finance::Quote module.

I attempted a few methods neither of which works. The methods I attempted were.
(1) Completely remove GNU Cash and Active Perl and reinstall GNU Cash and Active Perl
(2) Update Perl modules using "cpan -r".

What actually works is to replace Active Perl by Strawberry Perl. I obtain this solution by reading " install-fq-mods.cmd that actually attempts to install Strawberry Perl if perl cannot be found.

Here is the steps that leads to a success.
(1). Completely remove Active Perl. There is no need to reinstall GNU Cash. So leave GNU Cash alone
(2). Download and install Strawberry Perl
(3). Install Perl Finance::Quote module


C:\Program Files\gnucash\bin>install-fq-mods.cmd

(4). Test the functionality using gnc-fq-helper

C:\Program Files\gnucash\bin>echo (yahoo "JPM") | perl gnc-fq-helper
(("JPM" (symbol . "JPM") (gnc:time-no-zone . "2014-02-27 16:01:00") (last . 56.6
9) (currency . "USD")))

(5). Test the functionality using gnc-fq-dump

C:\Program Files\gnucash\bin>perl gnc-fq-dump nyse JPM TGT
Finance::Quote fields Gnucash uses:
    symbol: JPM                  <=== required
      date: 02/27/2014           <=== required
  currency: USD                  <=== required
      last: 56.69                <=\
       nav:                      <=== one of these
     price: 56.69                <=/
  timezone:                      <=== optional
=====

Finance::Quote fields Gnucash uses:
    symbol: TGT                  <=== required
      date: 02/27/2014           <=== required
  currency: USD                  <=== required
      last: 60.66                <=\
       nav:                      <=== one of these
     price: 60.66                <=/
  timezone:                      <=== optional

It works.
By the way, the information about version of the Perl and Finance::Quote are as follows,

C:\Program Files\gnucash\bin>perl --version

This is perl 5, version 18, subversion 2 (v5.18.2) built for MSWin32-x86-multi-t
hread-64int

Copyright 1987-2013, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


C:\Program Files\gnucash\bin>perl gnc-fq-check
("1.20" "bitcoin_gbp" "known_currencies" "bsero" "bitcoin_sek" "fetch_live_curre
ncies" "hu" "hex" "bitcoin_nok" "australia" "bitcoin_cad" "tdefunds" "mtgox_jpy"
 "fool" "bitcoin_hkd" "yahoo_europe" "mtgox_chf" "finanzpartner" "europe" "bitco
in_cny" "ftportfolios_direct" "unionfunds" "bitcoin_thb" "ftportfolios" "yahoo_b
rasil" "uk_unit_trusts" "lerevenu" "aiahk" "bmonesbittburns" "mtgox_hkd" "sixsha
res" "yahoo_nz" "mtgox_nok" "deka" "za" "maninv" "nasdaq" "bourso" "tsx" "bitcoi
n_jpy" "financecanada" "mtgox_dkk" "dwsfunds" "cominvest" "sixfunds" "bitcoin_sg
d" "mtgox_eur" "asegr" "mtgox_usd" "bitcoin_usd" "fidelity" "stockhousecanada_fu
nd" "bitcoin_chf" "asx" "fundlibrary" "bitcoin_pln" "mtgox_aud" "nzx" "amfiindia
" "nz" "romania" "bitcoin_rub" "yahoo" "nyse" "tiaacref" "canada" "asia" "usa" "
greece" "france" "hungary" "mtgox_pln" "fidelity_direct" "bse" "yahoo_asia" "bux
" "troweprice_direct" "mtgox_sgd" "morningstarjp" "platinum" "aex" "mtgox_cny" "
mtgox_sek" "yahoo_australia" "mtgox_rub" "usfedbonds" "mtgox_nzd" "bitcoin_dkk"
"brasil" "trustnet" "vanguard" "adig" "vwd" "mtgox_cad" "bitcoin_eur" "canadamut
ual" "finland" "bitcoin_nzd" "troweprice" "dutch" "indiamutual" "tdwaterhouse" "
tsp" "seb_funds" "goldmoney" "morningstar" "mtgox_thb" "bitcoin_aud" "mtgox_gbp"
)

which means that it is probably that Finance::Quote 1.20 works while 1.18 has some problem.

Tuesday, February 18, 2014

Redmine Error: Phusion Passenger Watchdog Failed to Start

Having upgraded a few package including Redmine and Ruby on Rail, my redmine host failed to start. I am running a Apache web server for the Redmine. When I browse the Redmine host, the error message returned in the web browser is


Application error
Rails application failed to start properly

The Redmine's production log at the redmine/log directory indicates nothing is generated in the log, which means Redmine does not even run. To verify that Redmine itself is actually OK, run it from the command line,

ruby script/rails server webrick -e production

Then point the browser to http://localhost:3000/. The Redmine server runs OK. Checking Apache's error log (the error_log file) a little bit closely, the error message looks the following,

[pid=9135 thr=140212503205888 file=ext/common/LoggingAgent/Main.cpp:287 
time=2014-02-01 03:29:02.699 ]: *** ERROR: Cannot stat 
'/var/log/passenger-analytics': Permission denied (13)
     (empty)
[Sun Feb 01 03:29:02 2014] [error] *** Passenger could not be initialized 
because of this error: Unable to start the Phusion Passenger watchdog 
because it encountered the following error during startup: Unable to start 
the Phusion Passenger logging agent: it seems to have crashed during startup 
for an unknown reason, with exit code 1
At the same time, the redmine_error.log that belongs to the virtual host in which the Redmine runs shows something similar to,

[Mon Feb 01 22:55:15 2014] [warn] [client 10.0.0.1] (104)Connection reset by peer: mod_fcgid: 
 error reading data from FastCGI server
[Mon Feb 01 22:55:15 2014] [error] [client 10.0.0.1] Premature end of script headers: 
 dispatch.fcgi

Now it becomes clearer that the problem may be that Phusion Passenger cannot access the directory /var/log/passenger-analytics. After I give sufficient permission to the directory as follows, the Phusion Passenger starts OK and the Redmine runs normally.

chown -R apache:apache passenger-analytics
chmod -R 750 apache:apache passenger-analytics
chcon system_u:object_r:httpd_sys_content_t:s0  passenger-analytics

The last step is necessary since SeLinux is enabled in my case. A second, perhaps a better approach is to route any analytics logs to Redmine's log directory, for which, I added the following line to the Redmine's Apache configuration file, in my case /etc/httpd/conf.d/redmine.conf,


<VirtualHost *:80>
   ......
   PassengerAnalyticsLogDir REDMINE_ROOT/log
   ......
</VirtualHost> 

In the above, replacing REDMINE_ROOT by the root directory of the Redmine installation, such as /home/usr/redmine etc. In this case, there is not need to change the directory permission and ownership since the Redmine directory should already have had correct permission and SeLinux context. In addition, you can consolidate the log files in a place that you like.

Thursday, January 30, 2014

Default Desktop Crashes in Ubuntu 13.10 (Saucy) as a VM VirtualBox Guest

I created a guest instance using Ubuntu 13.10 (Saucy) in Oracle VM VirtualBox. When I log in using the default Ubuntu Desktop environment, what I got was a nearly blackscreen after a "compiz crashed" message. My suspicion was that the video card is too  primitive and did not have a reasonable OpenGL support.

To fix the issue, I installed Gnome desktop and logged without any problem in using the Gnome Desktop environment. Since the default desktop environment crashes and I could not get a terminal window to do anything, I had to exit to the console to do the installation. The steps are as follows,


1. Press CTRL-ALT-F1 to switch to the console screen
2. Log in on the console screen
3. Install Gnome desktop environment, by running
         $ sudo apt-get install gnome
4. Kill and restart X or simply reboot the machine, by running
         $ sudo reboot
5. When the Graphical Login screen appears, click on the little
   icon to the right of the user name, and choose any of Gnome
   desktop environment, (Gnome Classic, Gnome Classic ...)
6. Then log in. 
You should be in without any problem.

Web Server Video Support

I was playing with HTML 5 video and encountered the following error in Firefox "no video with supported format and MIME type found" and  that in Internet Explorer "Error: Unsupported video type or invalid file path". The HTML file looks like the following,


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>HTML 5 Video Example</title>
</head>
<body>
<h1>Chapter 1: HTML/XHTML</h1>
<h2>Video Example</h2>
<video width="600" height="500"
       autoplay="autoplay"
       controls="controls"
       preload="auto"
       poster="novideo.png">
  <source src="./ex.mp4" type="video/mp4" />
  <source src="./ex.ogv" type="video/ogg" />
  <source src="./ex.webm" type="video/webm" />
  Your browser does not support the video element
</video>
</body>
</html>

The video clip of all 3 formats are at the server and the video plays well at the local machine and fine at another server. After a little bit digging, I found out that the Apache web server has some configuration issue and did not have proper MIME types added. To fix it, simply upload a .htaccess file to the directory where the HTML file is and the .htaccess has the following content,


AddType video/webm .webm
AddType video/mp4 .mp4
AddType video/ogg .ogv

Wednesday, January 22, 2014

Producing PDF document Compatible to Firefox Build-in PDF Viewer

Sometimes Firefox Build-in PDF Viewer does not render some PDF documents well, in which case, the PDF Viewer complains that the PDF document may not be displayed correctly.

A suggested method to correct it is to use external PDF viewer as suggested at Mozilla.

Web searches yield lots of discussions and the discussions are mostly how to find a way to display it correctly just like the above. Those discussions are on the "consumer" side.

However, if you are the on the side of producing and posting PDF documents online, you are probably more interested from beginning with in producing PDF documents that can be displayed correctly by the Firefox Build-in PDF Viewer.

As I investigate, this is not a trivial task. Generally, when the PDF Viewer does not display the document correctly, it is a result that the document contains certain feature which the viewer does not support. To generate a compatible PDF document to the viewer is not to use any unsupported feature that the viewer does not support. However, I failed to locate any document showing which feature is supported and which is not, including the project site at GitHub.

One method that worked for me at least in a few occasions is to use Firefox's Element Inspector.

When a PDF document is not displayed correctly, locate the element that is not displayed correctly or a nearby element to the element that is invisible as a result of not being displayed correctly, right-click the mouse and select "Inspect Element". Examine the element and elements nearby in the Inspector. If you examine them carefully, you may identify something suspicious. For instance, in FireFox 26.0, a PDF file saved in Microsoft PowerPoint is not displayed correctly. Examining it in the Element Inspector, I found out that the location of the problem and suspected that the font "Verdana" somehow could not be displayed correctly, as shown below.
 

By replacing font "Verdana" by a recognizable font, the problem went away.

Tuesday, December 31, 2013

"Uncreative Writing"?

I heard a discussion on "Uncreative writing" from the "On the Media" fro NPR. Host Brooke Gladstone and her guest Kenneth Goldsmith discusses plagiarism. What interests me is what Kenneth Goldsmith's experiments, that includes the "Uncreative Writing" course he has been teaching. See the course description on his website at

The radio episode I was listening is
that also includes the transcript of the program.

Goldsmith has a book bearing the name of "Uncreative Writing".


Find more  of Goldsmith's work at his website at,

Story Told in Photos ... "Faces of Addiction"

I heard the story about Chris Arnade's photographic work, called "Faces of Addiction". I checked it out when I got back to my computer. It was an indeed powerful story. His photographic work has been actually widely reported. Check his work out at Flickr. 

Several related ...