Saturday, August 17, 2013

Make Custom Fields in Coldfusion Solr Collections not Searchable

How

Here is how I did it, might not be the best way, but it works:

  • Update Solr schema
    • Change custom fields definition to: type: string, indexed: false
    • Comment out all the copyField definitions for the custom fields
  • Purge all Solr collections and reindex all of them
Details of the XML Changes
Changes of custom field definitions
Before:
<field name="custom1"   type="text"   indexed="true" stored="true" required="false" />
<field name="custom2"   type="text"   indexed="true" stored="true" required="false" />
<field name="custom3"   type="text"   indexed="true" stored="true" required="false" />
<field name="custom4"   type="text"   indexed="true" stored="true" required="false" />
After:
<field name="custom1"   type="string"   indexed="false" stored="true" required="false" />
<field name="custom2"   type="string"   indexed="false" stored="true" required="false" />
<field name="custom3"   type="string"   indexed="false" stored="true" required="false" />
<field name="custom4"   type="string"   indexed="false" stored="true" required="false" />
Changes for the copyField definitions
Before:
<copyField source="contents_*"  dest="contents" />
<copyField source="custom*"  dest="contents" />
<copyField source="title"  dest="contents" />
<copyField source="contents_*"  dest="contentsExact" />
<copyField source="custom*"  dest="contentsExact" />

After
<copyField source="contents_*"  dest="contents" />
<!--
<copyField source="custom*"  dest="contents" />
-->
<copyField source="title"  dest="contents" />
<copyField source="contents_*"  dest="contentsExact" />
<!-- 
<copyField source="custom*"  dest="contentsExact" />
-->
Environment
Coldfusion 10

Why


Why do I need to make custom fields not searchable?

Migrating Coldfusion collections from Verity to Solr is never straightforward. See my other post: Solr in Coldfusion 9 for some lessons I learn during migration.

Fast forward to last week (a couple of months after the production servers are migrated), another surprise surfaced. Some search will result in random text that does not appear to be relevant. After some investigation, I finally found out it's due to unexpected behavior of custom fields.

Custom field in Verity was not seem to be searchable. After migration to Solr, the custom fields are indexed and became searchable. It may be a good thing for people who want it to be searchable. But, in my case they were used for storage only, contains database ID and other contents that should not be used for search purpose.

Parting Words

It took me nearly half a day to finally figure out how to do it. Hopefully it can save someone a few hours of frustration. I started by naively changing only custom fields to index: false, and turns out they are still searchable. Google search did not turn up anything helpful, except a few posts asking the exact question I was asking. Finally after exploring the Solr admin pages, and looking at schema of the collections, I found out that they are also copied into searchable fields, and type: text will also trigger analyzer on it.

Tuesday, July 30, 2013

ExtJS multiselect problem when shift click to select entries

Environment

IE  10; ExtJS 4.1

Problem

I am using ExtJS "multiselect" control. When trying to select multiple rows using Shift+Click, I'm getting a messy screen (Figure 1). The data behind the scene is correct, but the look is disturbing. Ideally, it should look like Figure 2. 
Figure 1. Screenshot showing the problem

Figure 2. Screenshot showing the expected behavior

Solution

Solution to this problem is relatively trivial, but not obvious. Just add the following attribute to the multiselect control, you will get behavior like Figure 2. I found the solution by looking up example hosted on Sencha web site, and found the only difference is in this "ddReorder" attribute. Once it's added, the selection behavior is as expected. Drag drop reorder is harmless for what I am working on.
ddReorder: true 

Friday, July 19, 2013

Adobe Flex RSL Error in IE

This is another case which I know the cause and the solution for a problem. But I don't understand why it would cause a problem.

Environment:
  - IE10, Win7, Flash Player 11.8 debugger
  - Google Chrome  28.0 with Flash Player 11.8

Symptom:
  Flex application stopped  working in IE. Always getting this error message: "RSL Error 1 of 2". RSL is short for Runtime Shared Library. Using ServiceCapture, I do see the main SWF loaded, and the first RSL loaded, but no the rest.
  The same Flex application works perfectly in Google Chrome.

Cause:
  In the the IE Security setting, "Enable Protected Mode" is unchecked.


Solution:
  Go to IE > Tools > Internet Options > Security, make sure "Enable Protected Mode" is checked. Then restart IE. Voila, it all works again. In retrospect, I might turned it off when I was trying to set up Selenium test framework.

Question:
  It's still beyond me why "Protected Mode" seems to make IE 10 more compatible. Just a few days back I had another problem with Office Web application due to the exact same cause. An extra IE windows will always popup when I open an Office 2013 application in Excel. The problem is gone after I enabled protected mode.

----
Flex: a RIA web application development framework based on Adobe Flash technology

Tuesday, July 09, 2013

Upgrading Coldfusion 9.0.0 to 9.0.1 with HotFix 2

