Tuesday, January 13, 2015

Configure ELMAH in Plesk

The issues I encountered are

1. Can't access using /elmah.axd, 403 forbidden

Add

 
    ....
   
 

  Thanks to this post

   http://code.google.com/p/elmah/wiki/SecuringErrorLogPages

2. Elmah doesn't log in Plesk

Check permission Elmah logging folder, it is ~/Logs in my case. Make sure IIS user and IIS WP user has write permission




Saturday, September 7, 2013

Office Upload Center - Document Cache Error

Skydrive pro 2013 can't sync with Office 365.  Office upload center shows "Document cache error", click "delete cache" in setting cause upload center to crush. Finally resolve the issue by following steps.

1.  In task manager, kill MSOSYNC.EXE.

2.  Run regedit,  in HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\Internet, delete FileStoreCriticalError entry.   The version number 15.0 is for office 2013, 14.0 is Office 2010.

3. In c:\users\[username]\AppData/local\Microsoft\Office\15.0,  delete OfficeFileCache.

4.  In c:\users\[username]\AppData/local\Microsoft\Office\SPW, delete all files.

More details, please refer to http://www.addictivetips.com/windows-tips/office-2010-fix-office-document-cache-error/

Monday, July 9, 2012

A Very Short History of Data Science

A Very Short History of Data Science

  Here is a brief of history of data science. In this post, the author lists the main paper, books and events in different stage of the development of data statistic and big data

http://whatsthebigdata.com/2012/04/26/a-very-short-history-of-data-science/



Wednesday, September 7, 2011

Most influential computer books

Stackflow has a 3 year old post for voting the most important IT books. The vote can be found here

The top 10 books are:



I've read the Refactoring and Design Pattern but not the rest of them. They are really good.  Hope to have to to go through them when I'm free.

Tuesday, September 6, 2011

Resizing partition for HP laptop

Last Sunday, I bought a new HP pavilion dv6 6024TX for my wife. She was quite happy with the new machine. The only flaw is that the whole 750G HDD has only one drive C. (There are 4 partitions but rest of them are for recovery purpose). So I take the responsibility to reorganize the partitions.

I did that before by reinstall the OS. But this time I decided to resize the existing partition without losing exist data and create a new partition on freed space.

I started to try Partition Magic of Symantec since I have used it long time before. Unfortunately, the product has been discontinued by its owner as described in this post.

I have to find another tool. After searching around on net, I found GParted. The tool is open source and powerful. It can be downloaded here.

In order to use GParted, system need to be boot under GParted itself. So a bootable USB is needed. I took the follow steps to setup a bootable USB

