Thursday, November 17, 2005

Tax for mutual fund

Some special rules:
1. To qualify for the qualified dividend (taxed at same rate as long term captical gain), the fund must be held for at least 61 days.
2. Upon selling of a fund held not more than 6 months, part of short term capital loss (if there's any) must be treated as long term captital loss to the limit of long term captital gain distributions.


A good guide is at
http://fairmark.com/mutual/

At the same site, tax information for other investment can also be found.

Tuesday, November 15, 2005

Notes on Yahoo finance historical prices

The adj close is the actual close multiplied by split multiplier and dividend multiplier
See following page for explanation.
http://help.yahoo.com/help/us/fin/quote/quote-12.html

IMPORTANT NOTE: Historical dividend is also adjusted by split multiplier and dividend multiplier

CSV file for historical price can be retrieved by (SPY as example)
http://ichart.finance.yahoo.com/table.csv?s=SPY

HTML page for historical price
http://finance.yahoo.com/q/hp?s=SPY

Wednesday, November 02, 2005

Can people short in an IRA account?

The answer is NO.
Reason (adapt from http://invest-faq.com/articles/ret-plan-trad-ira.html)
The restriction comes from the combination of the following three facts. First, the law governing IRAs says that if any part of an IRA is used as collateral, the entire IRA is considered distributed and thus subject to income tax and penalties. Second, the rules imposed by the Federal Reserve Board et al. say that short sales have to take place in a margin account. Third and finally, margin accounts require that you pledge the account as collateral. So if you try to turn an IRA into a margin account, you'll void the IRA; but without a margin account, you can't sell short.

Monday, October 31, 2005

How to get information about land

Find the website for county assessor's office. Then look for what you need.
For Santa Clara county, it's at http://www.sccgov.org/ari

How to find information about a person, address, or phone number

The following website is exellent:
http://www.reversephonedirectory.com/

Monday, October 24, 2005

Verizon DSL conflicts with NetBeans javadoc help

Cause : Motive SmartBridge (installed with Verizon support center) take over ALT-F1 globally.
Solution : uninstall Verizon support center.

See following page about Motive SmartBridge
http://www.intelliot.com/blog/archives/2004/06/05/motive-smartbridge/

Thursday, October 06, 2005

FILE privilege for mysql

FILE privilege can only be granted globally (using ON *.* syntax).
Same for the following privileges
PROCESS, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SHOW DATABASES, SHUTDOWN, and SUPER privileges

Viewing Javadoc in Eclipse

Eclipse IDE Javadoc Configuration Tutorial

Tuesday, October 04, 2005

Tax for employee stock option

There are several types of stock incentive
1. Incentive stock option
2. Restricted stock
A good article about incentive stock option http://www.fairmark.com/execcomp/iso.htm
For restricted stock, see http://www.rowbotham.com/stock_options/restricted_stock.htm

Key points
For incentive stock option,
1. No tax until exersize. No tax for receiving, vesting ISO.
2. When exercize, no REGULAR tax. There is tax for AMT, difference between market price and exercise price recognized as ordinary income
3. When sell, if qualifying for special holding requirement (>1 years after exercize, >2 years after receiving ISO), For REGULAR tax, taxed as capital gain with exercize price as tax basis. For AMT, taxed as capital gain with market price when exercising as tax basis.
4. When sell, if qualified as Qualified Small Business Stock, half the gain recognized as capital gain for REGULAR tax. 7% of the excluded gain need to be reported for AMT.

---

Instruction for AMT, for 6251

Line 12 - Qualified Small Business Stock
If you claimed the exclusion under section 1202 for gain on qualified small business stock held more than 5 years, multiply the excluded gain (as shown on Schedule D (Form 1040)) by 7% (.07). Enter the result on line 12 as a positive amount.

Line 13 - Exercise of Incentive Stock Options
For the regular tax, no income is recognized when an incentive stock option (ISO), as defined in section 422(b), is exercised. However, this rule does not apply for the AMT. Instead, you generally must include on line 13 the excess, if any, of:
1. The fair market value of the stock acquired through exercise of the option (determined without regard to any lapse restriction) when your rights in the acquired stock first become transferable or when these rights are no longer subject to a substantial risk of forfeiture, over
2. The amount you paid for the stock including any amount you paid for the ISO used to acquire the stock.
Note. Even if your rights in the stock are not transferable and are subject to a substantial risk of forfeiture, you may elect to include in AMT incomethe excess of the stock's fair market value (determineed without regard to any lapse restriction) over the exercise price upon the transfer to you of the stock acquired through exercise of the option. You must make the election by the 30th day after the date of the transfer. See Pub. 525, Taxable and Nontaxable Income, for more details.
If you acquired stock by exercising an ISO and you disposed of that stock in the same year, the tax treatment under the regular tax and the AMT is the same, and no adjustment is required.
Increase your AMT basis in any stock axquired through the exercise of an ISO by the amount of the adjustment. Keep adequate records for both the AMT and regular tax so that you may figure your adjustment. Seethe instructions for 16.


Topic 427 - Stock Options http://www.irs.gov/taxtopics/tc427.html

URL Redirection

Simple way to do page redirection is
<html>
<head>
<meta http-equiv="refresh" content="5; URL=http://my_new_web_address">
</head>
</html>

But user will notice the transition page

For more complicated see a good article about this is at HOWTO: Common URL Redirection Techniques for IIS, Summary

One of ways mention in the article is to use 302 redirect response. See for example:
Working with 301 and 302 Redirects
302 Redirect

Friday, September 30, 2005

Employee Invention

CALIFORNIA LABOR CODE (http://www.leginfo.ca.gov/.html/lab_table_of_contents.html)
DIVISION 3 Article 3.5

2870. (a) Any provision in an employment agreement which provides
that an employee shall assign, or offer to assign, any of his or her
rights in an invention to his or her employer shall not apply to an
invention that the employee developed entirely on his or her own time
without using the employer's equipment, supplies, facilities, or
trade secret information except for those inventions that either:
(1) Relate at the time of conception or reduction to practice of
the invention to the employer's business, or actual or demonstrably
anticipated research or development of the employer; or
(2) Result from any work performed by the employee for the
employer.
(b) To the extent a provision in an employment agreement purports
to require an employee to assign an invention otherwise excluded from
being required to be assigned under subdivision (a), the provision
is against the public policy of this state and is unenforceable.



2871. No employer shall require a provision made void and
unenforceable by Section 2870 as a condition of employment or
continued employment. Nothing in this article shall be construed to
forbid or restrict the right of an employer to provide in contracts
of employment for disclosure, provided that any such disclosures be
received in confidence, of all of the employee's inventions made
solely or jointly with others during the term of his or her
employment, a review process by the employer to determine such issues
as may arise, and for full title to certain patents and inventions
to be in the United States, as required by contracts between the
employer and the United States or any of its agencies.



2872. If an employment agreement entered into after January 1,
1980, contains a provision requiring the employee to assign or offer
to assign any of his or her rights in any invention to his or her
employer, the employer must also, at the time the agreement is made,
provide a written notification to the employee that the agreement
does not apply to an invention which qualifies fully under the
provisions of Section 2870. In any suit or action arising
thereunder, the burden of proof shall be on the employee claiming the
benefits of its provisions.

Avoiding Legal Problems with Employees In California

Monday, September 05, 2005

Configure JDBC datasource for Tomcat 5.5.*

1. Do not modify server.xml.
2. Copy JDBC driver, dbcp and collections jars to common/lib.
3. Add the following to your web.xml in your application:


<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/dbTest</RES-REF-NAME>
<res-type>javax.sql.DataSource</RES-TYPE>
<res-auth>Container</RES-AUTH>
</RESOURCE-REF>
</WEB-APP>

4. Create new context.xml under META-INF and paste the following:

<context reloadable="true" path="/dbtest" debug="5" crosscontext="true" docbase="dbtest">
<logger timestamp="true" suffix=".txt" prefix="localhost_realtorApp_log." classname="org.apache.catalina.logger.FileLogger">
<resource username="joe" password="XXXX" url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true" type="javax.sql.DataSource" auth="Container" name="jdbc/dbTest" driverclassname="com.mysql.jdbc.Driver" maxwait="5000" maxactive="4" maxidle="2">
</context>

Sunday, August 07, 2005

How to keep the LaTex compilation window open in WinEdt

At Menu -> Options -> Execution Modes, Click 'BATCH' Button

or

Menu -> Options -> Configuration Wizard -> Start -> Tex Configuration Wizard -> 'BATCH Execution Mode'

Thursday, August 04, 2005

Extract wav from wmv using Windows Media Format SDK

Modify the AudioPlayer example in the Media Format SDK 9.
There are several things needed to be done:
1. Call IWMReaderAdvanced::SetUserProvidedClock(TRUE) so that the program can use IWMReaderAdvanced::DeliverTime to request the reader to process the stream as fast as possible (ignore actual time)
2. Call IWMReaderAdvanced::DeliverTime in OnTime call back to request the reader process more data
3. Select the audio stream. Get IWMProfile interface by QueryInterface on IWMReader interface. Get the number of streams by IWMProfile::GetStreamCount. Get config (IWMStreamConfig) of each stream by IWMProfile::GetStream. Get the stream type by IWMStreamConfig::GetStreamType. Look for stream with type WMMEDIATYPE_Audio. Get stream number using IWMStreamConfig::GetStreamNumber. Use IWMReaderAdvanced::SetManualStreamsSelection(TRUE) to enable manual stream selection. Use IWMReaderAdvanced::SetStreamsSelected to select the audio stream.
4. Modify OnSample function to write the wav samples to a file.
5. Remove unnecessary part of the program

Note: AudioPlayer sample use asynchronous reader (IWMReader). It might be easier to use the synchronous reader (IWMSyncReader) obtained by WMCreateSyncReader.

Wednesday, July 20, 2005

Adding JDK Javadoc to NetBeans IDE

Download JDK documentation from http://java.sun.com/j2se/1.5.0/download.jsp
Unzip the zip file to the JDK directory
In NetBeans IDE
1. Choose Tools > Java Platform Manager from the main window.
2. Select the platform to which you want to add Javadoc in the left panel of the dialog box.
3. In the Javadoc tab, click Add ZIP/Folder and specify the location of the Javadoc files.
4. Click Close.

Adding CLASSPATH in NetBeans

In the Projects window, right-click the project node and choose Properties.
Click Libraries in the left panel of the Project Properties dialog box.
Adding library path in the right panel.

Wednesday, July 13, 2005

Setup Tomcat with Apache

Requires following steps
1. install JDK ,
j2se 5.0 http://java.sun.com/j2se/1.5.0/index.jsp

2. install Apache http server
Apache 2.0 http://httpd.apache.org/download.cgi

3. install Tomcat
Tomcat 5.x http://jakarta.apache.org/tomcat/index.html
Be sure to use j2se 5.0 for Tomcat 5. Otherwise a compatibility package needs to be installed.
Without compatibility package, tomcat 5 will not run with earlier version of j2se.

Compatibility package:
http://ftp.wayne.edu/apache/jakarta/tomcat-5/v5.5.9/bin/jakarta-tomcat-5.5.9-compat.zip
unzip it can copy to Tomcat directory

After installation, if everything is right, following pages can be viewed:
http://localhost:8080/
http://localhost:8080/jsp-examples/

4. install a connector, in this case JK
http://jakarta.apache.org/site/downloads/downloads_tomcat-connectors.cgi
copy mod_jk-1.2.14-apache-2.0.54.so to the ${apache_home}/modules, rename it to mod_jk.so.

5. configure and test

Add following line to ${tomcat_home}/conf/server.xml, in the <Engine> section,
<Listener className="org.apache.jk.config.ApacheConfig" modjk="C:/Program Files/Apache Group/Apache2/modules/mod_jk.so" />

Create a file ${tomcat_home}/conf/jk/workers.properties
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13

Add a line to the end of ${apache_home}/conf/httpd.conf
Include "C:/Program Files/Apache Software Foundation/Tomcat 5.5/conf/auto/mod_jk.conf"

Reference:
Using Apache HTTP with Apache Tomcat(http://johnturner.com/howto/apache-tomcat-howto.html)

Server Configuration Reference
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/index.html

For application deployment (Application directory structure setup)
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/host.html#Automatic%20Application%20Deployment

Jakarta Tomcat Connector - Apache HowTo
http://jakarta.apache.org/tomcat/connectors-doc/howto/apache.html

Jakarta Tomcat Connector - Workers HowTo
http://jakarta.apache.org/tomcat/connectors-doc/howto/workers.html

Wednesday, May 18, 2005

USB-400 Wireless Adapter

I finally get my USB Wireless Adapter working properly without the original installation disk and documentation.

The adapter has a model name USB-400. There is no manufacturer name.
Finally, I found the manual, driver & utility can be download from
http://www.syntaxgroups.com/support/downloads.php

Wednesday, April 06, 2005

Install TAO

Prerequirement:
PETSC must be installed

edit : include/tao_sys.h
search for the line: extern int PetscLogInfo(void *,const char*,...);
change to: extern int PetscLogInfo(void *,const char[],...);
This is because the prototype in tao_sys.h is different from that in
petsclog.h of PETSC

Run the following commands

export TAO_DIR=`pwd`
export BOPT=O_c++
export PETSC_ARCH=cygwin-intel
make all
make tao_testexamples >& examples.log

check for errors in examples.log

Install PETSC on Intel Microsoft Windows 2000

This note describes how to install PETSC on a machine with following specs:

CPU: Pentium 4
OS: Windows 2000
Compiler : Intel Compiler
Math : Intel MKL
MPI : MPICH
Shell: cygwin

Prerequirement:
install MKL: MKL should be in C:\Program Files\intel, with directory name MKL70, MKL61 or MKL, make sure ia32/mkl_c_dll.lib should be the only one library needed
install MPICH: MPICH should be in C:\Program Files\MPICH

edit :

search in *.py for 'C:\Program' and 'cygdrive', change drive letter for your pre-installed software

edit : ${PETSC_DIR}/makefile
search for the FIRST "MINFO_", change MINFO_ to ${MINFO}
remove the next few lines until line: -@$(RM) MINFO MINFO_
change this line to: -@$(RM) MINFO
This is because unknown problem with sed

environment:
adding the MKL DLL directorty to PATH
before entering cygwin, run vcvars32 first to set the environment

entering cygwin
go to root of PETSC
run following commands:
PETSC_DIR=`pwd`; export PETSC_DIR
config/configure.py --with-fc=0 -with-vendor-compilers=intel
make BOPT=O_c++ all
make BOPT=O_c++ test
NOTE: configure.py will use flag -TP for compiling both .c and .cpp files.

If everything is right, configure.py should automatically locate pre-installed
MKL and MPICH. The end of ${PETSC_DIR}/configure.log should look like
following:


Compilers:
C Compiler: /cygdrive/c/users/xw/work/petsc-2.2.1/bin/win32fe/win32fe icl --nodetect -MT
C++ Compiler: /cygdrive/c/users/xw/work/petsc-2.2.1/bin/win32fe/win32fe icl --nodetect -MT -GX -GR -TP
PETSc:
**
** Configure has determined that your PETSC_ARCH must be specified as:
** ** PETSC_ARCH: cygwin-intel
**
**
** Configure has determined that your PETSC_DIR must be specified as:
** ** PETSC_DIR: /cygdrive/c/users/xw/work/petsc-2.2.1
**
** Please make the above changes to your environment or on the command line for make.
**
BLAS/LAPACK: /cygdrive/c/Program\ Files/Intel/MKL70/ia32/lib/mkl_c_dll.lib
MPI:
Type: Default MPICH install location (C:\Program Files\MPICH with MS compatible SDK
Version: 1.2
Includes: ['/cygdrive/c/Program\\ Files/MPICH/SDK/include']
Library: ['/cygdrive/c/Program\\ Files/MPICH/SDK/lib/mpich.lib', 'ws2_32.lib']
Python Configure Actions
These are the actions performed by configure on the filesystem
-----------------------------------------------------------------
PETSc:
Build : Set default architecture to cygwin-intel in bmake/variables
Build : Set default optimization to g in bmake/common/bopt_
File creation : Generated list of jobs for testing in bmake/cygwin-intel/jobs
File creation : Generated list of jobs for testing in bmake/cygwin-intel/ejobs
File creation : Generated list of jobs for testing in bmake/cygwin-intel/rjobs
File creation : Created bmake/cygwin-intel/configure.py for automatic reconfiguration
Framework:
Substitution : bmake/config/rules.in was substituted to produce bmake/cygwin-intel/rules
Substitution : bmake/config/packages.in was substituted to produce bmake/cygwin-intel/packages
Substitution : bmake/config/variables.in was substituted to produce bmake/cygwin-intel/variables
File creation : Created configure header bmake/cygwin-intel/petscconf.h
File creation : Created C specific configure header bmake/cygwin-intel/petscfix.h

How to show tootips of a toolbar in a dialog window?

It is easy to add a toolbar to a dialog window. However, it takes some effort to make the tooltips of the toolbar to work. Here are the steps needed to be taken.

1. Add the following line to the message map in the header file of the dialog box

afx_msg BOOL OnToolTipText(UINT nID, NMHDR* pNMHDR, LRESULT* pResult);

2. Add the following line to the cpp file of the dialog box

ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipText )

3. Add following line to InitDialog()

EnableTooltips();

4. Add the following function


BOOL CConfBrowser_MFCDlg::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
UINT nID =pNMHDR->idFrom;
if (pTTT->uFlags & TTF_IDISHWND)
{
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
}
if (nID)
{
pTTT->lpszText = MAKEINTRESOURCE(nID);
pTTT->hinst = AfxGetResourceHandle();
return(TRUE);
}
return(FALSE);
}