Instructions from Adobe are not clear or simply wrong sometimes.
Here is actual steps I took:
Environment: Windows XP, CF 9.0.0 Server Installation, IIS

  • Update Coldfusion from 9.0.0 to 9.0.1
  • Apply Cumulative Hot Fix 2 | Coldfusion 9.0.1 (http://helpx.adobe.com/coldfusion/kb/cumulative-hot-fix-2-coldfusion-1.html)
    • Download and extract files:
    • Go to your {ColdFusion-Home}/lib directory and make a backup of lib folder (I just copy and paste the folder in the same place)
    • Apply update JAR file
      • In the ColdFusion Administrator, select System Information page by clicking the "i" icon in the upper-right corner. 
      • In the Update File text box, browse and select chf9010002.jar located under CF901/lib/updates directory. 
      • Click Submit Changes. 
    • Stop ColdFusion instance. 
    • Update CFIDE
      • Go to {CFIDE-HOME} and make a backup of CFIDE folder (I just copy and paste the folder in the same place)
      • Go to extracted CFIDE folder (typically CFIDE-901\CFIDE), copy all files into current CFIDE folder and overwrite existing files
    • Update WEB-INF
      • Go to {ColdFusion-Home}/wwwroot/WEB-INF directory and make a backup of WEB-INF folder (I just copy and paste the folder in the same place)
      • Go to extracted WEB-INF folder (typically CF901\CF901\WEB-INF\WEB-INF), copy all file into the current WEB-INF folder and overwrite existing files
    • Update lib folder (it's already backed up at the begining)
      • Go to extract lib folder (typically CF901\CF901\lib), copy all files (exclude the "updates" folder) into the current lib folder and overwrite existing files
    • Start Coldfusion instance
To Uninstall: 
  • Stop Coldfusion
  • Delete CFIDE, WEB-INF and lib folders, rename the copied folders back to their original name
  • Start Coldfusion

Tuesday, April 30, 2013

Breaking change in Coldfusion 10 vs Coldfusion 9

Here is one breaking change:
  • DeserializeJSON of null value
Test Code to show the change:
result = deserializeJSON('{"test": null}');
writedump(result);
writeoutput(result.test);

In CF9, result.test is string value: "null".
In CF10, the above code will have error, because result.test is "undefined".

Debugging DotNet component on Coldfusion Server

Here is a recipe to setup Visual Studio debugging of remote Coldfusion server's .NET application.

Environment: Visual Studio 2012, Coldfusion 9
Setup:
  1. Coldfusion Server: 
    1. install "Remote Tools for Visual Studio 2012 Update 2"
    2. Start "Remote Debugger Configuration Wizard" and configure accordingly
    3. Start "Remote Debugger" As Administrator
  2. Visual Studio computer:
    1. Click Debug > Attach to Process
    2. In "Qualifier" type the Coldfusion server's computer name
    3. Check "Show processes from all users"
    4. Click "Refresh"
    5. Select "JNBDotNetSide.exe"
    6. Click "Attach"

Done!

To see it in action, set a break point in your code, load a Coldfusion page that invokes your .NET application, Visual Studio debugger should break accordingly.

Wednesday, April 03, 2013

test embedding Skydrive Spreadsheet

Above is an example to embed skydrive document to blog. Only catch? Use the "JavaScript" instead of the "Embed Code" version. It works beautifully, impressive.

Wednesday, March 20, 2013

ExtJS Store Shared Between Multiple ComboBox Controls

Environment: ExtJS 4.1.3, auto loaded store, shared by multiple comboboxes

Problem:
Combobox with auto-complete behaves strangely. Sometimes, the list is obviously filtered down by something else.

Cause:
The same data store instance is shared by multiple combobox on the page. "doQuery" function in the combobox will try to reserve the store's filter that is not created by the combobox itself (see ComboBox.js > clearFilter, and doQuery implementation). This design allows the auto-complete filter of different dropdown pickers to interfere with each other.

Solution:
1. create custom control, then override "doQuery" function to call store.clearFilter()
Pros:
- Clean, reusable design
Cons
- Validation still has cross contamination of conflicting filtering
- In cases you want to preserve an existing filter, this solution need more tweaks or configuration input to make it working

2. Declare store of the combobox using the following style: store: {type: 'myStoreAlias'}, instead of store: 'myStoreName'. This way it will ensure each combobox has their own instance of the store, thus not interfering each other's filtering.
Pros:
- No other hidden surprises lurking around
Cons:
- Pretty much have to abandon the store: 'myStoreName' completely, because in a module design, you just don't know which combobox may live in the same page with another one and using the same store
- Network and memory overhead to maintain multiple copies of the same data

Wednesday, March 13, 2013

Coldfusion Error: "Value can not be converted to requested type."

Symptom: All of a sudden the test cases that worked before, stopped working. Error message is: "Value can not be converted to requested type.". Wasted hours trying to diff and check typos with no avail. Finally, surrender, and Googled the following article published in 2006:

ColdFusion Query Error: Value Can Not Be Converted To Requested Type

http://www.bennadel.com/blog/194-ColdFusion-Query-Error-Value-Can-Not-Be-Converted-To-Requested-Type.htm

So, it is an old problem that never go away. Everything clicks now. Database schema was just updated with a few new columns. "SELECT *" combined with CFQUERYPARAM seems to have some caching issue and everything just messed up from there.

Solution? remove SELECT *, change to use explicit column names. The problem simply goes away for good.

Friday, March 01, 2013

HTML + JavaScript Charting Solutions

  • Ext JS, Example (good for intranet application)
  • d3.js (extremely popular at this moment)
  • Dojo Charting
  • YUI Chart
  • Google Chart (Big down side, at least at this time, is that Google will receive every single data point you want to plot. Not a good thing for any data that requires privacy!)
  • Flotr2
  • Flash charts? lots of good choices there, but not accessible on mobile clients, and in danger of being completely out in a few years?

Tuesday, February 19, 2013

Support JSONP in Coldfusion

Let say you already have a Coldfusion page that serves JSON data to your AJAX web application, now you want to support JSONP from cross domain client call. Here is the code snippet that will do it:

Solr in Coldfusion 9


Some tips for using Coldfusion 9 Solr search:
  • Lesson Number 1: Make sure you review ALL the files under your collections \conf folder, many of them need to be commented out or changed from default values. Here is an incomplete list of what I changed:
    • Commented out words in protwords.txt
    • Deleted content in spellings.txt
    • Updated synonyms.txt, deleted the test words, and added new synonyms based on the vocabulary specific to my application's domain
    • schema.xml:
      • Updated default query operator from AND to OR
    • solrconfig.xml
      • commented out "solr", "rocks" and other similar configurations
    • Enable term highlighting (see http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSe9cbe5cf462523a0-5bf1c839123792503fa-8000.html \), but it's still not quite there. Still looking for a complte solution for this one.
  • In Coldfusion Admin, change Solr buffer limit from default value 40 to 80 (http://bloggeraroundthecorner.blogspot.com/2009/08/tuning-coldfusion-solr-part-1.html)
  • Ensure "Coldfusion 9 Solr Service" is started and set to "Automatic" startup type
  • To access Solr collection from remote Coldfusion servers, 
    • For the remote CF servers: change Solr server name in Coldfsuion Admin, DATA & Service > Solr Server > Solr Host Name
    • For the Solr Host: Allow remote server to have access to its Solr instance. Configure Jetty to listen on all incoming IP address. Coldfusion's default configuration is allow only 127.0.0.1, thus disabling remote CF server's access to it's hosted Solr instance. To change this, just open jetty.xml in {coldfusion home}\solr\ect, and comment out the host line which restricts to listen on 127.0.0.1 only (interestingly, I found this solution from this link: http://helpx.adobe.com/coldfusion/kb/coldfusion-9-limit-access-solr.html, which claims Coldfusion's default configuration is to listen on all ip addressed
  • Web access to Solr admin: http://{Your CF Server Name}:8983/solr/
  • Last and a big one, when you try to update multiple indexes, you will see error like this:
Error_opening_new_searcher_exceeded_limit_of_maxWarmingSearchers4_try_again_later

Stack Trace:
...
org.apache.solr.common.SolrException: Error_opening_new_searcher_exceeded_limit_of_maxWarmingSearchers4_try_again_later

Error_opening_new_searcher_exceeded_limit_of_maxWarmingSearchers4_try_again_later

request: http://localhost:8983/solr/.../update?commit=true&waitFlush=false&waitSearcher=false&wt=javabin&version=1
    at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:424)
    at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:243)
    at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
    at coldfusion.tagext.search.SolrUtils.commitToServer(SolrUtils.java:1024)
    at coldfusion.tagext.search.SolrUtils.addDocument(SolrUtils.java:664)
    at coldfusion.tagext.search.IndexTag.doQueryUpdate(IndexTag.java:929)
    at coldfusion.tagext.search.IndexTag.doStartTag(IndexTag.java:254)
    at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722)


