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/

Friday, January 29, 2010

Flex Builder Error: "Unable to export SWC oem"

Solution: Right click on project, select Properties > Flex Library Build Path > Assets. Uncheck the root node and check it again, then compile project. The error is gone.

I found the solution here: http://flexdevtips.blogspot.com/2009/06/unable-to-export-swc-oem.html

Friday, January 15, 2010

Performance Optimization for Embedded Systems

Some key points:
  • Load code and data as much as possible into internal memory (L1 cache);
  • Use compiler or linker options to optimize for code size can sometimes give better performance than optimize for performance (GreenHills has a very nice tool to help find the optimum compromise between optimize for speed and size). Major points for manipulation:
    • Optimize for speed
    • Optimize for size
    • Remove unused functions
    • Remove debug information
    • Enable code cache
  • Carefully tune the use of code cache and data cache. Performance difference between fine tuned layout and the default can be 10 time or more;
  • Use integer, fixed point over float over double. If floating point computation is necessary, but double is not needed, then remember that all the constants MUST explicitly declared as floating precision, otherwise there may be a lot of double computation and float to double conversions. For example, instead of x=2.0; should use x=2.0f;
  • Bit shift is faster than add (usually), add is faster than multiply (usually), multiply is faster than divide. So the following tricks usually are helpful:
    • Use left shift and right shift instead of multi and div by 2, 4, 8, 16, 32, ... (integer only);
    • Use add instead of multi 2, 3;
    • If a number is used as divider many times, pre-calculate it's inverse, and use multiply for the calculations;
  • Blackfin (DSP architecture specific): assign data to A/B bank properly to enable parallel data retrieval;
  • Profiler is your friend: use profiler to find the biggest consumer and focus on them;
  • In C++ world: avoid deep hierarchy, because those practices take precious memory space which in turn have grave impact on performance;
  • Be careful when you use C runtime. Call to "printf" can easily add 1k memory footprint;

Thursday, January 14, 2010

"var scope" for CFC Function Variables

Why is it good practice to always "var-scope" every CFC function variable?
  • Make it clear that the variables are only visible within the function;
  • Using "var-scope" actually can help improve performance. I tried the test here, and am personally convinced that "var-scope" has significant positive impact on performance;
  • If you "var-scope" every CFC function local variables, then it will be obvious when you have typo in your code. Because you can use tool like "varScoper" to scan your file, if there are complains, you either forget to "var-scope" a variable, or you've got a typo that "varScoper" just helped you to catch;

Monday, December 14, 2009

Start ASP.NET Development Web Server in Command Line

