"Read It Later Pro" has been ruined into Pocket, but RIL Free is still usable.

I loved RIL Pro for iPad and used it every day, but about a month ago I was forced to upgrade to new version, named Pocket.
The new version has so many problems, that it's almost unusable.
The main issue is that iPad app doesn't show many of the saved links. 
I've posted my opinion that it would be better to have  Pocket as a new separate application and recommend users to install it side by side with RIL Pro and try before replace at Pocket forum  APR 20, 2012 
I found that there a many other threads that report different issues with a new version and I've posted a few comments, supporting suggestions to fix the issues, that were broken by the Pocket.(e.g. here)
 Pocket agents answered only a  small number of questions, and many of their answers were unreasonable- like "We removed this feature because it is not convenient for our future plans"
Example of this is still stored in Google cache

24Apr I've posted a request to restore RIL Pro in AppStore until they will fix the problems in pocket.
From 27 April they introduced moderation on the public forum and stopped show new posts.
Actually "moderation" is not a correct work, it's converted the forum into Q&A site, where they show only posts with answers that they like.
Furthermore they removed many discussion threads that existed on the forum before the "moderation".
When I pointed to this in email, the answer was un-reasonable-that their forum is actually not a forum, but "a helpful support site where users can get their questions answered"
In fact users post public questions and do not see them posted for a week or forever.
For couple of my questions I received email starting with the words
    "An agent has responded to your question (Link to Question<http://readitlater.assistly.com/customer/portal/questions/306173-sync-in-ril-free-stopped-working>)."
But the link is not working, because they deleted the discussion from the forum.

At the beginning of May Pocket support answered that the  "known issue with a partial list sync" is addressed and will be in the next upgrade.
Despite the statement in upgrade notes, next upgrade didn't help with the problem(at least for me).
Support  replied to me, that  "it seems as though a small handful of users are still experiencing this sync discrepancy."

27Apr I've reported that "Sync in RIL Free stopped working" and it was on forum at least until 6 May(according Google cache)
10 May I received a reply via email(but post has been removed from the forum)
"The fix is to log out of Read It Later Free, and then log back in. Although your local cache will be cleared, the app will go through your list and re-download your items."
 It was the first useful advice after introducing Pocket. Now I am able to use RIL Free. With all it's limitation RIL Free is in much more workable conditions, than Pocket. It shows all articles that I've saved and it allowed to rename titles. The only feature from RIL Pro, that I really missing, is the ability to filter only untagged articles.

So now I can read all my saved articles in RIL Free and wait until they will fix the Pocket.

The conclusion I've had is that the Pocket company doesn't respect their customers, and I should not rely on their products too much. However the application is quite convenient, and I am familiar with it, so I will continue to use it. 

The company's  behaviour reminds me how Google changed layout of iGoogle tabs and ignored hundreds of complains. Note that recently (4 years later) Google returned to layout similar to original.

Links about SQL PIVOT

One of my colleagues asked how to create SQL query to show results as columns of a row, that actually stored in multiple rows in the table. Other co-worker suggested to use cursor to manually generate required rows.
I’ve found a few links about SQL PIVOT.  
It is easy to start with
http://www.kodyaz.com/articles/t-sql-pivot-tables-in-sql-server-tutorial-with-examples.aspx
or http://programmingsolution.net/post/SQL-Server-Pivot-Converting-Rows-to-Columns-with-Dynamic-Query.aspx

More detailed are articles written by Itzik Ben-Ganhttp://www.sqlmag.com/article/tsql3/pivot-or-unpivot-your-data
and
http://www.sqlmag.com/content1/topic/pivot-or-unpivot-your-data/catpath/tsql3/page/2compaslightly  

How to use Pivoting Without Aggregation is described inhttp://www.sqlmag.com/article/tsql3/pivoting-without-aggregation

Log JavaScript errors to the server.