This error will be consistently showing up in production environment with even very light traffic, and became a big show stopper for the usage of Solr collection provided by Coldfusion (does not seem to be a Solr problem, instead a problem of Coldfusion integration problem). 

Root cause seems to be that Coldfusion commits every index update, and causing excessive Solr searcher warming. Combining with misconfigured default Solr configuration, this problem starts to appear for a collection of only a few hundred entries.

In Coldfusion 10, this problems seems like easier to solve by using the newly introduced "autoCommit" attribute, which should always be "no" (i.e. never use the default value). Then I guess configuring the "autoCommit" in solr config file will solve the above problem in Coldfusion 10.

However, production environment that is already in CF 9 is stuck. My solution for it is a combination attack:
    • Manually throttle cfindex update by adding a sleep after every update
    • Wrap try catch block around the cfindex update, then add a longer sleep time in the catch block, and add retry logic to try update again after the sleep
    • Database flag of index entries, this flag will be set only after index is updated successfully. A scheduled CF task will scan this flag to identify missed updates (due to the above error), and try to update index again
The above approach so far allows me to update thousands of indexes without any problem.

Wednesday, October 10, 2012

Downloadify Stopped Working in Google Chrome

Downloadify uses Flash's download functionality to enable client side download. It saves server side roundtrip.  There is also nice user extensions using Downloadify to export ExtJS grid on the client side. HTML 5 does have some limited support of client side download, but it suffers inconsistent support between browsers.

