Friday, December 19, 2014

Node.JS Error "Cannot find module '...'"

Setting up NodeJS is generally a smooth process. There is one thing need to be taken care of manually: set up environment variable node_modules. This variable must point to the npm global installation location, otherwise you NodeJS application may have problem starting with error message like this:
Error: Cannot find module 'XXX'

In Windows, the easiest way is to go Computer > Properties > Advanced System Settings > Environment Variables > User Variables > New

After the configuration, need to exit the current command line and start a new one in order to see the environment variable in effect.

Wednesday, November 19, 2014

IIS Error: Cannot write configuration file

Symptom

When trying to change IIS configuration, got this error message:
Filename:
    \\?\C:\Windows\System32\inetsrv\config\applicationHost.config
    Error: Cannot write configuration file

Error Message

Diagnosis

Turns out root cause of the problem is a full C: drive.

Windows Explorer

Solution

Luckily, this is a virtual machine with some spare disk capacity. So it's just a matter of allocating more resource, then extend C: drive.


Wednesday, November 05, 2014

Flex TextArea problem in DataGrid

Problem

Flex 4 TextArea does not take multi-line entry when used as editor in DataGrid.

Solution

Add editorUsesEnterKey="true" attribute to the column with TextArea editor.


P.S.

The solution is straightforward. But the route to finding this solution kind of proves open source or at least show your customer the source code is very important.

I first suspect the enter key is intercepted by DataGrid, but it appears that keydown event is intercepted by DataGrid before the TextArea. Some Googling with various keyword combination did not turn up anything interesting.

Not sure where to start, I added a itemEditEnd event handler to the DataGrid, and set a breakpoint there. After walking through the stack, I saw the following code segment, and thus the solution above pops out. Now I can simply go to documentation of editorUsedEnterKey and make sure this is what I want.

(Code of interest from DataGrid.as)
    /**
     *  @private
     */
    private function editorKeyDownHandler(event:KeyboardEvent):void
    {
        // ESC just kills the editor, no new data
        if (event.keyCode == Keyboard.ESCAPE)
        {
            endEdit(DataGridEventReason.CANCELLED);
        }
        else if (event.ctrlKey && event.charCode == 46)
        {   // Check for Ctrl-.
            endEdit(DataGridEventReason.CANCELLED);
        }
        else if (event.charCode == Keyboard.ENTER && event.keyCode != 229)
        {
            // multiline editors can take the enter key.
            if (!_editedItemPosition)
                return;

            if (columns[_editedItemPosition.columnIndex].editorUsesEnterKey)
                return;

            // Enter edits the item, moves down a row
            // The 229 keyCode is for IME compatability. When entering an IME expression,
            // the enter key is down, but the keyCode is 229 instead of the enter key code.
            // Thanks to Yukari for this little trick...
            if (endEdit(DataGridEventReason.NEW_ROW) && !dontEdit)
            {
                findNextEnterItemRenderer(event);
                if (focusManager)
                    focusManager.defaultButtonEnabled = false;
            }
        }
    }

Thursday, August 21, 2014

Ubuntu LTS 12 on VMWare Player Showing Multiple Columns of Identical Screens

Symptoms

After updating to Kernel 3.2.0.67 and reboot, my screen is showing three columns of duplicated desktop. 

Environment: 

  • VMWare Player 6.0.3
  • Ubuntu: 12.04 LTS, Kernel 3.2.0.67 (post upgrade version, I'm not sure what was the version before my upgrade)
  • The VM image was created way back in a very old VMWare Player, started from Ubuntu 10. It has been kept up-to-date by applying Ubuntu patches and eventually to 12.04 LTS. Turn out this probably was the root cause of all the troubles

Solution

After some Google search and reading up on posts, I was eventually lead to the following thread:
Guest display split into identical panes
Flip to page 2, on post 17 from thellstrom, there is the solution that worked for me. I used solution 1b mentioned in the post, and after reboot, everything is back to normal.

Cause

So, based on the article, root cause of the problem is due to VM created on old version of player with virtualHW version 7. I updated the config file from version 7 to 9, and everything appears to be working now.

Thursday, August 14, 2014

Wednesday, August 13, 2014

Lua in Visual Studio 2013


Build Lua for Windows using Visual Studio 2013 is a very straightforward task.

Project to build lua.exe:
  1. Create Project > Visual C++ > Empty Project
  2. Add Existing Item ...
    • Select all files under src except luac.c
  3. Project Property > All Configurations > Configuration Properties > C/C++ > Preprocessor > Preprocess Definitions, add: _CRT_SECURE_NO_WARNINGS

That is it.

To build luac.exe, simply repeat above steps. When selecting files, select all files, except lua.c.