Friday, December 20, 2013

How To Count Number of Lines in Multiple Files

At work we normally work with large files and I wanted to count a number of lines in multiple files. There are many ways to do this, however the following command did the trick:

findstr /R /N "^" MyText*.TXT | find /C ":"

The above command will count all the number of lines in all text files that starts with "MyText". This command can sometimes take time to execute especially when dealing with large files.

I believe that there are other ways to count numbers of lines in  multiple files. The following links can be very helpful as well:




Monday, February 18, 2013

Nancy.Json.JsonSettings.MaxJsonLength Exceeded

I was working on the web app which reads data from MongoDB and return the results to the UI as Jason using nancy. However I experienced the following error while returning a large chunk of data:-

Nancy.Json.JsonSettings.MaxJsonLength Exceeded

The data returned was so huge that it exceeded the max jason length (102400). The good news is that you can increase the max json length so that it caters for large amounts of data, this is how you can do this using c# :-

 JsonSettings.MaxJsonLength = Int32.MaxValue;

The above code will increase the max length from 102,400 to 2,147, 483, 647

A potentially dangerous Request.Path value was detected from the client (&).

I came across the the following error while testing one of company's web app:


A potentially dangerous Request.Path value was detected from the client (&).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (&).


Well the error is self-explanatory, my URL contained an illegal character (&). An alternative to resolve this error is through the use of  "requestPathInvalidCharacters " in your web.config file. You can implement this as follows:-

  <system.web>
    <httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,%,:,\" />
  </system.web>
 
The above should solve the problem. You can either choose to lock this down to a particular location, as recommended by one of the members of Stack Overflow:-


<location path="the/path/you/need/to/lock/down">
    <system.web>
        <httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,%,:,\"/>
    </system.web>
</location>
The above approach is even more safe because you only locking it down to a particular location, rather than exposing this to the whole site.


Regards,
Mpho

Monday, October 29, 2012

Windows Task Scheduler Error 2147944309

At work we had issues with our scheduled job as they failed to start. The error we were getting was not helpful either, so the error value was 2147944309.

Basically the Error Value 2147944309 tells you that the account you are using to run the batch has been locked out.

Below is an explanation of the error:


0n2147944309 = 0x80070775

Facility: 8007 = Win32 (it's a "Win32" status code)

Status: 0x775 = 0n1909


if you go to your command prompt and type in the following command c:\net helpmsg 1909, you will acually get the error message and that is:

The referenced account is currently locked out and may not be logged on to

Regards,
Mpho




Thursday, September 9, 2010

Google Scribe

Hey folks!

I didn't know there is something called Google Scribe. It's actually provide you with text autocomplete service. It auto suggest words as you type, I guess this could save you typing time :)

You can play around with the tool at http://scribe.googlelabs.com/

Great Stuff Google !!!