Ok, after all the justification for using it, Downloadify stopped working for Google Chrome recently. And here are the observations:
  • Environment: Windows, Google Chrome is up-to-date
  • Download still works in IE and Firefox;
  • Download only works in Chrome if I'm testing using Intranet URL. But it does not work if the URL looks like Internet address (i.e. http://localhost works, but http://10.10.10.1 won't work);
  • IE, Firefox are on Flash 11.3, and Chrome is running Flash 11.4
Solution:
Not really a solution. It's more like a workaround.
  1. In Chrome address bar type: "about:plugins"
  2. Click on "Details" button to expand into more detailed view
  3. Find "Flash" section, and disable the Flash player 11.4 (something called "PepperFlash"\"pepflashplayer.dll")
  4. Make sure there is another Flash player listed here, which should be Adobe's distribution

Root Cause?
I can only guess. Still not sure why and how to fix it properly.
Turns out Google Chrome has it's own Flash distribution. (Only guessing) It seems to be different from Adobe's official one, and somehow has higher default security settings.

itemId and id in ExtJS

The story: 
Here is a lesson for not reading document thoroughly. My very first ExtJS project goes smoothly until one day I created multiple tabs, and then closed some of them. All of sudden the layout completely messed up. In the debug console, there is null reference error. Call stack is deep in the ExtJS library.

Fast forward, after several hours of digging around, I found out I was using "id" config for several ExtJS controls. Then, close tab action will cause all the controls on the other tabs with the same "id" got deleted from DOM.

Solution:
Use "itemId" instead of "id" config for controls.

Comparison to ASP.NET
Came from ASP.NET world, I guess that is why I was using "id" config without any second thought. Below is a comparison of similar concepts in ASP.NET

ExtJS ASP.NET _
itemId  ID  (Recommended) HTML element's ID is automatically generated to ensure uniqueness, usually by concatenating ID of the container hierarchy. Programmer only need to ensure ID is unique within it's container.
id  ClientID  (Not recommended) Rendered HTML element will use this property as their ID. It's programmer's responsibility to ensure it is unique across the whole page (think when you starting to have multiple instances of the same control on a page).

