Tuesday, September 07, 2010

Laptop Performance vs. Network Drive

Symptom: When working from home using a company laptop, ever notice that the corporate laptop appears to be much slower on your home network? Well, I have had this problem for a while. After a closer look, I found whenever I switch to Windows Explorer or trying to open a file, it will take almost a minute for it to showup.

Root Cause: In my case, I found out the root cause is actually a bunch of network drives that are causing this performance problem.
There are 4 network mapped drives on my laptop which access various resources on intranet. Some are setup by IT so that they will be mapped whenever you boot you computer on company intranet. However, at home, connection to intranet is slow or non-existent. Whenever you make Windows Explorer visible or showing a File dialog, Windows explorer will try to map all of them one by one. That is, the more network drives you have, the longer you have to wait until Windows decide to give up on reconnecting these network drives.

Solution: I end up created a VB script to batch start/stop the mapping. At home with limit access to internet, I will run the scripts to stop all the mapped drives. At work, I will run the script to start the mapping.

The vb script to stop network drive:
Set objNetwork = CreateObject("WScript.Network")
On Error Resume Next
objNetwork.RemoveNetworkDrive "X:", "True"
objNetwork.RemoveNetworkDrive "Y:", "True"
objNetwork.RemoveNetworkDrive "Z:", "True"

To start network drive:
Set objNetwork = CreateObject("WScript.Network")
On Error Resume Next
objNetwork.MapNetworkDrive "X:" , "[your URI]"
objNetwork.MapNetworkDrive "Y:" , "[your URI]"
objNetwork.MapNetworkDrive "Z:" , "[your URI]"

Friday, September 03, 2010

What's in a RIA Software Engineer's Tool Chest

Major Power Tools
  • Microsoft Visual Studio
  • Adobe Flex Builder, Flash Builder
  • Adobe Coldfusion Builder
  • SQL Server Management Studio
Browsers
  • IE
  • FireFox
  • Google Chrome
Eclipse Plugins

Firefox Plugins
  • Firebug
  • Html Validator
  • Screengrab: take screenshots of browser content (including Flash)
  • YSlow
  • Web Developer

Free or really affordable utilities
  • Data Dictionary Creator: manage and generate data dictionary
  • Service Capture: capture HTTP traffic in/out of local computer, with built-in parser of Flash Remoting content
  • Fiddler: capture HTTP traffic, well known in .NET community
  • JSON Viewer: all you can ask for to navigate, search, format JSON data string
  • VNC: remote desktop
  • Tortois SVN, CVS, GIT: version control with Windows Explorer integration
  • Tour De Flex: Air application showcasing Flex controls and sample code
  • Skype: IM, talk, video conference, share desktop, ...
  • Google Desktop: search code, design document with ease
  • GIMP: free replacement for Photoshop
  • Sysinternals: a group of Windows Utilities now owned by Microsoft. Here are a few of my favorites:
    • Process Explorer: advance task manager, mostly used to search for locked resources
    • Port Mon: serial port traffic analyzer
    • Autoruns: manage autorun programs that can start through various mechanisms
  • Depends: Dependency Walker
  • WinMerge: graphical diff, can be easily integrated with Tortoise clients

Online Resources in Browser Bookmarks
  • Google Code Search: search open source code
  • Google Analytics: keep tab on web site usage
  • Stackoverflow: ask questions, search for answers, and answer some questions. Occasionally get job offers due to your answers here
  • EETimes: resource on embedded, semiconductor development
  • TechCrunch
  • DZONE: daily digest of tech blogs similar to TechCrunch
  • ScottGu's Blog: MSFT VP of several .NET products
  • MIX: Video, PPT of past conference
  • PDC: Video, PPT of past conference
  • GOOGLE IO: Video of past conference
  • BeanStalk: online SVN server
  • Github: onlien GIT server
  • Gist: code snippet management
  • CFLib.org: Coldfusion library

Open Source Software
  • FlexLib: Flex controls
  • AS3Core: Actionscript 3 utilities
  • PureMVC: MVC framework, popular in Flex community
  • Cairngorm: official MVC framework in Flex community
  • Report.NET: .NET PDF library
  • ZedGraph: .NET chart library
  • SQLite: light-weight database, popular in embedded community
  • NUnit: .NET unit testing framework
  • FlexUnit: Flex unit testing framework
Icons
  • Java Look and Feel Graphics Repository: official JAVA icon set
  • Visual Studio Image Library: came with Visual Studio Installation
  • Web Application Icons from WebAppers.com
  • famfamfam.com

Thursday, September 02, 2010

Flex Builder - TODO, FIXME in "Tasks" view

