Posts

HTML Scrubbing !

Just very recently I extended a little help to one of my UI developers (an Angular one :-)) and thought I'd share with the community a little piece of C# code.. Context : As with many legacy application data, we ran into one that has persisted a lot of garbage HTML data, copy-pasted from a Rich Text Editor, without application validating much of it..That accumulated a lot of HTML code persisted, when read and displayed using Angular.js framework, did not display the right content. The right content was intended to strip off all the HTML tags including &nbsp; as well. The below little utility as C# static function does exactly what I intend to put forth the above context..         public static string ScrubHtml(string value)         {             var step1OfScrubbedHtml = Regex.Replace(value, @"<[^>]+>|&nbsp;", "").Trim();             var step2OfScrubbedHtml = Regex.Replace(step1OfScrubbedHtml, @"\s{2,}", " ");

QuadKey - what it is?

Image
To start with, let me share an excerpt from MSDN as below: Bing Maps Tile System (Reference:   https://msdn.microsoft.com/en-us/library/bb259689.aspx ) Bing Maps provides a world map that users can directly manipulate to pan and zoom. To make this interaction as fast and responsive as possible, we chose to pre-render the map at many different levels of detail, and to cut each map into tiles for quick retrieval and display. This document describes the projection, coordinate systems, and addressing scheme of the map tiles, which collectively are called the Bing Maps Tile System. So if you follow the above references Bing Maps Tile System, you would get an idea that  - how the world map is kind of apportioned into a tile system and depending on what level of detail or zoom you are interested in, you would get a <N> character long quad-key.  For what I am involved with currently, we care to go for the maximum allowable detail to uniquely identify each geo-location,

Yep! Canadians are the nicest people on the planet.

Image
A recent travel story posted on BBC travel site prompted me to write this up on my humble blog and more than that, makes me feel proud Canadian, sharing with you all ... Pretty much everything is relative, at least from my perspective - and this blog is about it, isn't it? Our behavior is observed and compared vis-a-vis someone else's and having myself spent significant amount of time in 3 different continents - I agree 200% with the writer of this post on BBC.

KISS Principle - Your website should be so SIMPLE, a drunk person could use it.

Image
What in the world we are talking about? A drunk person playing with a web site to ensure it is 'tested' in a realistically simplistic nature !! Yes, these days you can hire a person for $150 - who would get drunk and jump on browsing on your website - with an objective of ensuring it is usable by pretty much anyone :-) Refer this link on the geek.com for a ping-back POST.

XSL1.0 String.Replace() is missing! How can that be achieved?

A couple of months ago, one of my team members, Ali Chaudhary dealt with an issue for which XSL 1.0 is in place and couldn't really figure out the String replacement feature in it .. until he hit the following URL .. seems there is always a way to achieve what you want to ...  http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx

Using T-SQL Convert LOCAL datetime to UTC datetime value using UTC offset (defined)

While working on some things recently, I figured there is an easy way to convert (using T-SQL) local time to UTC departure time … and that is leveraging built-in DATEADD function   Reference http://technet.microsoft.com/en-us/library/ms186819.aspx The key is using the right offset value for calculating UTC .. in the scenario that we dealt with, the database has Offset defined in minutes and is based on the offset/difference in minutes FROM UTC time so to convert the captured local date time to UTC.. the following works just fine .. DATEADD ( mi , - < UTCOffsetValue> , <LOCALDateCaptured> )    // mi - minutes As an example for offset, Canada EST (with Daylight) has the value for the Offset defined as -300 [5 hours behind of UTC] whereas for France it is defined as + 60 [1 hour ahead of UTC]

SQL Server database is Case In-Sensitive - is a MYTH!

The case sensitivity or insensitivity depends on the collation applied to the column or at the DB level .. Normally, the default collation is ‘CI’ but please remember it is not always ‘Case Insensitive’  If you run the below query on any particular db server .. SELECT SERVERPROPERTY ( 'COLLATION' )   what you could retrieve the data value, normally would be,  Latin1_General_CI_AS  (CI – Case Insensitive, AS – Accent Sensitive) But it could also be something like this …   Latin1_General_CS_AS  (CS – in this case, it is Case Sensitive)        So though it may take an additional 1/100 th of a nano-second, I'd generally prefer to UPPERize the string comparison such as below … UPPER(SUBSTRING ( COMMENT_ , 1 , 8 )) = ' Schedule '  instead of exact match such as SUBSTRING(COMMENT_, 1, 8) = 'Schedule'