(To check out more ExtJS related posts from me, click here: http://developertips.blogspot.com/search/label/ExtJS)

Monday, March 12, 2012

ASP.NET Exception: "Session state has created a session id, but cannot save it ..."

Symptom:
  • Only happens for new session
  • Exception Message:
    A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll Additional information: Session state has created a session id, but cannot save it because the response was already flushed by the application.
  •  Stack Trace: 
[HttpException (0x80004005): Session state has created a session id, but cannot save it because the response was already flushed by the application.]   System.Web.SessionState.SessionIDManager.SaveSessionID(HttpContext context, String id, Boolean& redirected, Boolean& cookieAdded) +3691007   System.Web.SessionState.SessionStateModule.DelayedGetSessionId() +199   System.Web.SessionState.SessionStateModule.ReleaseStateGetSessionID() +25   System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +874   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270 

Cause:
  • I was able to narrow down the cause of this problem to setting page's Buffer="false"
  • Reasoning would be that without buffering, all content are pushed to client immediately, and somehow, ASP.NET decided to set cookie at a very late stage where it can no longer write to HTTP header to set SessionID cookie
Solution:
Set Buffer to true is not a solution for me, because I will need to flush content to deliver real-time progress information.
Based on some understanding, a solution quickly came up with some Google search. Simply add the following line to Global.asax.cs > Session_Start, the problem is resolved.
string sessionID = Session.SessionID;

Wednesday, February 15, 2012

Faster Flex Builder Compile Time

To increase Flex Builder compile time during development, the following tweak helped my Flex 3 builder to go from 30 seconds to just a few seconds for a medium sized project.
Open project property, under Flex Compiler -> Additional compiler arguments, add " -incremental -keep-generated-actionscript"

It definitely helps me go from compile once every hour, to every few minutes. Such that I can get immediate feedback through compiler errors or warnings.

Monday, February 13, 2012

file 'lib' not found

When installing Ruby on Rails using command: gem install rails
Got this error message: file 'lib' not found
Seems like it's fixed by running gem instal rdoc followed by gem install rails again.

Tuesday, January 17, 2012

Cross Site XMLHttpRequest

  • IE8 and above:
    • use XDomainRequest instead
    • Can only cross from HTTP to HTTP or HTTPS to HTTPS (i.e. if web page is served from HTTP, then cannot cross-site access HTTPS. Or web page served over SSL cannot cross site access HTTP content. Will get "Access Denied" error.)
  • Cross site request server must send this response header:  Access-Control-Allow-Orig *

Friday, December 02, 2011

Useful Sysinternals Utilities

As a software engineer (not system administrator), I found the following tools from Sysinternal to be useful.
  • Autoruns: mainly used to turn off unnecessary executables during boot and login to speed up system boot performance
  • Portmon: used to monitor serial port traffic (similar to wireshark for network traffic)
  • Process Explorer: used mainly to find file locks, so that I know which process to kill to be able to free up the lock.
  • Process Monitor
  • PsExec: remote execute console application. Examples:
  • psexec \\vm-001 ipconfig /all
  • psexec \\vm-001 cmd
  • This command copies the program test.exe to the remote system and executes it interactively: psexec \\vm-001 -c test.exe
  • PsKill: kill local or remote processes. Mainly used in server software for house keeping (for example: kill stuck Office Automation process)
  • PsService
  • ZoomIt: usefuly for presentation. Zoom in screen, draw lines on the screen.

Friday, October 28, 2011

Disable Touchpad on Dell Laptop

Problem
Ever frustrated with Touchpad being overly sensitive?

I frequently got random mouse movements and clicks while using Laptop's keyboard. They are caused by the Touchpad being overly sensitive. It is especially a problem when I am using remote desktop working on another computer. I guess the Touchpad sensitivity settings does not work on remote desktop client?

And this is a major frustration, because when I finish typing a line of code, they frequently show up on the wrong line, and did not show up anywhere at all, because the random mouse clicks has took their focus away.

Research
Today, finally it struck me that I should disable this thing. And turns out the latest DELL tool has some nice options available. For one thing, I can permanently enable/disable "Pointing Stick", "Pointing Stick Buttons", "Touchpad", and "Touchpad Buttons". But, there is also a very nice feature called: "Disable Touchpad/Point Stick when external USB mouse is present". This is really a very user friendly feature that I never thought of searching for before.

Conclusion
I put a check next to the option:  "Disable Touchpad/Point Stick when external USB mouse is present", and got a wireless mouse. Problem solved. Happily typing code again.

Monday, October 10, 2011

Portable Mouse with a Hook or Loop

Goal: to allow portable mouse to be even more portable

Going to meeting with a laptop, a pen and notebook (made with paper) and a mouse can be a handful (not to mention when you have a cup of coffee). What if we have a hook or ring on the mouse so that it can dangle on a finger (or belt?).
 
Potential Solutions
- retractable ring
- foldable ring
- hook

Need to pay attention of location of ring or hook so that they don't interfere with normal mouse use.

Saturday, September 03, 2011

Adobe Flash Builder 4 and Coldfusion Builder crash during startup

Symptom: all of sudden, my Flash Builder 4 and Coldfusion Builder can not be started. They will crash during start. They are running on Eclipse 3.4.2, and 3.5.2 respectively.

Diagnostic: Coldfusion builder simply show me an error dialog without any useful information. It just generically states something like: Visual C++ request application to exit in abnormal way.
Of course, I tried to reset Eclipse and clear it's workspace to no avail.
However, luckily, Flash Builder 4 throws an exception. And I got a chance to start Visual Studio 2010 debugger session on it. Once in Visual Studio debugger, I saw exception type "bad_day_of_month" from boost library. Then I turn to "Stack Trace" tab, and saw callstack: Kernel32->atmlib.dll->UpdateNotifications.dll. A little Google on this end turned up a thread talking about similar problem from other Adobe users. So, I read the thread, it starts to mention how the "UpdateNotification" library will look at Windows Scheduled Tasks for Adobe updater. Then it occurs to me what might be, and later proven to actually be the root cause.

Cause: A few days earlier, in an effort to speed up my computer, I ran "AutoRuns" utility from "System Internals", and disabled a bunch of "Scheduled Tasks". Among them was a task named "AdobeAAMUpdater-1.0......".

Fix: using "AutoRuns" utilities, I turned the "AdobeAAMUpdater-1.0....." scheduled task back on. Then Flash Builder 4 and Coldfusion Builder are all back to normal.

Monday, August 08, 2011

SQL Maintenance Plan Failed

Environment: SQL 2005
Symptom: Scheduled SQL maintenance plan to do partial backup failed. Got two message logged in SQL Server log:
Error: 3041, Severity: 16, State: 1
BACKUP failed to complete the command BACKUP DATABASE master WITH DIFFERENTIAL. Check the backup application log for detailed messages.
Cause: Master database does not support partial backup. So, if the task is for "Differential" backup, "master" database should not be included.
Solution: Open the plan details, in the "Database(s)" section make sure database that needs to be backup are explicitly selected, instead of having "All databases" checked.


Monday, August 01, 2011

Coldfusion Webservice Input Name Changed to in0

Symptom: Coldfusion webservices sometimes complain about input parameter "In0"

Environment: Coldfusion 9 on Windows

Solution: Login to Coldfuion 9 Administrator portal, Go to Server Settings > Caching, click on "Clear Template Cache Now" and "Clear Component Cache Now". This seems to trigger to re-compile of webservices WSDL thus fixed the problem.


However:
  1. I don't know what is the root cause of this problem. Google turn-up some similar complains, but could not find any official answers on this
  2. The solution which required human interaction does not help in production environment
  3. The solution does not solve the problem permanently, sooner or later I'll hit the same error, and has to go back to the server and clear cache again

Wednesday, May 11, 2011

CFQUERYPARAM: LIST and SEPARATOR attributes

Adobe online document only listed these two attributes without much explanation. I found the following link with very thorough explanation of the effects and usage of these two attributes:
http://www.pukkared.com/2011/01/using-cfqueryparam-list-attribute-when-using-in-operator/

Tuesday, May 03, 2011

NUnit Integration With Visual Studio 2010

I just discovered the perfect tool for NUnit integration: Visual Nunit 2010

Here are the pros:
  • Open source, Apache License
  • GUI: I personally like it better than the official Nunit GUI
  • Visual Studio Integration: of course, this is the #1 reason I try it out, and I'm completely satisfied
  • Load config file without problem (Nunit project does not load config files correctly)
  • Debug: attach to Nunit or Nunit-agent is no longer needed, simply set breakpoints and click the red  arrow to start debug session
  • Easy drilldown of test cases
  • One click to execute any individual test cases
Cons? None so far.

Thursday, April 21, 2011

Server Side Office Automation using ColdFusion

Tips after fighting to get robust Office Automation using ColdFusion 9.


Definitions
COM: Microsoft Component Object Model.
Automation: the process of launching another application and controlling it programmatically through a public interface.

Environment
ColdFusion 9
Office 2007 SP2

Tips
  • Pay attention to Office version (down to minor rev numbers), I encountered several major differences  between Office 2007, and Office 2007 SP2 (no to mention the differences between 2003 and 2007)
  • Server setup
    • CF service account must be interactive
    • Office installation need to select option to install all features locally
    • After Office installation, need to login as service account, and start Office applications and click through license agreement, registration, ...
  • Open Office applications with Visible=false may have negative impact on it's behavior (At least for Powerpoint, I found some layout options are not functioning correctly if application is started in invisible mode. Specifically, I was trying to set text box property: "Shrink text on overflow", by setting AutoSize=2 (msoAutoSizeTextToFitShape), it won't work unless Powerpoint application is created in visible mode.)
  • Before even start ColdFusion code, I usually test my script using VBS, then translate to CFScript, however, CFScript have some minor difference from VBS:
    • VBScript can use array notation or foreach on some collections, but CFScript  usually has to access the 'items' accessor
    • Explicit type conversion may be necessary in some COM function calls, use "JavaCast". In my case, I got this error message:
