Wednesday, April 19, 2017

requirejs loads JavaScript files

RequireJS loads all code relative to a baseUrl.

Requirejs encourages using module IDs instead of URLs for script tags, it loads all codes relative to baseUrl. RequireJS also assumes by default that all dependencies are scripts, so it does not expect to see a trailing ".js" suffix on module IDs.

However, there may be times when you do want to reference a script directly and not conform to the "baseUrl + paths" rules for finding it. For instance, we want to add cache bust to the URL for specific js files rather than all js files (through urlArgs config option).

If a module ID has one of the following characteristics, the ID will not be passed through the "baseUrl + paths" configuration, and just be treated like a regular URL that is relative to the document:
  • Ends in ".js".
  • Starts with a "/".
  • Contains an URL protocol, like "http:" or "https:".
One example is:
var i18nModule = 'i18n!/scripts/customize/nls/lang.js?v=4.0';
require([i18nModule], function(obj) {
    // process the loaded file
Above example tells requirejs NOT conform to baseUrl+paths rule, instead load the lang.js file directly using relative path to document (root path). Note that i18nModule variable starts with a "/", and also ends in ".js".

Saturday, April 1, 2017

ESPP tax return

ESPP is a common income for corporate employees. When report tax, it actually has 2 parts.

1.  1099-B which reports the proceeds and cost basis
2.  Form 3922 which reports the adjustment due to ESPP benefits

FMV per share on grant date
FMV per share on exercise date
Exercise price paid per share

Usually the adjustment is MIN( FMV-grant date,  FMV-exercise date) * 15% = Exercise price paid

The part of amount is already reported in W2 and explained in Form 3922, so we need do adjustment the amount for 1099-B form.

For instance, if 1099-B reports proceeds $1000, and cost basis $800, the taxable amount is $200.
However, if 3922 adjustment is $50, the total taxable income is $200-$50 = $150.