Frameworks and libraries

JS front-end frameworks and libs

Ext Js: powerful MVC and MVVM framework for desktop like UI on the web using mostly declarative programming.

jQuery: no need to say more

Underscore.js: library with utility functionalities, binding, applying, map, reduce, all, each, etc.

Meld: Aspect oriented programming for JS.

Backend frameworks

ASP.NET Web forms, MVC: MVC is the future.

ASP.NET Web API

Zend framework

Other libraries and technologies

NHibernate, LINQ, Entity Framework: ORMs

Dependency injection: Spring.NET, Spring for Java, Unity.

Strategy to debug Javascript

Make sure you read the relevant API docs.

Use Chrome’s developer tools, Firebug, or IE’s, and Visual Studio debugger, they are awesome.

Use console.log and alert in code when necessary when tracing code is difficult.

Run JS scripts from JS console.

Don’t be afraid to trace through third party’s frameworks and libraries when necessary.

 

Chrome DevTools was disconnected from the page, IE error out of stack space

This issue, according to the stackoverflow answers seem to stem from the webpage having.

  • Infinite recursion(likely)
  • Infinite loop(not likely?)

The same issue will make IE display an error: “SCRIPT28: Out of stack space”

If you can debug and find out the infinite recursion, maybe it’s possible to fix this issue.

500.19 – Internal Server Error – The requested page cannot be accessed because the related configuration data for the page is invalid

Today I faced this error while trying to run a web application.

It turned out that it was occurred in a REST request to the server to retrieve a JSON file. I tried to solve this issue by first opening IIS and check the declared MIME types under the web application, then it complained that there is a duplicate entry in the web.config file.

It turned out that if the web.config file contains a declaration for the MIME type .json and under the application in IIS the MIME type is also declared, IIS will complain. I solved the issue by removing the MIME type declaration from the web.config file.

Tips to generate a large SQL Server table for testing

To generate a large table with millions of records, it’s possible to use the following script:

declare @RecordsNum int = 10000000-(select count(*) from Person)

declare @Count int = 0

set nocount on

Begin transaction

while(@Count < @RecordsNum)

begin

insert into MyTable(Name, Address, Age)

values(substring(Convert(varchar(255), NewID()), 0, 30),

substring(Convert(varchar(255), NewID()),0 ,30), RAND(100) * 100)

set @Count = @Count + 1

End

commit

select count(*) from MyTable

Some things to do to improve performance of the script:

  • Set NoCount to ON
  • enclose the while loop in a transaction explicitly

Ideas were found in this page: http://mitchelsellers.com/blogs/2008/09/12/creating-random-sql-server-test-data.aspx

Axis Object – Auto Interval Error in SSRS line charts

I faced this problem because the data series in my line chart doesn’t have any data when the vertical axis’s minimum, maximum, Interval and Interval type properties are all set to “Auto”.

Reading from the net it seems that this problem can also occur when your data has values of infinity such as when you use an expression to calculate the series data values and there is a division by 0 somewhere which produces infinity.

To solve this problem when there are no data values, I set the minimum value and the maximum value of the vertical axis using the following expression

For minimum value:  =IIf(Min(Fields!Value.Value) = Nothing, 0, “Auto”)

For maximum value: =IIf(Max(Fields!Value.Value) = Nothing, 100, “Auto”)

Basically, if there are no maximum or minimum values in the dataset, set some default values. This way SSRS won’t complain and the report will show with no error messages.

Default Values for parameters not working in SSRS with SharePoint integration

I faced this problem while trying to set default values to parameters in a report that resides within the SharePoint site.

It turned out that once a report is uploaded to SharePoint, the default values for parameters are maintained in the server, so subsequent changes to the default values will have no effect after saving or overwriting the report in the server.

To solve this, delete the report from the server and upload the report again. Quite stupid, but it works.

SSRS line chart gaps are not correct

For SSRS line charts to display gaps in the data correctly, the data must explicitly tells that for certain timestamps there are no data in those timestamp.

If there is a gap between timestamp A and timestamp B, the line chart will only display a gap if there are table rows for timestamps between A and B that contain empty or nil values. Otherwise, it will connect the lines instead of showing gaps.

Strategies to debug irreproducible bugs, or Heisenbugs

If the code in question involves concurrency, check if there is a potential for deadlocks which occurs infrequently and hard to track.

Check for other factors: network conditions, equipment quality, environment, bugs originated from OSes or third party libraries.

Add sufficient loggings to the code in case the bug appears again by detecting the bug’s behaviour, so that in the future if it appears again you will have something to track it.

Add a notification mechanism to notify you when the bug appears again, similar to previous point.

Forget about it for a while and work on other tasks, so that you can look at it from another angle later.

Have another person with fresh eyes to look at the code and give new ideas on what might cause it.

Pass many different inputs to the code with many edge cases to see if the bug can be reproduced, might be very time consuming and not effective, but can try.

If it doesn’t appear again and you have no idea how to reproduce it, maybe it’s okay to just ignore it for the time being.