An exception occurred when executing a COM method. 
The cause of this exception was that: AutomationException: 0x80048240 - Item 1 not found in the Designs collection. in 'Microsoft Office PowerPoint 2007'. 
Code causing the problem: objPresentation.Designs.Item(1)
Reason: ColdFusion is not type safe. COM definition for this input parameter is variant type. Seems like ColdFusion trying to send it over in string format "1" instead of numeric value 1.
Solution: objPresentation.Designs.Item(JavaCast("int", 1))
    • VBScript can use enumerates just by name, CF does not have that luxury, you have to find out the numeric values for each of the enumerations, please see my other post for list of some numeric values: Some Enum Values for Office COM Object.
  • To find out numeric values, I used Visual Studio to add reference to Office library, then I can easily navigate or search for enums
  • One way to implementation robust automation:
    • Main CFC
      • Create a worker thread to do automation task
      • Wait for the thread with timeout
      • After wait is finished, if it's timeout, will kill automation application, kill thread, and cleanup, else we have successfully done!
    • Automation thread
      • Global lock on Office Application name (avoid concurrency issue)
      • Create automation object
      • <<do you thing>>
      • quit automation object
      • ReleaseCOMObject
      • cleanup
  • To cleanup, I use "pskill" to kill office processes, so that a single failed call won't block all future automation attempts
  • Code segment to create automation object

Server Side Office Automation Problems
  • Office applications are not designed for server environment
  • Concurrency (Office applications are non-reentrant, STA based automation, use global shared resources)
  • Scalability
  • Security
  • May lock up on launch or any point during execution if there are modal dialog popup (typically you will see license agreement, error messages, “install on first use”, … dialogs)
  • License considerations: each client must have licensed copies of Office
  • Officially discouraged by Microsoft
“Microsoft does not recommend or support server-side Automation of Office”
Alternatives
  • CFSpreadsheet
  • HTML/XML based format for word and excel
  • OOXML (Open XML file format)
  • Excel Services (Since Sharepoint Server 2007)
  • Word Automation Services (Since Sharepoint Server 2010)
  • Server libraries: Apach POI, Microsoft Open XML SDK
Reason to Stick with Automation Approach
  • After the above "Problems" section, the biggest incentives to use automation are
    • Need to invoke Excel macro or solution package on server side
    • You already have some fancy VBS code that can do what you wanted through Office automation

References