Here is a plugin that adds support for TODO comments in "Tasks" view.
http://www.richinternet.de/blog/index.cfm?entry=911D4B57-0F0D-5A73-AF6F4D4D04099757

It was created for Flex Builder 2 in 2006, but I tested, it also works for Flex Builder 3.

Here is link to the request on Adobe's JIRA: FlexBuilder should parse //TODO comments into the normal Task panel . I have voted for this issue.

However, Dirk obviously did a good job in his plugin, such that Adobe decided to defer and closed the issue!?

Wednesday, August 25, 2010

Import Android Samples into Eclipse

I am trying to open Android samples in Eclipse (with ADT installed). At first, it seems to be a tedious task, trying to import every single project. Then, I found out that ADT already has a shortcut for importing samples. Just go File > New Android Project. In the "New Adroid Project" dialog, select the Build Target, then check "Create project from existing sample". Now, in the dropdown below select the project you want to import. It is much simpler than I thought.



Well, of course, it would be even better, if the sample projects have Eclipse project in them. That will save me even more time.

Wednesday, August 18, 2010

SQL Scripts for CLR Assemblies

Here are SQL Scripts for CLR assemblies on Microsoft SQL Server.

Assumptions: assembly's name: "SQLCLR.dll".In the dll, you have an aggregate function: "ConcateAll" which concatenate all string. The dll is in database server's c:\temp directory.

To enable CLR on SQL Server:


To clean up (remove the CLR function and assembly from database)


To upload assembly to SQL Server


Create aggregate function based on CLR assembly


Grant execution permission to user

Monday, July 26, 2010

MS SQL Column Alias

T-SQL used in Microsoft SQL Server seem to have very limited support for column alias. If you have a complex calculated column that you want to re-use in GROUP, SELECT or another expression, it will be desirable to use alias to reference the same definition everywhere so that we can have a clear and easier to understand SQL statement.


Here is an article that is very helpful in this matter: Avoid Transact-SQL's Column Alias Limitations

Key points:
  • MS SQL only allow alias in SELECT and ORDER BY
  • Use sub-query, can help in some cases to re-use column alias

Thursday, July 15, 2010

Coldfusion web services call return error: java.lang.NullPointerException

Turns out Coldfusion web services return data may contain pointer, and the receiving side will try to interpret that pointer. Once we commented out the offending data (a 2D array) in return, the error is gone.

Wednesday, July 14, 2010

DELL Quickset for Latitude E-Family

Just got a new Dell Latitude E6510 laptop. However, cannot find the familiar Dell Quickset on it.

After a couple of days' casual research, I finally found the answer: Dell Control Point is the new Quickset for Latitude E-Family.

As a side note, I like E6510.
Pros:
  • Fast
  • Bright screen
  • Nice keyboard: backlight, good touch
  • Multi-touch, allow pinch zoom, rotations, and other gesture
  • ... more
Cons: none so far.

Wednesday, July 07, 2010

Syntax Highlighting on Blogger - Gist

Here is another way to paste code into blogger with nice syntax highlighting.
  1. Go to http://gist.github.com
  2. Past the code you want to post
  3. Copy the embed tag
  4. Go back to blogger, and select "Edit Html"
  5. Paste the embed tag into your post
Below is the example source code using this tag: <script src="http://gist.github.com/467670.js?file=gistfile1.sql"></script>




A potential drawback of this approach might be the stability of github as a company. In a downturn, it may shut down with very short notice.

Compare to using SyntaxHighlighter, personally, I think this approach is way better:
  1. No setup required (in a previous post I documented how to setup syntaxhighlighter for blogger, it took me half an hour to setup everything correctly. Now with gist, there is zero setup required );
  2. Faster to create code snippet in a post;
  3. Supports more languages;
  4. No need to worry about pasting XML, HTML, or other special characters;


To paste script like below used to require replacing '<' with &lt; and '>' with &gt; manually. Now is simply copy paste without any manual changes:

Flex Builder Error 1046: "Type was not found or was not a compile-time constant"

Problem:
While editing a big .as file in Flex Builder 3, the compile is broken suddenly. Got this error:
1046: Type was not found or was not a compile-time constant: ?????.


Cause:
Seems like Flex editor tend to wrongly remove import statement at the top of .as file without user consent.

Solution:
Disable Flex Builder feature:
Windown > Preferences > Flex > Editors > ActionScript Code, uncheck "Remove unused imports when organizing"

Tuesday, June 29, 2010

ColdFusion Builder Error: "Unhandled event loop execution"

Environment: Eclipse 3.5, ColdFusion Builder Plugin, Aptana

Problem:
Whenever I open a Coldfusion file, will see error "Unhandled event loop exception." followed by a dialog: "An error has occured. See error log for more details. CFMOutlinePage_0".

Cause:

