Evaluated a Bootstrap-Combobox Library

Evaluated a bootstrap-combobox library from GitHub. The setup was quite easy in Plunker, and I just need to copied two files, bootstrap-combobox.js and bootstrap-combobox.css.

The evaluation at http://plnkr.co/edit/XMzzoo?p=preview

I used $(‘#combobox1’).combobox() instead of $(‘.combobox’).combobox() to initialize the combobox.

References:

https://github.com/danielfarrell/bootstrap-combobox

Tests of MVC Controller and Locations of machine.config

Wrote functional tests using MS test suite against MVC controllers on a 64-bit machine. These tests would perform CRUD operations in the database. The web applications worked fine. However, when I ran my functional tests, I got this error “provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified”.

Knowing the web applications worked fine, I immediately executed the following sql to verify the sql connection existed, and couldn’t find the associated sql connection.

select top 100 * from sys.dm_exec_connections 
where client_net_address like '%xyz'
order by last_read desc

 

I then executed netstat in command line in my local machine to verify whether a tcp/ip connection was attempted, and still couldn’t find the lower level tcp/ip connection. At this moment, I knew the tests haven’t reached making the connection step yet.

netstat -ano | findstr ".xyz"

 

After debugged, I found out that MS tests fetched connection strings from this location,

C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Config\\machine.config

instead of x64 location used by web apps,

C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\Config\\machine.config

So I added the connection strings to the right location, and functional tests passed. So make sure that machine.config files in both locations match.

Add To Toolkit – Excel Formula Beautifier

Tags

I was looking at an Excel worksheet the other day. There were so many calculations, and most of calculations were composed of numerous formulas. One typical calculation was around eight lines with no spaces among them, and used so many formulas such as IF, VLookup, AveragesIf, SUM, COUNT, TRIM, etc. Basically, these calculations were little programs by themselves.

I had no idea about how the calculation worked. So I began to indent each formula inside the calculation to understand how it worked. Soon I felt frustrated because there were so many. I cannot do it like this, and had to find a better way…

I began to search Internet, and found this nice utility, Excel Formula Beautifier, and its source code is available at GitHub. It saved me tons of time. Added to my toolkit.

References:

  1. http://excelformulabeautifier.com/
  2. Source code at GitHub, https://github.com/joshbtn/excelFormulaUtilitiesJS

Unit Tests in TFS – Deploy Stub Test Files

Tags

Unit tests in VS 2015 in local machine were 100% pass rate. When checked in with TFS Continuous Integration, the build failed.  All unit tests passed except one with File Not Found error.

Looked at the details of error message, and found out that there were a few stub files Moq used in unit tests. These files were supposed to deploy with unit tests together. The ‘Build Action’ property was set to ‘Content’, and ‘Copy to Output’ property to ‘Copy if Newer’ already. However, test run just could not find those stub files.

Researched this issue, and happened to find the ‘DeploymentItem’ attribute in MSDN. Attached this attribute [DeploymentItem(@”Testfiles\”)] to my test class according to MSDN instructions, and build succeeded.

References:

DeploymentItem Attribute

TFS Continuous Integration – MSB3202, Project Not Found

Tags

Had a VS solution with a few projects, and added existing projects from other TFS folders. Set up a build definition with continuous integration and unit tests, built successfully in local machine, checked in, and got this error “MSB3202: Project xxx.csproj not found”. Verified the project xxx.csproj was at the right location. However, TFS build server and agent cannot find it. What was going on?

Researched internet, found many articles and blogs. However, still cannot solve the issue.

In the end, figured out how to solve this build error by trial-and-error. Here are the steps.

  1. Go to Source Setting of Build Definition
  2. Add entries like the 2nd and 3rd row (highlighted in red) explicitly specifying the Source Control Folder and Build Agent Folder so that TFS know what to do with existing projects in other TFS folders.

 

Source Control Folder Build Agent Folder
$/DefaultCollection/Main/SolutionX $(SourceDir)\SolutionX
$/DefaultCollection/Main/ExistingProjectA $(SourceDir)\ExistingProjectA
$/DefaultCollection/Main/ExistingProjectB $(SourceDir)\ExistingProjectB

 

 

 

 

 

 

JQuery .append vs .html Performance?

Tags

One of web design principles is that the UI should be responsive when loading data into a html element. Of course, we also prefer the loading speed faster. In this exercise, we use JQuery .append or .html to load a huge html table with thousands of rows into a DIV element. But which one is loading faster, .append or .html?

Check it yourself, http://plnkr.co/edit/PGBH6N?p=preview

The results of loading 10,000 rows measured in seconds:

  Edge Firefox Chrome
.append 0.907 0.143 0.258
.html 0.462 0.286 0.441

The results, as you can see, are mixed. .html is faster in Edge, and slower in Firefox and Chrome. .append is slower in Edge, and faster in Firefox and Chrome. However, the .append and .html in Edge is significantly slower than in Firefox and Chrome.

 

Site Visits By Country Map

Tags

This was one of my pet projects, showing the site visits by country map. After browsed the internet, I found this company HighCharts. Personal use is free.

I was able to modify and got it to work quickly within a few minutes, thanks to excellent demos with JSFiddle on their company website. I hard coded the following lines. Of course, you can get these data from an API, etc.

var data = [{
        code: "US",
        value: "238",
        name: ""
      }, {
        code: "CA",
        value: "43",
        name: ""
      },
      ...
];

You can see the site visits so far for this year 2017, here, in plunker. Enjoy and have fun!

Site-Visits-By-Country-2017.png

 

References:

  1. HighCharts

Caching – Do You Really Need It?

Many people love caching. They used caching everywhere they could, even in situations such as only a few users used the system at any point of time. Somewhere down the line, there were numerous issues found out to be involved with caching. Some sample issues were application out of memory, users cannot log in, etc. I’ve seen all these problems. There were caching design defects in some of the systems I saw. Debugging was so difficult in such systems due to caching. You might wonder how a small system like this can have these issues?

Most of us, including myself, really don’t understand the caching. We just like it, think it is cool, and believe it will immediately increase performance even when we don’t have a performance issue.

I remembered I studied Operating System’s caching when I was at graduate school. I remembered we must control the size of caching, hit ratios, replace policy, and other algorithms, etc., and it was really tough even in the theoretical level.

Caching of something rarely changes, such as countries, states, etc., is fine. You really need to re-consider when designing caching of anything else. Do you really need it?

References:

  1. https://en.wikipedia.org/wiki/Cache_(computing)
  2. https://www.simple-talk.com/dotnet/asp-net/caching-the-good-the-bad-and-the-hype/

 

 

Add DLLs to Libraries in VS Solution

Struggled to add DLLs to a Libraries folder in VS TFS solution every time, and decided to write the procedure down so that I can do it faster next time.

Create ‘Libraries’ folder:

  1. Add a new solution folder ‘Libraries’ folder in the VS solution
  2. Create a ‘Libraries’ folder in the related TFS location of Source Control Explorer
  3. Check in the ‘Pending Changes’

To add DLLs to ‘Libraries’ folder of TFS:

  1. Right click the ‘Libraries’ folder in the related TFS location of Source Control Explorer
  2. Choose ‘Add Items to Folder’, browse to DLLs, and click ‘Finish’

Map (/add) DLLs from TFS to solution:

  1. Right click the VS solution, select ‘Open folder in File Explorer’, browse to the ‘Libraries’ folder
  2. Drag and drop those DLLs in the ‘Libraries’ folder of Window Explorer to ‘Libraries’ folder in the VS solution
  3. Check in the ‘Pending Changes’

Found this solution [1], adjusted it to my way.

References:

[1] – http://stackoverflow.com/questions/4971807/storing-referenced-dlls-in-visual-studio-solution-folder

 

No More In-Memory Paging!

Browsed some codes, and found a customized DataPager control. This codes behind this DataPager basically go down to database, fetch all the rows, filter the rows based on searching parameters in the memory, and display rows to UI based on page size. Amazingly, it still works due to small size of all data rows returned.

What happens if we have a million rows? thinking face

It is bad practice, and not scalable. It is not difficult to implement a paging inside the database [1]. If you use LINQ and Entity Framework, it is even easier [2][3].

References:

[1] – https://msdn.microsoft.com/en-us/library/bb445504.aspx

[2] – https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application

[3] – https://msdn.microsoft.com/en-us/library/bb738702(v=vs.100).aspx