Adobe. 2011. ColdFusion Developer’s Guide. Last Accessed April 19, 2011. http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Part_4_CF_DevGuide_1.html
Forta, Ben and et al. 2005. Advanced Macromedia ColdFusion MX 7 Application Development, Chapter 26 Extending ColdFusion with COM. Macromedia Press. http://www.forta.com/books/0321292693/0321292693_chapter26.pdf
Microsoft. 2011. KB 257757: Considerations for server-side Automation of Office. Last Accessed April 19, 2011. http://support.microsoft.com/kb/257757

Friday, March 25, 2011

Some Enum Values for Office COM Object

Actual integer values for several Office 2007 (12.0) COM Enums

Microsoft Office Core


MsoAutoSize

msoAutoSizeMixed-2
msoAutoSizeNone0
msoAutoSizeShapeToFitText1
msoAutoSizeTextToFitShape2

Word


WdSaveFormat

wdFormatDocument970
wdFormatDocument0
wdFormatTemplate971
wdFormatTemplate1
wdFormatText2
wdFormatTextLineBreaks3
wdFormatDOSText4
wdFormatDOSTextLineBreaks5
wdFormatRTF6
wdFormatUnicodeText7
wdFormatEncodedText7
wdFormatHTML8
wdFormatWebArchive9
wdFormatFilteredHTML10
wdFormatXML11
wdFormatXMLDocument12
wdFormatXMLDocumentMacroEnabled13
wdFormatXMLTemplate14
wdFormatXMLTemplateMacroEnabled15
wdFormatDocumentDefault16
wdFormatPDF17
wdFormatXPS18
wdFormatFlatXML19
wdFormatFlatXMLMacroEnabled20
wdFormatFlatXMLTemplate21
wdFormatFlatXMLTemplateMacroEnabled22
wdFormatOpenDocumentText23

WdExportFormat

wdExportFormatPDF17
wdExportFormatXPS18

WdAlertLevel

wdAlertsMessageBox-2
wdAlertsAll-1
wdAlertsNone0


PowerPoint


PpSaveAsFileType

ppSaveAsPresentation1
ppSaveAsPowerPoint72
ppSaveAsPowerPoint43
ppSaveAsPowerPoint34
ppSaveAsTemplate5
ppSaveAsRTF6
ppSaveAsShow7
ppSaveAsAddIn8
ppSaveAsPowerPoint4FarEast10
ppSaveAsDefault11
ppSaveAsHTML12
ppSaveAsHTMLv313
ppSaveAsHTMLDual14
ppSaveAsMetaFile15
ppSaveAsGIF16
ppSaveAsJPG17
ppSaveAsPNG18
ppSaveAsBMP19
ppSaveAsWebArchive20
ppSaveAsTIF21
ppSaveAsPresForReview22
ppSaveAsEMF23
ppSaveAsOpenXMLPresentation24
ppSaveAsOpenXMLPresentationMacroEnabled25
ppSaveAsOpenXMLTemplate26
ppSaveAsOpenXMLTemplateMacroEnabled27
ppSaveAsOpenXMLShow28
ppSaveAsOpenXMLShowMacroEnabled29
ppSaveAsOpenXMLAddin30
ppSaveAsOpenXMLTheme31
ppSaveAsPDF32
ppSaveAsXPS33
ppSaveAsXMLPresentation34
ppSaveAsOpenDocumentPresentation35
ppSaveAsExternalConverter36


PpAlertLevel
ppAlertsNone1
ppAlertsAll2


PpAutoSize
ppAutoSizeMixed-2
ppAutoSizeNone0
ppAutoSizeShapeToFitText1

PpSlideLayout
ppLayoutMixed-2
ppLayoutTitle1
ppLayoutText2
ppLayoutTwoColumnText3
ppLayoutTable4
ppLayoutTextAndChart5
ppLayoutChartAndText6
ppLayoutOrgchart7
ppLayoutChart8
ppLayoutTextAndClipart9
ppLayoutClipartAndText10
ppLayoutTitleOnly11
ppLayoutBlank12
ppLayoutTextAndObject13
ppLayoutObjectAndText14
ppLayoutLargeObject15
ppLayoutObject16
ppLayoutTextAndMediaClip17
ppLayoutMediaClipAndText18
ppLayoutObjectOverText19
ppLayoutTextOverObject20
ppLayoutTextAndTwoObjects21
ppLayoutTwoObjectsAndText22
ppLayoutTwoObjectsOverText23
ppLayoutFourObjects24
ppLayoutVerticalText25
ppLayoutClipArtAndVerticalText26
ppLayoutVerticalTitleAndText27
ppLayoutVerticalTitleAndTextOverChart28
ppLayoutTwoObjects29
ppLayoutObjectAndTwoObjects30
ppLayoutTwoObjectsAndObject31
ppLayoutCustom32
ppLayoutSectionHeader33
ppLayoutComparison34
ppLayoutContentWithCaption35
ppLayoutPictureWithCaption36

PpTextStyleType
ppDefaultStyle1
ppTitleStyle2
ppBodyStyle3

Friday, December 17, 2010