start "ASP.NET Development Server" /B c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE /port:[port#] /path:[file path] /vpath:[/virtual parth/]

Starting debug server this way will allow debugging web project without even starting Visual Studio 2005.

Friday, December 04, 2009

VC++ Redistributing

Symptom: I keep bumping into this issue. Once in a while my VC++ application does not even start on the targe computer.

Cause: The root cause is that the target computer does not have the VC++ library to support the applications. I works with server products, so I usually just install VC++ library once and expect all my future updates can be done by xcopy only. However, because I turned on auto-update on my development computer, my Visual Studio 2005 keep changing the library it is linked against. So once in a while xcopy deployment is broken.

Fix:
  • Sometimes it can be fixed by simply running Windows Update
  • Run VC++ Redistributable Package on the target computer. It is located here: %PROGDIR%\Microsoft Visual Studio 8\SDK\v2.0\Bootstrapper\Packages\
  • More options here: Choosing a Deployment Method

Monday, November 16, 2009

GridView: get selected rows

Below is sample C# code to get selected rows in GridView.

protected int[] GetSelectedRows()
{
List rowIDs = new List();
foreach (GridViewRow row in GridView.Rows)
{
CheckBox cb = ((CheckBox)row.FindControl("chkRow"));
if (cb.Checked)
{
string IDString = GridView.DataKeys[row.RowIndex].Value.ToString();
rowIDs.Add(Int32.Parse(IDString));
}
}
return rowIDs.ToArray();
}

"SelectAll" CheckBox in GridView using jQuery

Here is a way to do it:


/**
* Register logic for "select all" check box and the group of check boxes
* for each data row.
*
* @param {Object} chkAllSelector jQuery selector to find the "select all" check box
* @param {Object} chkItemSelector jQuery selector to find the check boxes for all the rows
*/

function registerSelectAll(chkAllSelector, chkItemSelector) {
//"select all" checkbox
var checkAllBox = $(chkAllSelector);
//checkbox for each row
var checkItems = $(chkItemSelector);

//check/uncheck all rows if "select all" is clicked
checkAllBox.bind("click", function(){
checkItems.each(function(){
this.checked = checkAllBox[0].checked;
})
});

//uncheck "select all" if some rows are unchecked
checkItems.bind("click", function(){
if(this.checked === false) {
checkAllBox[0].checked = false;
}
});
}


To use it:

registerSelectAll(".chkAllHeader input", ".chkItem input");

Monday, November 09, 2009

"An unexpected error occurred." accessing Network Connection's properties

Cause: seems like it suddenly happens after a recent Windows Update. I cannot ping or "remote desktop" to the computer. Trying to access network connection give me this error: "An unexpected error occurred."

Solution:
This seems to fix the problem:
command line:
regsvr32 netshell.dll
regsvr32 ole32.dll
reboot

Then I can access the properties page, and I disable/re-enabled firewall. Everything coming back to normal.

P.S.
Keep my fingers crossed. Waiting for more surprised from next automatic Windows Update.

Wednesday, October 14, 2009

3D Visualization on iPhone - Got to see it to believe it

Ziosoft showcased this amazing 3D visualization on iPhone. It is fast and smooth with very high image resolution. With dual touch, seem like it is very easy to control zoom, move cutoff plane, rotate and move object, and select depth of rendering.

http://www.youtube.com/watch?v=sDVAosnh1j4&feature=channel_page

From their description and the look, it is obvious that there is web server doing the rendering behind. iPhone seem to provide the dual touch and navigation. Still the the speed is impressive. Either the iPhone has very high speed internet access, or there is some very efficient decompress and rendering algorithms running on it so that data transfer rate is not too high.

Monday, August 10, 2009

Server Explorer Missing

Symptom: Visual Studio 2005 Server Explorer is missing.
Reason: A while back, Visual Studio failed to load the server explorer at starup time, and showed a dialog to disable it. I guess I accidentally clicked "yes".

Solution: run this command in Visual Studio 2005 command line environment:
devenv /resetskippkgs

Tuesday, June 30, 2009

Refeactor! for C++ -- Review

Tried Refactor! for C++ (free version 9.1.5 published June 29, 2009). Visual Studio 2005

Summary of my experience:
Pros:
  • Free;
  • The idea is very attractive: refactor C++ code with right click and no modal dialogs;
  • Rename class names seem to work fine;
Cons:
  • Does not work most of the times. Usually global search and replace did a better job in renaming things;
  • Affects VS grammar highlight. After installation, code grey out by "ifdef"s are totally messed up. Unistall the softwate, Visual Studio went back to correct grey out;

Recommended? No. I uninstalled the software after a few days.

Still looking for a decent C++ refactoring tool.

Monday, December 29, 2008

Modem Error: NO CARRIER

What to check when you get "NO CARRIER" (numeric code: 3) error from Modem:
  • Verify Modem is connected to phone line properly;
  • Verify the phone number you are dialing works properly by calling this number using your phone, and verify that you hear: first ring tone, then the negotiation tone (yes, you should be able to hear the chirping sound over a regular phone);
If you can hear the negotiation tone, but frequently get "NO CARRIER" error, here is a solution:
Set modem register S7 to a longer timeout value. 50 is the default, you can set it to 120 (ATS7=120). Sometimes, you can set this timeout value through MODEM configuration GUI, you can find something like: "Cancel the call if not connected within __ seconds".

Friday, November 07, 2008

Firefox keep crashing -- a solution

Every couple of days, I will see my Firefox using 99% of CPU and crash.

I am a web developer. My Firefox has all sorts of add-ons: Abduction, Firebug, Html Validator, ScapBook, Screen grab!, Web Developer, YSlow. So, I do not need YSlow to know why my Firefox is slow and tend to crash.

I have an idea: how about start two instances of Firefox, one with all the add-ons and the other one clean. I will use the clean one for normal web browsing, and the fully loaded one with development. And, guess what, there is already someone who has done this and posted a blog about it: Firefox: Run a Regular and Development Profile at the Same Time. I used the solution, and it works perfectly.