Some time ago I found debugging - Automatic feedback on JavaScript error - Stack Overflow.  
and the discussion has  links to
Logging JavaScript Errors To ASP.NET(Unfortunately the link to download in the post is broken).
and custom control to help log JavaScript errors by sending error information to the server -thecodepage.com/post/JavaScript-Error-Notifications.aspx.
I’ve downloaded solution from  JSErrorNotifier.zip. When I wanted to include dll into my solution dependencies,  I decided to rename WebControls.DLL to more descriptive JSErrorNotifier.DLL.
I also decided to rename default namespace to be the same as DLL name.
It wasn’t a good idea, because control stopped to work. It took me some time and I had to call  StreamHelper.EnsureWebResourceValid function from my old post Check that embedded resource exist before calling ClientScript.RegisterClientScriptResource or GetWebResourceUrl
to do all consistent changes for namespace renaming.

Finally when I made control working again, I found that it doesn’t work in IE 9. After another half an hour of debugging I found that for my IE9 onerror event is not fired even for example from MS documentation
http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onerrorEX.htm.
It worked on other browsers and on IE8, but on IE9 you need to disable script debugging in Internet Explorer (Tools, Internet Options, Advanced). The  same happens if IE9 changed to IE7 or IE8 mode.(Actually I’ve noticed that Developer Tools Browser mode IE7 or IE8 do not emulate correctly native script engine of older IE versions)

However native IE8 on XP fires onerror regardless if debugging is enabled or disabled.

I hope that not too many IE9 users with enabled debugging will have  JS errors in our application.

Case-insensitive Contains extension for list of strings

I wanted to have case-insensitive Contains method for list of strings.
Overload Enumerable.Contains<TSource> Method (IEnumerable<TSource>, TSource, IEqualityComparer<TSource>) expects custom IEqualityComparer class.I was about to create my own class IgnoreCaseEqualityComparer : IEqualityComparer<string>,
but then found StringComparer.Create Method, that allow to use standard class.

public static bool ContainsString(this IEnumerable<string> collection, string toFind, bool ignoreCase = true)
{
return collection.Contains(toFind,
StringComparer.Create(CultureInfo.InvariantCulture, ignoreCase));
}

Select tool to minimize JavaScript and CSS size

There are multiple ways and techniques how to combine and minify JS and CSS files.
The good number of links can be found in http://stackoverflow.com/questions/882937/asp-net-script-and-css-compression
and in http://www.hanselman.com/blog/TheImportanceAndEaseOfMinifyingYourCSSAndJavaScriptAndOptimizingPNGsForYourBlogOrWebsite.aspx

There are 2 major approaches- do it during build or at run-time.

In our application there are multiple user-controls, each of them required different JS or CSS files, and they loaded dynamically in the different combinations. We decided that loading all JS or CSS files for each page is not a good idea, but for each page we need to load different set of files.
Based on this combining files on the build stage does not looks feasible.
After Reviewing  different links I’ve decided that squishit should fit to our needs. http://www.codethinked.com/squishit-the-friendly-aspnet-javascript-and-css-squisher

Different limitations of using SquishIt.
We had some browser specific CSS files, that loaded conditionally depending of browser type(i.e IE and all other browsers). We had to put them in separate bundles,

For Resources and AXD files we decide to use HttpModule and HttpHandler created by Mads Kristensen

To GZIP html we are using wwWebUtils.GZipEncodePage() http://www.west-wind.com/weblog/posts/2007/Feb/05/More-on-GZip-compression-with-ASPNET-Content Just swap the order of which encoding you apply to start by asking for deflate support and then GZip afterwards.

Additional tips about SquishIt.

Use CDN: https://groups.google.com/group/squishit/browse_thread/thread/99f3b61444da9ad1
Support intellisense and generate bundle in codebehind http://tech.kipusoep.nl/2010/07/23/umbraco-45-visual-studio-2010-dotless-jquery-vsdoc-squishit-masterpages/

Links about other Libraries that were considered

A few links from http://stackoverflow.com/questions/5288656/which-one-has-better-minification-between-squishit-and-combres2

