Skip to main content

Posts

Showing posts from February, 2016

Is your code ready for the leap year?

As we enter February, it's a good time to remember that 2016 is a leap year . For most people, this may just be an interesting oddity; an extra day to work or play. But for software developers, the leap year can cause significant pain. If you are just now thinking about checking your code for leap year bugs, you better move quickly. In fact, you might already be experiencing the effects and may not even realize it! What kind of bugs might be lurking in your code? Off-by-one issues, especially around data filtering using date-range queries Unexpected or undesired behavior in user interfaces Potential for exceptions, crashes, or hanging as edge cases are encountered “Meh,” you say. “My code is just fine. We have unit tests.” “Oh really,” I say. “Do your tests properly mock the clock? Do they test edge cases including February 29 and December 31? Have you tested any low-level C++ code you might have as well as the rest of your system? Do you even know what a leap y...

Render bundle script after page load using Javascript

get bundle url and set in script tag in Head after page load  window.onload = function () {             var LayoutJsBundleUrl = ('@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/bundles/LayoutJs")');             var script = document.createElement("script");             script.src = LayoutJsBundleUrl;             script.type = "text/javascript";             document.getElementsByTagName("head")[0].appendChild(script);         } Also get bundle url from Scripts.Url("~/bundles/LoginJs")

How to convert a column number (eg. 127) into an excel column (eg. AA)

private string GetExcelColumnName ( int columnNumber ) { int dividend = columnNumber ; string columnName = String . Empty ; int modulo ; while ( dividend > 0 ) { modulo = ( dividend - 1 ) % 26 ; columnName = Convert . ToChar ( 65 + modulo ). ToString () + columnName ; dividend = ( int )(( dividend - modulo ) / 26 ); } return columnName ; } Ref:  http://stackoverflow.com/questions/181596/how-to-convert-a-column-number-eg-127-into-an-excel-column-eg-aa