Check for Balanced Parenthesis in a String


public static bool IsBalanced(string input)
        Dictionary<char, char> bracketPairs = new Dictionary<char, char>() {
            { '(', ')' },
            { '{', '}' },
            { '[', ']' },
            { '<', '>' }

        Stack<char> brackets = new Stack<char>();

            // Iterate through each character in the input string
            foreach (char c in input)
                // check if the character is one of the 'opening' brackets
                if (bracketPairs.Keys.Contains(c))
                    // if yes, push to stack
                // check if the character is one of the 'closing' brackets
                    if (bracketPairs.Values.Contains(c))
                    // check if the closing bracket matches the 'latest' 'opening' bracket
                    if (c == bracketPairs[brackets.First()])
                        // if not, its an unbalanced string
                        return false;
                    // continue looking
            // an exception will be caught in case a closing bracket is found, 
            // before any opening bracket.
            // that implies, the string is not balanced. Return false
            return false;

        // Ensure all brackets are closed
        return brackets.Count() == 0 ? true : false;





Add maxlength on textArea using jQuery

The Low Down

The maxlength attribute limits the number of characters that an <input> or<textarea> can accept. The maxlength attribute on textarea is new in HTML5.

  • Works for GUI-less inputs like text, email, url, search, tel and password.
  • Upon data entry, browsers will not permit the user to enter more than the characters defined by the value of the maxlength attribute: cutting off the text as-you-type and truncating pasted text. This can lead to bad user experience.
  • maxlength does not limit placeholder length.
  • If a preset value is included with a value that has more characters than the allowed length, a validation error will not be thrown. However, if that preset value is edited, yet is still longer than the allowed length, the element will become invalid, matching the :invalid pseudoclass selector, and will be prevented from being submitted in both Opera and IE10+, which both display the tooLong validity error message.
  • IE 9 reported support on both inputs and textareas but only works on inputs.



The textArea “maxlength” attribute is supported in HTML 5, the problem is not all browsers support HTML 5, especially, the old IE.


jQuery Example

A jQuery example to implement the “maxlength” effect on a textarea field.

<script language="javascript" type="text/javascript"
<script language="javascript" type="text/javascript">

    $(document).ready( function () {

	maxLength = $("textarea#comment").attr("maxlength");
" + maxLength + " remaining
); $("textarea#comment").bind("keyup change", function(){checkMaxLength(, maxLength); } ) }); function checkMaxLength(textareaID, maxLength){ currentLengthInTextarea = $("#"+textareaID).val().length; $(remainingLengthTempId).text(parseInt(maxLength) - parseInt(currentLengthInTextarea)); if (currentLengthInTextarea > (maxLength)) { // Trim the field current length over the maxlength. $("textarea#comment").val($("textarea#comment").val().slice(0, maxLength)); $(remainingLengthTempId).text(0); } }
</script> </head> <body> <h1>TextArea maxlength with jQuery</h1> <textarea id="comment" maxlength="10" rows="10" cols="60" ></textarea> </body> </html>








IIS 7.5 – uploadReadAheadSize

IIS 7.5 – uploadReadAheadSize

A developer recently reported a problem that when a customer attempted to upload an attachment, they would sometime receive the error:

The page was not displayed because the request entity is too large.

In our case it did not include an error number, but it will sometimes include the error number:


The fix for us is listed below:

How to set the uploadReadAheadSize in IIS 7.5

  1. Launch “Internet Information Services (IIS) Manager”
  2. Expand the Server field
  3. Expand Sites
  4. Select the site you want to make the modification for.
  5. In the Features section, double click “Configuration Editor”
  6. Under “Section” select: system.webServer>serverRuntime
  7. Modify the “uploadReadAheadSize” section
  8. Click Apply
– Note that the value is in BYTES

Difference between Self Signed SSL & Certificate Authority

E-commerce has played a vital role in modern technology and due to phishing and spyware attacks, it is safe to install SSL certificate on e-commerce website. Generally, Certificates are of two types one is self-signed and the rest is signed certificate. Both certificates hold well position at their personal level. It depends upon the site owner, what he will choose is a right certificate for him. There are organizations who want certificate only for encryption and there are organizations who want to increase trust in identity, legitimacy, and security.

Self-signed certificate The certificate has signed by its owner. Self-signed certificates generally utilized for testing local servers. The web browser will show a pop-up, that the web site certificate is self-signed. Such certificates are not signed by the Certificate authority. Self-signed certificates deliver the same level of security to data that flows in the tunnel between browser and server, but has no relation with the identity of the person or organization issued it, thus the owner of a web service stays anonymous. That’s why self-signed certificates are considered as untrusted.

Signed certificate is an authorized certificate issued by trustworthy certificate authority. The Secure Socket Layer is utilizing to encrypt the data between the web server and client’s browser. When client visits site it shows in address bar about the authenticity of website. It boosts confidence of customer. The information flows in tunnel is secure. The most common certified authorities are Symantec Jump Thawte Jump RapidSSL Jump GeoTrust Jump etc. Both certificates provide encrypted technology but authority only verified Signed certificate.

Drawback of Self-signed Certificate: Let’s discuss the drawbacks of self-signed certificate comparing with signed certificate.

  • Self-signed shows unauthenticated message in web address while signed certificate shows authentication message hence customer find trusted seal in address bar
  • Self-signed certificate encrypt the data but flunk to retain customer on site due to error message regarding risky behavior of web site.
  • Self-signed certificate does not allow any authority for implementation while signed certificate needs a certified authority for implementation.
  • Self-signed certificate are for testing so there is no call for to pay for a signed certificate while signed certificate is embedded with https:// and utilized for online purchase.
  • Customer scared to deal with self-signed certificate because of unsafe environment of certificate while customer gains self-assurance transacting online with signed certificate.
  • Self-signed certificate fails in E-commerce business because it does not attract customers while Signed certificate attracts customers due to its authenticity.
  • Self-signed certificate are free of cost while signed certificate are usable from $10 to $1000 per year.
  • Self-signed certificate is easy to deploy while signed certificate require following a process of deployment.
  • In Self-signed certificate private key is shared between third party and end user while in signed certificate private key is kept with end user and not shared with anyone.

If we conceive the above difference than it is admirable to deal with signed certificate because customer is the king in this competitive market hence if customer is not satisfied with your website than no need to avail such certificate.