Turns out CF Builder is using Aptana which conflict with the lastest Aptana.

Solution:
Disable Aptana:
  • Disable Aptana: Windows -> Preferences -> General -> Startup and Shutdown, uncheck all Aptana plugins;
  • Disable Aptana Update: Windows -> Preferences -> Install/Update -> Available Software Sites, disabled all Aptana sites;
  • Restart Eclipse using the "-clean" command line, and the problem seems to be fixed now.
Another riskier solution is to uninstall Aptana Studio from Eclipse.
  • Copy current Eclipse directory for backup;
  • Help > About Eclipse > Installation Details > Installed Software > Aptana Studio > Uninstall
More Info:
---------------Detailed Error Log-------------------------
eclipse.buildId=
java.version=1.6.0_20
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product -clean


Error
Tue Jun 29 10:45:04 PDT 2010
Unhandled event loop exception

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NoSuchFieldError: EditorUpdaterThread_0)
at org.eclipse.swt.SWT.error(SWT.java:3884)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3885)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3506)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
Caused by: java.lang.NoSuchFieldError: EditorUpdaterThread_0
at com.adobe.ide.editor.cfml.EditorUpdaterThread.createDelayedRefreshJob(EditorUpdaterThread.java:340)
at com.adobe.ide.editor.cfml.EditorUpdaterThread.access$1(EditorUpdaterThread.java:338)
at com.adobe.ide.editor.cfml.EditorUpdaterThread$1.run(EditorUpdaterThread.java:265)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
... 22 more

-------------Screenshot of the error dialog--------------------------------------

Thursday, June 24, 2010

Visaul Studio Strong Name Error - Importing key file "X.pfx" was canceled

Problem:
Getting a new computer, so I installed fresh Visual Studio 2010, and checked out source code from SVN. Then I got the following errors:

Cannot import the following key file: X.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_F...


Importing key file "X.pfx" was canceled
Solution:
Run this command line:
sn -i X.pfx VS_KEY_F...

Wednesday, June 23, 2010

Flex Compiler Error - Could not resolve * to a component implementation

While extending MX control ComboBox, I am trying to alter it's property.

<mx:dropdownfactory>
<mx:component>
<mx:tree change="outerDocument.updateLabel()" height="200" allowmultipleselection="{outerDocument.allowMultipleSelection}" showroot="{outerDocument.showRoot}" showdatatips="true" datatipfield="{outerDocument.labelField}">
</mx:tree>
</mx:component>
</mx:dropdownfactory>

I got the compiler error as stated in the tile. Turns out I should refer to the property using my custom control's own name space. So the code should be like this:

<local:dropdownfactory>
<mx:component>
<mx:tree change="outerDocument.updateLabel()" height="200" allowmultipleselection="{outerDocument.allowMultipleSelection}" showroot="{outerDocument.showRoot}" showdatatips="true" datatipfield="{outerDocument.labelField}">
</mx:tree>
</mx:component>
</local:dropdownfactory>

SQL 2005 on Windows XP SP3 - MSXML6 Error

Problem:
With a fresh Windows XP SP3, I cannot install SQL 2005. The error message in log file is:
Property(S): SupportedOSMessage = Installation of this product failed because it is not supported on this operating system. For information on supported configurations, see the product documentation.
Property(S): ShortCutText = MSXML 6 Service Pack 2 (KB973686)
Property(S): DialogTitle = MSXML 6 Service Pack 2 (KB973686) Setup
Property(S): ProductName = MSXML 6 Service Pack 2 (KB973686)
Property(S): ShortName = MSXML 6 Service Pack 2 (KB973686)
Property(S): WrongPackage = This MSXML6 Service Pack 2 (KB973686) package is not supported on the current processor type.
Property(S): DialogPatchTitle = MSXML 6 Service Pack 2 (KB973686) Patch
Property(S): SystemFolder = C:\WINDOWS\system32\
...
MSI (s) (04:A8) [09:38:47:725]: Product: MSXML 6 Service Pack 2 (KB973686) -- Configuration failed.

MSI (s) (04:A8) [09:38:47:725]: Windows Installer reconfigured the product. Product Name: MSXML 6 Service Pack 2 (KB973686). Product Version: 6.20.2003.0. Product Language: 1033. Reconfiguration success or error status: 1603.
Solution:
Luckily, I am not the first one who saw this problem. This problem seems to be around for a while now. There is a nice Microsoft KB article for this exact problem, and the solution is to use "Windows Installer CleanUp utility" to remove existing MSXML then install SQL 2005.

And, IT WORKS!!

Reference: MSKB 968749 http://support.microsoft.com/kb/968749

Monday, June 07, 2010

MSDN Library is Gone in Visual Studio 2010