USB setup with Windows
  • Download the GParted Live zip file.
  • If you already have a partition of at least 200 MB in size on your USB flash drive formatted with a FAT file system then skip to the next step (3).
    Otherwise create at least a 200 MB partition on your USB flash drive and format it with a FAT16 or FAT32 file system.
  • Extract all the contents of the zip file to FAT16/FAT32 partition on your USB flash drive. Keep the directory architecture, for example, file "COPYING" should be in the USB flash drive's top directory (e.g. G:\COPYING).
  • Browse to your USB flash drive and as an administrator, click the makeboot.bat in the dir utils\win32\. WARNING! Makeboot.bat must be run from your USB flash drive.
  • Follow the on-screen instructions.
    (PS: The above description is modified from: http://www.pendrivelinux.com/2007/01/02/all-in-one-usb-dsl. Thanks to PDLA from http://pendrivelinux.com)
There are also other ways to create bootable USB. Check out this link to find more

After setup the USB, reboot system from USB.  In order to boot from USB, I need to enter BIOS(press F10 to enter BIOS for HP laptop) and change boot order. 

The system will start Debian Linux and eventually enter GParted. It is a X window program looks like this.


Then I can do tasks like resize a partition, create a new partition etc. The whole information about how to use can be found in Help Manual,

It's not end yet. As I tried to create a new partition on freed space I get this error:

You can not have more than 4 primary partitions

This is because there are already 4 there, one is driver C and the other 3 are HP_TOOLS, RECOVERY and SYSTEM. Windows has the limitation that a machine cannot have more than four primary partitions. 

So I have to delete one of them. I backup up the Recovery through HP tool Recovery Manager to 4 DVD. It was pretty straightforward and the instructions can be found here on HP support site.

After all this, I created a new partition and named it D drive.   


Monday, August 30, 2010

Performance tuning tricks for Web App

Mads Kristensen talked about perfornace tuning tricks. This is the second part of the series and is quite useful. The download zip contains tools mentioned in his post.

The post also have links to some good performance articles and tools like Microsoft Ajax Minifier, YUI Compressor and Google Closure Compiler.

Thursday, November 26, 2009

Scale out in SQL Server 2005

There is an msdn article about scale out architecture for SQL Server 2005. The link is here Scale Out SQL Server 2005

Tuesday, December 9, 2008

Microsoft provide an open souce CMS

MS developed an open source CMS codenamed "Oxite". It's at alpha version stage.

From Microsoft’s description of Oxite:


“Oxite provides you with a strong foundation you can build upon - pingbacks, trackbacks, anonymous or authenticated commenting (with optional moderation), gravatar support, RSS feeds at any page level, support for MetaWebLog API (think Windows Live Writer integration made easy), web admin panel, support for Open Search format allowing users to search your site using their browser’s search box, and more - so, you can spend time on designing a great experience.”



Please go to here for some detail

Sunday, November 30, 2008

Free refactor in Visual Studio

There aren't many articles about build-in refactor tool in VS 2008. I find one post Refactoring In Visual Studio 2008. This can be used as a start point to this refactoring tool.

Also, DevExpress provided a free Refactor! for VS 2005. I found it originally from Free refactoring tools for ASP.NET code in Visual Studio 2005. Not sure if it works fine in VS 2008.

Thursday, November 27, 2008

Output GridView to Excel


To output GridView or DataGrid to Excel file, one can use:


  1. Use oledb classes to create and write data into Excel file

  2. If datasource is DataTable or DataSet, use writeXml method

  3. Use RenderControl method of Control class



Taking the latest way as an example

System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
htmlWrite.WriteLine("<table cellspacing=\"0\", rules=\"all\", border=\"1\">");
gvResult.RenderControl(htmlWrite);
htmlWrite.WriteLine("</table>");

System.Text.UnicodeEncoding encoding = new System.Text.UnicodeEncoding();

String fileName = Guid.NewGuid().ToString() + ".xls";
String path = @"c:\temp\";
File.WriteAllText(path + fileName, stringWrite.ToString(), encoding);

Data Binding Expression


One can use objects as datasouce and bind to it by using GridView control.

<asp:Label ID="lbNumber" runat="server" Text='<%#Eval("Number") %>'></asp:Label>


Here "Number" is a property of the datasouce object.



If the field of datasouce is a strong typed object itself, we can also use like this:

<asp:Label ID="lbProjectType" runat="server" Text='<%#Eval("ProjectType.Type") %>'></asp:Label>


"ProjectType" is a property of datasouce object and is an object which has a member called "Type".



If we want to do some complex work during binding, we can also do it at code behind. One approach is writing code in RowDataBinding or ItemDataBinding event handler, The other way is define a method and call it declaratively. Below is an example for the later:


<asp:Label ID="lbScheduledDate" runat="server" Text='<%# DisplayDate(Eval("ScheduledFrom"), Eval("ScheduledTo")) %>'></asp:Label>

Thursday, November 6, 2008

IIS can not access by anonymous account

Recently I encounter an issue. Windows anonymous account can not access local IIS. The security setting in IIS is correct.

After a couple of hours searching on internet. I find the cause. That's because my IUSR_computername doesn't has the right of "log on locally". So I go to:

controlpanel -> Admin Tool -> Local Security Settings -> Local Policies -> User Rights Assignment and find that Guest group doesn't have the permission of "Log on locally". Since IUSER_computername is memeber of Guest group. It doesn't have it as well.

I removed it from Guest group and add it to User group to make this account can be log on locally.

Auth Diagnostics 1.0 is a good tool to find IIS authentication issues. It can be downloaded here

Also, there is a good guideline here to help troubleshooting such issue.

Sunday, November 2, 2008

Create Template Dynamically - Part 2

In my previous blog entry: Create Template Dynamically. I mentioned a nice article on this topic. This article shows how to implement ITemplate interface to build template.

Another article, Using Templated Controls Programmatically shows how to use CompiledTemplateBuilder to do the something. Actually, CompiledTemplateBuilder class is an implement of ITemplate, in it's constructor, a method need to be passed in. And later on, it's initiateIn method will call the method to finish render task.

Friday, October 31, 2008

Create Template Dynammically

Some ASP.NET server controls, like GridView, ListView, Menu provide templates, we can use templates to partially change render behaviors of these controls. Usually we achieve this by using declarative.

However, chances are that we need to create and use templates programmatically. Here is a nice article written by Dino Esposito. Although it is written several years ago, the concept is remain unchanged.

Wednesday, October 29, 2008

Saturday, May 3, 2008

1054 Unknown column 'p.products_id' in 'on clause'

When upgrade mySQL 4.x to mySQL 5.x, it will create this error in zen-cart 1.2.x. The get around is change sql select statemenst as follows:

ZenCart/includes/modules/meta_tags.php, about line 180


from ((" . TABLE_PRODUCTS . " p), " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd on mtpd.products_id = p.products_id and mtpd.language_id = '" . (int)$_SESSION['languages_id'] . "


ZenCart/includes/blocks/blk_advanced_search_result.php


$from_str = "from (((" . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd), " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " mtpd on mtpd.products_id= p.products_id and mtpd.language_id = '" . $_SESSION['languages_id'] . "'";


ZenCart/includes/index_filters/default_filter.php


$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, if(s.status = '1', s.specials_new_products_price, NULL) AS specials_new_products_price, IF(s.status = '1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = '1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'";
}
} else {
// show the products in a given categorie
if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id']))
{
// We are asked to show only specific catgeory
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status = '1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status ='1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from (" . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' and p2c.categories_id = '" . (int)$current_category_id . "'";


ZenCart/includes/modules/product_listing.php, line 1


if($m_brandname&&!$model_code)
{
$listing_sql = "select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status ='1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from ((".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS." p) left join ".TABLE_MANUFACTURERS." m on p.manufacturers_id = m.manufacturers_id, ".TABLE_BRAND_MODEL." bm) left join ".TABLE_SPECIALS." s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = bm.product_id and pd.products_id = bm.product_id and pd.language_id = '1' and bm.brand_name = '".$m_brandname."' order by p.products_sort_order, pd.products_name";
}
else if($m_brandname&&$model_code)
{
$listing_sql = "select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status ='1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from ((".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS." p) left join ".TABLE_MANUFACTURERS." m on p.manufacturers_id = m.manufacturers_id, ".TABLE_BRAND_MODEL." bm, ".TABLE_MODEL." md) left join ".TABLE_SPECIALS." s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = bm.product_id and pd.products_id = bm.product_id and pd.language_id = '1' and bm.brand_model_id = md.brand_model_id and md.model_code = '".$model_code."' order by p.products_sort_order, pd.products_name";
}
else if($p_brandname&&!$part_code)
{
$listing_sql = "select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status ='1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from ((".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS." p) left join ".TABLE_MANUFACTURERS." m on p.manufacturers_id = m.manufacturers_id, ".TABLE_BRAND_PART." bp) left join ".TABLE_SPECIALS." s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = bp.product_id and pd.products_id = bp.product_id and pd.language_id = '1' and bp.brand_name = '".$p_brandname."' order by p.products_sort_order, pd.products_name";
}
else if($p_brandname&&$part_code)
{
$listing_sql = "select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, pd.products_description, IF(s.status = '1', s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status ='1', s.specials_new_products_price, p.products_price) as final_price, p.products_sort_order from ((".TABLE_PRODUCTS_DESCRIPTION." pd, ".TABLE_PRODUCTS." p) left join ".TABLE_MANUFACTURERS." m on p.manufacturers_id = m.manufacturers_id, ".TABLE_BRAND_PART." bp, ".TABLE_PART." pt) left join ".TABLE_SPECIALS." s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = bp.product_id and pd.products_id = bp.product_id and pd.language_id = '1' and bp.brand_part_id = pt.brand_part_id and pt.part_code = '".$part_code."' order by p.products_sort_order, pd.products_name";
}


Although this may not solve all issues, most are eliminated

Thursday, May 1, 2008

DataGrid.ItemCommand doesn't fire

In one of my web application, ItemCommand event of a datagrid doesn't fire as expected. After some work, I find out the reason.

The bind to datasouce code of this datagrid control is put in Page_PreRender handler, not in Page_Load. On first load of the page, everything is fine, the rows are populated in datagrid and I add "cancel" button for each row.

Then I click "cancel" button, which trigger a postback. Again, Page_Load hander runs first. Then .NET framework try to call ItemCommand event, I reckon it checks the rows in datagrid and since their are no rows yet. It decides not to call ItemCommand. Then Page_PreRender is called. The command is ignored.

So, don't do important tasks in Page_PreRender