Instead of CFDUMP

Ways to inspect CFC returns in browser without using CFDUMP.

1. Using Chrome JSONView extension:
Prerequisite:
Install Google Chrome

Now just add to request URL: "&returnFormat=JSON". The CFC return will be shown in nice hierarchical which can be interactively expanded or collapsed.

2. In IE and FireFox using ServiceCapture
Prerequisite: buy and install ServiceCapture.

Still in request URL, add: "&returnFormat=JSON". In ServiceCapture, Response > JSON will show the data structure in expandable tree structure.

Friday, November 19, 2010

SQL Interview Questions

Here is a collection of Microsoft SQL Server interview questions.
Basic Concepts
  • Filtered index
  • Common Table Expression
  • Derived tables
  • Fill factor
  • Clustered Index
  • Heap table
  • OLTP vs. OLAP
  • Star schema
  • What are the differences between SQL developer, standard and enterprise editions
  • local vs. global temporary table
  • sparse columns
  • Functions: STUFF, PATINDEX, RANK, NTILE
  • SCOPE_IDENTITY vs. @@IDENTITY
  • XML support
  • Geo-spatial data support
  • CLR integration
  • Replication
Breadth
  • NoSQL
  • Column based RDBMS
Best Practices
  • What are the performance best practices
  • What are the security best practices
Coding Skills
  • How to select top N records without using TOP
  • Write a stored procedure to check out one job with columns: JobID, Status (new, checked out, done), priority
  • Write a stored procedure to atomically insert records into the following tables with error handling
Table A
---------
ID
Name

Table B
---------
ID
Name

Table A_B
---------
ID_A
ID_B

Wednesday, October 27, 2010

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)

Thursday, April 22, 2010

Windows XP "System Restore" and Subversion

Subversion users be aware: Windows XP "System Restore" will rollback your SVN working folder!

Just learned it the hardway. I did a system restore on my Windows XP box, and all of sudden all the projects are broken. It turned out that all my SVN working folders are rolled back too.

Solutions?
  1. Checkout "Head" from SVN repo again. Lucky for me, I do check-in frequently, and this solution works for me just fine;
  2. Start "System Restore", and this time select "Undo my last restoration";

Monday, April 19, 2010

Subversion (SVN) Client for Windows Quick Start

This is a brief guide to SVN client usage on Windows using Tortoise SVN client.

Recommended Software:
  1. Install Tortoise SVN client from this web site: tortoisesvn.tigris.org
  2. Install winmerge from winmerge.org for merging code
Check out:To check out a project from SVN server for the first time: start Windows Explorer, right click in the folder you want to save the checkout code, and select "SVN Checkout".

Check in procedures:
Check-in usually have three steps in the following order:
  1. add new file to server;
  2. check for new updates from server and merge if necessary;
  3. commit the changes back to the server;
Minimum requirement for the checked in code is that they can compile without errors.

More detailed checkin steps:
1. In windows explorer, right click the checkout root folder, and select “SVN Add”;
2. If new files are listed in the following dialog:
a. check the files that you want to send to SVN;
b. uncheck the files that you do not want to send to SVN, and add them to the ignore list;
3. Right click the root folder again, and select “SVN Update”
4. If there are changes or merge during update step, double check that the code can still compile;
5. Right click the root folder, and select “SVN Commit”, and type a proper comment about what are fixed, or the new features in this checkin;

Monday, April 12, 2010

Visaul Studio 2010 First Impression

It is officially released today. Tried a little bit and did not like it at all.

#1 problem: sluggish GUI response! No kidding. I thought Eclipse is slow, now I see something slower. No wonder it's release date was postponed to fix performance problem.

Of course, there is also problem finding my way around the IDE. Cannot seem to find a way to generate create script for my database project.

Friday, March 26, 2010

Lean Software Development

Some study notes while reading about Lean Software Development:
  • Adapted from Lean Manufacturing, Toyota Production System;
  • Originated in the boot "Lean Software Development" by Mary Poppendieck and Tom Poppendieck
  • Principles:
    • Eliminate waste
      • Extra features
      • Economies of scale: focusing on high utilization is almost guaranteed to lower it
      • Cross boundaries

    • Amplify leaning
    • Decide as late as possible
    • Deliver as fast as possible
    • Empower the team
    • Build integrity in
    • See the whole

  • Two pillars
    • Continuous improvement
    • Respect for people

  • The responsibility lies, not with black belt specialist, but with the leadership hierachy that runs the operation and they are teachers and coaches;
  • The essence of (the Toyota system) is that each individual employee is given the opportunity to find problems in his own way of working, to solve them and to make improvements;
  • Challenge everything, dissatisfied with status quo
  • Kanban
  • Kaizen
    • spread knowledge
    • small, relentless
    • retrospectives
    • 5 whys
    • eyes for waste

  • Share rather than enforce practices
Good References:


http://en.wikipedia.org/wiki/Lean_software_development

Lean Primer: http://www.leanprimer.com/downloads/lean_primer.pdf

http://www.poppendieck.com/