.Net 4.5 will have out-of-the-box tools for JS/CSS combining.
http://weblogs.asp.net/scottgu/archive/2011/11/27/new-bundling-and-minification-support-asp-net-4-5-series.aspx . It suggests default bundle of subfolder, but also seems supporting similar to squishit explicitly specified files.

http://www.codeproject.com/KB/aspnet/combres2.aspx  config XML file can specify expiry etc

https://github.com/andrewdavey/cassette
http://stackoverflow.com/questions/7026029/alternatives-to-cassette

Dynamically loaded JS files requireJS http://requirejs.org/docs/start.html  

http://www.west-wind.com/weblog/posts/2008/Jul/07/Inclusion-of-JavaScript-Files
Pack and minimize your JavaScript code size

YUI Compressor (from Yahoo)
JSMin (by Douglas Crockford)
ShrinkSafe (from Dojo library)
Packer (by Dean Edwards)

RadScriptManager  & RadStyleSheetManager -fromTeleric(not free)

Tools to optimize performance:

PageSpeed tools family http://code.google.com/intl/ru/speed/page-speed/download.html



v

ReplaceBetweenTags function with delegate to describe transformation

I've created a function that allow to replace content between XML tags with data, that depend on original content within tag, in particular to MAsk credit card number.

The function uses MidBetween extension from My StringHelper class

 /// <summary>
///
/// </summary>
/// <param name="thisString"></param>
/// <param name="openTag"></param>
/// <param name="closeTag"></param>
/// <param name="transform"></param>
/// <returns></returns>
/// <example>
/// // mask <AccountNumber>XXXXX4488</AccountNumber>
///requestAsString  = requestAsString.ReplaceBetweenTags("<AccountNumber>", "</AccountNumber>", CreditCard.MaskedCardNumber);
///mask cvv
///requestAsString = requestAsString.ReplaceBetweenTags("<FieldName>CC::VerificationCode</FieldName><FieldValue>", "</FieldValue>", cvv=>"XXX");
/// </example>
public static string ReplaceBetweenTags(this string thisString, string openTag, string closeTag,
Func<string, string> transform)
{
//See also http://stackoverflow.com/questions/1359412/c-sharp-remove-text-in-between-delimiters-in-a-string-regex
string sRet = thisString;
string between = thisString.MidBetween(openTag, closeTag, true);
if (!
String.IsNullOrEmpty(between))
sRet=thisString.Replace(openTag + between + closeTag, openTag + transform(between) + closeTag);
return sRet;
}
public static string ReplaceBetweenTags(this string thisString, string openTag, string closeTag, string newValue)
{
//See also http://stackoverflow.com/questions/1359412/c-sharp-remove-text-in-between-delimiters-in-a-string-regex
string sRet = thisString;
string between = thisString.MidBetween(openTag, closeTag, true);
if (!
String.IsNullOrEmpty(between))
sRet = thisString.Replace(openTag + between + closeTag, openTag + newValue + closeTag);
return sRet;
}

Code style Tip: Case insensitive string comparison

Good
if (String.Compare(myString, ALL_TEXT, StringComparison.OrdinalIgnoreCase) == 0)
                               {
                                        return true;
                               }
OK(not obvious what true means)

if (String.Compare(myString, ALL_TEXT, true) == 0)
                               {
                                        return true;
                               }
BAD: (non null safe)

