Wednesday, August 28, 2013

Link shared folder in SVN

Found this article, and followed it's instruction. Very straight forward.
TortoiseSVN and Subversion Cookbook, Part 4: Sharing Common Code
https://www.simple-talk.com/dotnet/.net-framework/tortoisesvn-and-subversion-cookbook-part-4-sharing-common-code/

What I did is just these steps (assuming both folder1 and folder2 want to have a subfolder: sharedlib):
  1. Open repo-browser
  2. Drag and drop shared folder into a root folder (folder name sharedlib, level same as folder 1 and folder 2)
  3. Right click on folder 1,Show Properties > New > External > New, local path: sharedlib, URL: ../sharedlib
  4. Do the same thing for folder 2
Now both folder 1 and folder 2 have sharedlib.

OpenCV in Visual Studio 2012

It's surprisingly easy, just took about 15 minutes to see some example code running.

Steps to create the first OpenCV project using Visual Studio 2012
  1. Download: opencv.org > OpenCV for Windows
  2. Run the downloaded executable and decompress to d:\opencv (to help the examples below)
  3. Open Visual Studio 2012, create new project  Visual C++ > Win32 > Win32 Console Application
  4. Add "Include Directories": Project Properties > Configuration Properties > C/C++ > General > Additional Include Directories, add: D:\opencv\build\include
  5. Change to static link (optional, but if this is not done, then the library below need to be changed slightly): Project Properties > Configuration Properties > C/C++ > Code Generation > Runtime Library, select Multi-threaded (Debug)
  6. Add "Library Directories": Project Properties > Configuration Properties > Linker > General > Additional Library Directories, add:D:\opencv\build\x86\vc11\staticlib (or  D:\opencv\build\x86\vc11\lib if you don't want static link)
  7. Add lib files: Project Properties > Configuration Properties > Linker > Input >Additional Dependencies, add the libraries listed below. (Note: 1. comctl32 is a Windows library; 2. replace "246" to version number you have; 3. files ending with "d" is debug version, for release configuration, remove it)
IlmImfd.lib
libjasperd.lib
libjpegd.lib
libpngd.lib
libtiffd.lib
opencv_calib3d246d.lib
opencv_contrib246d.lib
opencv_core246d.lib
opencv_features2d246d.lib
opencv_flann246d.lib
opencv_gpu246d.lib
opencv_haartraining_engined.lib
opencv_highgui246d.lib
opencv_imgproc246d.lib
opencv_legacy246d.lib
opencv_ml246d.lib
opencv_nonfree246d.lib
opencv_objdetect246d.lib
opencv_ocl246d.lib
opencv_photo246d.lib
opencv_stitching246d.lib
opencv_superres246d.lib
opencv_ts246d.lib
opencv_video246d.lib
opencv_videostab246d.lib
zlibd.lib
comctl32.lib


Now, for a quick sanity check, run one of the sample code from opencv.org (the example I used is "Hough Circle Transform" http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html
 
Environment:
  • Windows 7
  • Visual Studio 2012
  • OpenCV 2.4.6

Monday, August 26, 2013

Selenium WebDriver

Two lessons learned

  • IE driver need to start with "ignoreZoomSettings" true
  • JavascriptExecutor return for JS object

IE driver need to start with "ignoreZoomSettings" true

Got this error when using WebDriver for IE: "
org.openqa.selenium.remote.SessionNotFoundException". Turns out I was using IE to visit the same site I'm testing, and I adjusted zooming to 120% there. Fix for this problem is easy, simply change IE web driver creation to this:


DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
driver = new InternetExplorerDriver(caps);

JavascriptExecutor return for JS object

What can be returned from JavaScriptExecutor.executeScript? According to the documentation, these are the types that it handles: Boolean, Long, String, List, or WebElement or null. I did a little experiment, and pleasantly surprise by the fact that array of JSON can be handled too. The return will be ArrayList of Maps. Calling obj.toString (Java side) will actually give me expected JSON string too.
Figure: Return Object as Shown in Eclipse Variables View

Thursday, August 22, 2013

Selenium WebDriver sendKey is very slow in IE

sendKey for IE is very slow. Turns out there is an easy fix. Simply download 32 bit IE driver (guess it's my bad used 64 bit driver before).

Environment:
Windows 7 Pro 64 bit
IE 10
Selenium 2

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.