I consider this another major setback in Visual Studio 2010.

Visual Studio 2010 come with a help system that is the worst since Visual Studio 2002.

Pros:
  • web-based, can be views in IE, as well as FireFox;
  • Encourage the use of better search engines like Google?
Cons:
  • No auto-complete search box;
  • Search result is worse than Google;
  • Left pane only has three fixed positions, cannot be resized or hidder;
To compensate the lack of auto-complete, I have stopped using my local help system and starting to use Google as my MSDN document explorer which did an excellent job.

Monday, May 10, 2010

Google Lost Touch with Users

Recently, Google made some major changes without giving user an option to use the old style.

I do not like their changes, mainly the bar on the left. It is duplicate of the bar on the top which I'm fine with.

Now, with the bar on the left, waste huge amount of space beneath it, I am forced to constantly scroll my browser horizontally to see the full content.

I'd rather to see ads fill that space. Then I know this is a decision driven by commercial interest.

Now, with those seemingly useless links which is neither good for me nor Google, I am completely puzzled.

How can I turn this sidebar off? Try a "GOOGLE SEARCH".

Thursday, May 06, 2010

Dynamically Hide Cells in Flex DataGrid

Goal: Control visibility of controls in Flex DataGrid

Problem:
Control of cells' visibility in Flex DataGrid turns out to be pretty tricky. If you simply use inline item renderer and bind it's visibility attribute to a data provider, it won't work.

Why:
Fortunately, Flex is open source. So, we can dig a little deeper into why it does not work.
  1. Look at SDK 3.2.0: DataGridBase.as, line 1073 will show that Flex SDK will actually set the renderer to visible after set "data" property of the control.
  2. Also, the SDK may decide to hide the cell when it sees fit in various situations;
So, it is not desirable to control visibility directly. You are fighting with the SDK.

Solution(s):
Solution 1: Use a container as item renderer, and embed your control inside the container.
Pros: Quick and easy to implement. An added benefit is that you can control cell layout;
Cons: As all the Flex text book will stress: using too many containers is very BAD for performance! How bad? A 20X20 DataGrid may take at least 5 seconds to render!

Solution 2: Create custom control based on the control you want to use in the cell. And manage a new "forceHide" attribute, which will cooperate with the original "visible" attribute to decide a control's visibility. Please see the sample code below. Some details are missing, but you get the idea.

...
protected var _forceHide:Boolean = false;
/**
* visible by set method
*/
protected var _setVisible:Boolean = false;
/**
* If set, this control will not be visible. It will overwrite visible property.
* DataGrid tend to manipulate visible directly, we can only use
* this extra field to force hide control even if DataGrid decides
* that it can be shown.
*/
public function set forceHide(value:Boolean):void {
_forceHide = value;
setVisible(_setVisible);
invalidateProperties();
}
override public function setVisible(value:Boolean, noEvent:Boolean=false):void {
//save desired settings
_setVisible = value;
//forceHide can mask out change request
super.setVisible((!_forceHide) && value, noEvent);
}
...

Other Thoughts:
How about "CallLater"? It turns out to be a bad idea. As stated before, Flex SDK may want to hide some controls. If your "CallLater" set a control's visible to true, when Flex SDK think it is invisible, you may see some ghost controls hanging around.

Thursday, April 29, 2010

Coldfusion Query of Queries (QoQ) Support

QoQ is convenient, but also poorly documented. I cannot find any official Adobe documentation with details about its features and limitations. It's features changes from version to version, usually only expanding (which is a good thing). There are also many bugs, and weird restrictions.

I guess Ben Forta's books rarely touched this topic for a reason.

So generally, I can only test what can be done by trial and error, and frequently find out that although it works on my computer, but will fail in another CF host due to difference in CF server version.

A summary of what can and cannot be done in CF QoQ (aka In Memory Query).
1. Data size: recommended 5,000 - 50,000 rows, subject to computer memory size;
2. join: inner join of two tables using WHERE clause
Can:
join two tables
inner join through a WHERE clause
cross join
Cannot:
use these clauses: LEFT JOIN, RIGHT JOIN, OUTER JOIN
join more than two tables
3. union: supported, but can be difficult to use due to strict type matching requirements;
4. dot notation: allow access to query in a structure through dot notation;
5. conditional operators: IS, IS (NOT) NULL, >, >=, <>, !=, <, <=, ==, BETWEEN, IN, LIKE
6. case sensitivity: it is case sensitive
7. other supported T-SQL keywords: GROUP, ORDER, DISTINCT, AVG, COUNT,

Beyond QoQ:
1. features from CFQuery tag: maxRows (equivalent to TOP), blockFactor
2. features from CFOutput, CFLoop: startRow, maxRows (combined equivalent to LIMIT)