if (myString.ToLower()==ALL_TEXT.ToLower()
                               {
                                        return true;
                               }

Dump an arbitrary object To Html String

For debugging purposes me and my collegue wanted to dump details of the arbitrary object, and created function that uses LINQPad Dump functionality (thanks to http://stackoverflow.com/a/6035014/52277 and original http://linqpad.uservoice.com/forums/18302-linqpad-feature-suggestions/suggestions/447166-make-dump-extension-method-available-in-visual-s discussion)
   public static string DumpToHtmlString<T>(this T objectToSerialize)
       {
           string strHTML =
"";

           try
           {
               var writer = LINQPad.
Util.CreateXhtmlWriter(true);
               writer.Write(objectToSerialize);
               strHTML = writer.ToString();
           }
           catch (
Exception exc)
           {
               
Debug.Assert(false, "Investigate why ?" + exc);
           }

           return strHTML;
       }

You will need to add the linqpad executable as a reference in your project.


TO DO similar in plain text ,look at https://github.com/ServiceStack/ServiceStack.Text StringExtensions , e.g. JsonSerializer/CsvSerializer

or http://objectdumper.codeplex.com/

Disable messages from SQL Server “Login failed for user” in Event log

I’ve noticed multiple messages from SQL Server in EventLog on my machine
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors. [CLIENT: 10.222.25.129]
I’ve found that there are machines of my co-workers, but they were not sure, which processes tried to access my SQL server.

I’ve tried a few things and finally in SQL Server Configuration Manager disabled tcp, as it was suggested in
http://blogs.msdn.com/b/psssql/archive/2010/03/09/what-spn-do-i-use-and-how-does-it-get-there.aspx

Specify Linq To SQL ConnectionString explicitly

When modifying Linq to  Sql data model in Visual Studio 2010,  it re-assigns ConnectionString that is available on developer’s machine.
Because the name can be different on different machines, Designer often replace it with something like ConnectionString1, which causes errors during deployment.
It requires developers to ensure that ConnectionString stays unchanged.
 
More reliable way is to use context constructor with explicit ConnectionString name instead of parameterless default constructor

GOOD:
  var ctx = new MyModelDataContext(Settings.Default.ConnectionString);
Not good:
         var ctx = new MyModelDataContext();

Do not expose enum in WCF response

We had a backward compatibility problem in WCF client, when in Service application a new value was added to one of enums. We discussed different ways to avoid this backward compatibility issues, and I found recommendation do not expose enum in wcf response in http://stackoverflow.com/a/788281/52277.

It is still required to create new versions of our service interfaces to replace each enum fields with string field, that expects only documented values, and describe, what should be default behavior, if field has an unexpected value.

Visual Studio 10 crashed when tried to open one of solutions

Visual Studio 10 crashed when I tried to open  one of my solutions. Closing Visual Studio and rebooting the machine didn’t help.
The error message that was logged(see below), didn’t give any useful ideas.
Finally It was fixed after I’ve deleted MySolution.suo file, which was quite big, and also Resharper folders.

Log Name:      Application
Source:        Application Error
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Description:
Faulting application name: devenv.exe, version: 10.0.40219.1, time stamp: 0x4d5f2a73
Faulting module name: msenv.dll, version: 10.0.40219.1, time stamp: 0x4d5f2d48
Exception code: 0xc0000005
Fault offset: 0x00355770
Faulting process id: 0x1dc0
Faulting application start time: 0x01cd1836888599f4
Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
Faulting module path: c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\msenv.dll
Report Id: 9924b2f9-844e-11e1-bc19-782bcba513ea
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
 <System>
   <Provider Name="Application Error" />
   <EventID Qualifiers="0">1000</EventID>
   <Level>2</Level>
   <Task>100</Task>
   <Keywords>0x80000000000000</Keywords>
   <TimeCreated SystemTime="2012-04-12T03:21:31.000000000Z" />
   <EventRecordID>401998</EventRecordID>
   <Channel>Application</Channel>
   <Security />
 </System>
 <EventData>
   <Data>devenv.exe</Data>
   <Data>10.0.40219.1</Data>
   <Data>4d5f2a73</Data>
   <Data>msenv.dll</Data>
   <Data>10.0.40219.1</Data>
   <Data>4d5f2d48</Data>
   <Data>c0000005</Data>
   <Data>00355770</Data>
   <Data>1dc0</Data>
   <Data>01cd1836888599f4</Data>
   <Data>C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe</Data>
   <Data>c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\msenv.dll</Data>
   <Data>9924b2f9-844e-11e1-bc19-782bcba513ea</Data>
 </EventData>
</Event>v

Translate jQuery UI Datepicker format to .Net Date format

I needed to use the same date format in client jQuery UI Datepicker and server ASP.NET code. The actual format can be different for different localization cultures.

I decided to translate Datepicker format to .Net Date format similar as it was asked to do opposite operation in http://stackoverflow.com/questions/8531247/jquery-datepickers-dateformat-how-to-integrate-with-net-current-culture-date

Note that replace command need to replace whole words and order of calls is important

Function that does opposite operation (translate  .Net Date format toDatepicker format) is described in
http://www.codeproject.com/Articles/62031/JQueryUI-Datepicker-in-ASP-NET-MVC


/// <summary>
/// Uses regex '\b' as suggested in //http://stackoverflow.com/questions/6143642/way-to-have-string-replace-only-hit-whole-words
/// </summary>
/// <param name="original"></param>
/// <param name="wordToFind"></param>
/// <param name="replacement"></param>
/// <param name="regexOptions"></param>
/// <returns></returns>
static public string ReplaceWholeWord(this string original, string wordToFind, string replacement,
RegexOptions regexOptions = RegexOptions.None)
{

string pattern =
String.Format(@"\b{0}\b", wordToFind);
string ret=
Regex.Replace(original, pattern, replacement, regexOptions);
return ret;
}

/// <summary>
/// E.g "DD, d MM, yy" to ,"dddd, d MMMM, yyyy"
/// </summary>
/// <param name="datePickerFormat"></param>
/// <returns></returns>
/// <remarks>
/// Idea to replace from http://stackoverflow.com/questions/8531247/jquery-datepickers-dateformat-how-to-integrate-with-net-current-culture-date
///From http://docs.jquery.com/UI/Datepicker/$.datepicker.formatDate to http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
///Format a date into a string value with a specified format.
///d - day of month (no leading zero) ---.Net the same
///dd - day of month (two digit) ---.Net the same
///D - day name short ---.Net "ddd"
///DD - day name long ---.Net "dddd"
///m - month of year (no leading zero) ---.Net "M"
///mm - month of year (two digit) ---.Net "MM"
///M - month name short ---.Net "MMM"
///MM - month name long ---.Net "MMMM"
///y - year (two digit) ---.Net "yy"
///yy - year (four digit) ---.Net "yyyy"
/// </remarks>
public static string JQueryDatePickerFormatToDotNetDateFormat(string datePickerFormat)
{

string sRet = datePickerFormat.ReplaceWholeWord(
"DD", "dddd").ReplaceWholeWord("D", "ddd");
sRet = sRet.ReplaceWholeWord(
"M", "MMM").ReplaceWholeWord("MM", "MMMM").ReplaceWholeWord("m", "M").ReplaceWholeWord("mm", "MM");//order is important
sRet = sRet.ReplaceWholeWord(
"yy", "yyyy").ReplaceWholeWord("y", "yy");//order is important
return sRet;
}

Copy to local drive before running installations

I've downloaded Windows Identity Foundation from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=17331,
but when I  was trying to install, it returned
---------------------------
Windows Update Standalone Installer
---------------------------
Installer encountered an error: 0x80070003
The system cannot find the path specified.

---------------------------
I’ve tried a few other similar downloads, and all had the same error,
Finally I’ve realized, that they don’t want to run from shared drive.
After I’ve copied to local drive  Windows6.1-KB974405-x64.msu, I was able to install it.

Extract substrings starting with known text from long lines

I’ve received a .csv report from TripWire logs, where each entry is a long text strings.
I needed to extract some substring from each row, e.g “ErrorCode: ABC1234” where preceding text is constant, but actual error code could be different.
In TSQL I can do someting similar using patIndex and substring, e.g.
select text,substring(TEXT,PATINDEX ('%ErrorCode:%',TEXT),10)

In C# I can do it using RightAfter and TrimLength from My StringHelper
RightAfter(Text,”ErrorCode:”).TrimLength(10)  

But I was able to do it In Visual Studio Editor using replace and tick ‘Use regular expressions”

Find what
^.*ErrorCode:
replace with
ErrorCode:

I would appreciate suggestions to do similar extracts using other tools.

Related post

Remove empty lines in text using Visual Studio.

«May»
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789