Nirav Patel’s Weblog

10 Tips For Effective Reading And Learning

Posted by Nirav Patel on May 23, 2008

 

  1. Relax Before Reading
    Concentration is key factor of effective reading and learning. You will need to relax your mind and swipe off your thoughts. You brain need to be empty by thoughts before you start the reading. It is like giving space to new thoughts which are going to be arise during your reading. Your emotions need to be in neutral before reading. That will give you chance to evaluate your reading. You can do some meditation or listen to soft music before start of reading. Most of all fighter pilots and F1 racers adopt this technic before go to the flight or in race. Try it, it is really effective. 
  2. Go Slow with the Reading
    Never do hurry with your reading. Don’t just read. Go very slow with reading. Try to understand each and every word written by author. Try to ask questions to your own self and find the answer. The more deeply you force your brain to think, the better chance you have of learning and remembering.
  3. Take Challenges of Exercises.
    Authors keep exercises in book for you. But what if they do that for you? You will never take challenge to do that. It will be like, you have hunger and somebody is eating on behalf of you….
  4. Write Your Own Notes In Book
    Its not bad to use Pencil to writ something in your books. You can write lots of your own notes in book. It is really good practice to improve your understanding of what you are reading. Some people don’t like to write anything into book, as book get spoil. In this case you can write your notes into separate notebook or even you can use sticky notes. But please write your thoughts.
  5. Give Enough Time To Your Brain
    The process of transferring the reading into long-term memory happens after stop reading. Our brain needs time to do processing. If we keep anything new or challenging during the processing time, Some of what you learned might be lost. It is recommended to read before you go to bed.
  6. What Your Brain Need?
    The performance of Brain is depend on lots of things. But we can follow few basic things to make it more efficient. The brain works best in a nice bath of fluid. Research said that Dehydration decreases cognitive function of brain. The dehydration can happened before we feel thirsty. So, keep drinking enough water while reading [But this also can cause lots of washroom visit and can break your concentration, so keep it in your own limit]. Brain also need good sound sleep. To learn at it’s best, give enough sleep to you brain [At least 6-8 hours]. And last but not least, you brain need food. Please eat proper to nourish your brain. Protein, Vitamins, Sodium and Iodine are very important for your brain.
  7. Speak it out Loud.
    Speaking activates a different part of your brain. If you are trying to understand something, or increase your chance of remembering it later, say it out loud. You can discuss what you have learned or read with some of your friend (Or even with your own self in front of mirror). The discussion will bust the confidence in you. And you will see that you are learning quickly. During discussion you might come out with new ideas you had not known were there when you were reading about it.
  8. When To Stop
    You should know that when to stop reading. Your brain may overloaded. You should understand the limitation of your brain (I can not read more then 45 minutes in row, it’s limitation of my brain). Now one very obvious question, how to know when to stop? If you find yourself starting to forget what you just read, or the characters start dancing on page, then that is the right time to stop reading and have some break.
  9. Feel it !!
    You must feel the importance of what you are reading or learning. Your brain need to take the reading seriously to learn effectively. Your brain will never take the reading seriously if it don’t know the importance of that. 
  10. Practices
    Apply what you have read in your life. Try to put that in your everyday practice. Theoretical and practical both are the different knowledge. You need to apply your theoretical knowledge in your practical life. Coz all reading and learning will not matter until you start practicing that in your routine life. Books will show you the path (Theory) but to walk on the path (Practical) is your responsibility. I might have read everything written or printed about the Everest, but to archived the Everest is complete different thing. My reading and knowledge about the Everest only worth if, I climb and archived the Everest.

Posted in Technology | No Comments »

SQL Server Reporting Service (SSRS) - HTTP Status 401 Unauthorized Error

Posted by Nirav Patel on May 21, 2008

I am going to continue on writing article on SQL Server Reporting Services (Its because, it is providing me good fame on http://forums.asp.net, LOL).

We have to deploy the reports on the the Reporting Services Virtual Directory (I can write the whole different article on the Reporting Deployment, but may be next time. Right now we don’t want to go deep into that.). The Reporting Server Virtual Directory may exist on the different server. It is recommended to keep anonymous access off for Reports virtual directory if you are going to call reports on the web.

The anonymous access allows any user to access the page. But now when we are keeping anonymous access off for the Reports, it can create problem while fetching the report inside the Report Viewer control on any ASPX page.

The Report server will expect authorized user to access the reports. This can be done by two ways.

  1. Passing the Report Server User Credentials with the Reports.
  2. Forms Authentication on Reporting Server.

Today, I am going to explain that How can we pass the User Credentials of the Reporting Server with the report call.

We need to Create one sealed class to perform this action. This class need to be inherited from IReportServerCredential interface.

    [Serializable]
    public sealed class ReportServerNetworkCredentials : IReportServerCredentials
    {
        #region IReportServerCredentials Members

        /// <summary>
        /// Provides forms authentication to be used to connect to the report server.
        /// </summary>
        /// <param name="authCookie">A Report Server authentication cookie.</param>
        /// <param name="userName">The name of the user.</param>
        /// <param name="password">The password of the user.</param>
        /// <param name="authority">The authority to use when authenticating the user, such as a Microsoft Windows domain.</param>
        /// <returns></returns>
        public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string userName,
            out string password, out string authority)
        {
            authCookie = null;
            userName = null;
            password = null;
            authority = null;

            return false;
        }

        /// <summary>
        /// Specifies the user to impersonate when connecting to a report server.
        /// </summary>
        /// <value></value>
        /// <returns>A WindowsIdentity object representing the user to impersonate.</returns>
        public WindowsIdentity ImpersonationUser
        {
            get
            {
                return null;
            }
        }

        /// <summary>
        /// Returns network credentials to be used for authentication with the report server.
        /// </summary>
        /// <value></value>
        /// <returns>A NetworkCredentials object.</returns>
        public System.Net.ICredentials NetworkCredentials
        {
            get
            {
                string userName = "SERVERUSERNAME";
                string domainName = "DOMAIN";
                string password = "somepassword";

                return new System.Net.NetworkCredential(userName, password, domainName);
            }
        }

        #endregion
    }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

How to Utilize the ReportServerNetworkCredentials Class in your Report call on Page_Load event…

protected void Page_Load(object sender, EventArgs e)
{
    myReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;

    // Here we are going to pass the ReportServerCredentials to the Report Viewer.
    myReportViewer.ServerReport.ReportServerCredentials = new ReportServerNetworkCredentials();

    ReportServerLoaction = ConfigurationManager.AppSettings["REPORT_SERVER_PATH"];
    myReportViewer.ServerReport.ReportServerUrl = new Uri("http://MyReportServer/Reports/");
    myReportViewer.ServerReport.ReportPath = "TempReports/MyFirstReport";
    myReportViewer.ShowParameterPrompts = false;
    myReportViewer.ShowPrintButton = true;

    Microsoft.Reporting.WebForms.ReportParameter[] reportParameterCollection = new Microsoft.Reporting.WebForms.ReportParameter[1];
    reportParameterCollection[0] = new Microsoft.Reporting.WebForms.ReportParameter();
    reportParameterCollection[0].Name = "ClientID";
    reportParameterCollection[0].Values.Add("49020644-63AA-4D92-81A1-8F85D49ACF67");

    myReportViewer.ServerReport.SetParameters(reportParameterCollection);
    myReportViewer.ServerReport.Refresh();
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Please feel free to comment on the article. Critics are highly appreciated.

Posted in .Net 2.0, .Net 3.5, SQL Server, SQL Server Reporting Services, SSRS, Technology | No Comments »

SQL Server Reporting Services (SSRS) Versus Browser Compatibility

Posted by Nirav Patel on May 10, 2008

Microsoft has released SQL Server Reporting Services(SSRS) as server based report generation and development environment in 2004. It was released as SQL Server 2000 extension. SSRS has been released directly to the competition of Crystal Report and other Business Intelligence tools. The current version of SSRS is shipped with SQL Server 2005.

The file format of SSRS reports is .rdl. The RDL is XML. The RDL can be exported to PDF, XML, Excel, TIFF, CSV, HTML. Apart from this, you can call the report by simple URL.

Sounds Good…!!!!!

But, with all this coolest features of SSRS, there are plenty of bugs too. First ever bug I encounter is Browser Compatibility. There is pretty big issue with SSRS reports browser compatibility. The reports are best view in only IE6 and above. In this competitive world, we need to provide browser compatible websites. SSRS can be big hurdle in your website against browser compatibility.

We experienced a problem with the multivalue parameter dropdown in ReportViewer control in FireFox. It was working fine in IE. The calendar control and the multivalue dropdown was having problem. The problem caught me when I click on the calendar control, the calendar appears and then quickly disappeared before I can select anything. It was just in frequence of second. Wow, it was pretty quick and it became a challenging game for me to catch it. But Microsoft was very quick and I never could catch calendar.

The problem was with ReportViewer control provided by VS2005. When we call report directly in Firefox browser using report URL, it was working perfectly fine. So, finally we came to conclusion that, the problem is only due to ReportViewer control.

The solution to resolve the issue is very strange. We need to remove the DOCTYPE tag from the HTML. Removing DOCTYPE tag can create lots of issues with HTML and CSS layouts. But we have to rectify other issues.

Developers of ReportViewer control has used some nonstandard methods and attributes like onactive event. The page contains specific DOCTYPE, will not parse such events. We tried to use other DTDs like, HTML 4.0 and HTML 5.0 but nothing help. Finally we removed the DOCTYPE and problem get solve (And other design related problem start arising).

For more in SSRS please visit Paresh Jagatiya’s Weblog.

Posted in .Net 2.0, SQL Server, SQL Server Reporting Services, SSRS | No Comments »

Date Format Conversion

Posted by Nirav Patel on May 2, 2008

The whole world is divided into different time zones and cultures. Every country has own style to display date and time format. Like, in USA the date has been displayed in “mm/dd/yyyy” format while in Great Britain and India the date has been displayed in “dd/mm/yyyy” format. In the web era, it’s always tough to provide culture oriented user interface. It is easy to display the date in specific format on page using ASP.net. Programmer can easily use .ToString(“dd/mm/yyyy”); to display the date into British format. But it’s not easy to store date into server with formatting.

Let’s take one scenario to understand this, I have a webpage which sense the user’s current time zone and display the date according to that. But the website is hosted on the USA based server. So the SQL Server for the Website will have the “mm/dd/yyyy” format. The SQL Server will expect the date in “mm/dd/yyyy” format. This can create problem when we provide such user interface which accept the date into “dd/mm/yyyy” format. We have to convert the date back into server’s date format before saving into database.

There is no any direct method to convert the date format with DateTime type. Probably Convert.ToDateTime() provide such facility with iFormatProvider interface. But, I really don’t know how to use that. So, I found one another work-around to convert the date in other format.

It’s very tricky to convert the date format from “dd/MM/yyyy” to “mm/dd/yyyy” in .Net 2.0. Below is function, using that programmer can convert any date in any format to the server’s date format.


public DateTime ConvertDate(string Date, string CurrentDateFormat)
{
    try
    {
        return DateTime.ParseExact(Date, CurrentDateFormat, new CultureInfo(Thread.CurrentThread.CurrentCulture.Name));
    }
    catch
    {
        throw;
    }
}

Posted in .Net 2.0, Technology | Tagged: , , , , | No Comments »

Credit Card Validations

Posted by Nirav Patel on January 22, 2008

Credit Card transaction is one of the important parts of all e-commerce websites. There are lots of Credit Card Payment Gateways, which help you to authenticate credit cards. But almost all credit card payment gateways took very long time to respond back. And that might cause performance issue with our developed website.

We can reduce the payment gateway server trips by validating the credit cards in our system itself. As per my experience, most of the time the customer enters wrong credit card number and that cause the waiting time. We can validate those numbers in our system itself using JavaScript or server validators (i.e. Custom Validator in ASP.Net). We can achieve this using Regular Expression. But first let’s start with some facts with Credit Card Numbers… There are total 5 types of widely accepted credit cards, Visa, Master Card, American Express, Diners Club and Discover. The card number pattern is depending on the type of card. The number pattern consists of the length of Card Number and the number prefix.

 

Card Type Prefix Length Example
Visa 4 16 4563 2214 3215 8542
Master Card 51 to 55 16 5147 2254 6585 4521
American Express 34
37
15 3422 4587 9874 125

3741 5478 9854 654

Diners Club 30
36
38
14 3000 2544 8874 12
3685 1475 8544 32

3874 8745 6654 85

Discover 6011 16 6011 7415 6587 2265

 

We can validate these credit cards using regular expression. Find below table of the regular expression for each credit card type.

Card Type Regular Expression
Visa ^4\d{3}-?\d{4}-?\d{4}-?\d{4}$
Master Card ^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$
American Express ^3[4,7]\d{13}$
Diners Club ^3[0,6,8]\d{12}$
Discover ^6011-?\d{4}-?\d{4}-?\d{4}$

 

Below is the example of a validation function of Java Script for the Credit Card Validation using Regular Expression and “mod 10” algorithm…

This code validate the credit card using Regular Expression and the “mod 10” algorithm. All the card has different prefix and the length. We are using regular expression to validate the card length and prefix. After the card number has the right prefix and correct length, a “mod 10” validation is performed on the credit card number. Cards with an even number of digits go through differently than cards with an odd number of digits (American Express). Every other digit, starting with the second digit (first digit for American Express) is added together. Then a second pass is made, again with every other digit, starting this time with the first digit (second digit for American Express). During this second pass, each digit is multiplied by 2. If the digit multiplied by 2 is greater than or equal to 10, the total minus 9 is added to the original sum from the first pass. If the digit multiplied by 2 is less than 10, that total is added to the original sum from the first pass. After the two passes, the total should be evenly divisible by 10. This is the check that the JavaScript code goes through to validate the credit card.

function isValidCreditCard(type, ccnum)
{
    if (type == "Visa")
    {
        // Visa: length 16, prefix 4, dashes optional.
        var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
    }
    else if (type == "MC")
    {
        // Mastercard: length 16, prefix 51-55, dashes optional.
        var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
    }
    else if (type == "Disc")
    {
        // Discover: length 16, prefix 6011, dashes optional.
        var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
    }
    else if (type == "AmEx")
    {
        // American Express: length 15, prefix 34 or 37.
        var re = /^3[4,7]\d{13}$/;
    }
    else if (type == "Diners")
    {
        // Diners: length 14, prefix 30, 36, or 38.
        var re = /^3[0,6,8]\d{12}$/;
    }

    if (!re.test(ccnum)) return false;

    // Remove all dashes for the checksum checks to eliminate negative numbers
    ccnum = ccnum.split("-").join("");

    // Checksum ("Mod 10?)
    // Add even digits in even length strings or odd digits in odd length strings.
    var checksum = 0;

    for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2)
    {
        checksum += parseInt(ccnum.charAt(i-1));
    }

    // Analyze odd digits in even length strings or even digits in odd length strings.
    for (var i=(ccnum.length % 2) + 1; i     {
        var digit = parseInt(ccnum.charAt(i-1)) * 2;
        if (digit < 10)
        {
            checksum += digit;
        }
        else
        {
            checksum += (digit-9);
        }
    }

    if ((checksum % 10) == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

Note that the first character in a string is charAt(0), so that is why 1 is subtracted from the value of i all the time. For the first pass, if the length is even, then the length mod 2 (”mod” is a mathematical term that says to return the remainder of the first number divided by the second number, so 5 mod 2 is 1 and 6 mod 2 is 0. % is the mod operator in JavaScript) results in 0. So 2 minus 0 is 2, so the value of i will walk through the even numbered digits. In the first pass for strings of odd length, the length mod 2 is 1, so 2 minus 1 is 1, and the value of i will walk through the odd numbered digits.

This way we can validate credit card numbers client side and save some server trips.

Posted in Technology | Tagged: , , , , , , , , , , , | 2 Comments »

Hello world!

Posted by Nirav Patel on January 17, 2008

Welcome to my Weblog. My name is Nirav Patel. I am a 26 year old guy from Ahmedabad, India. I work as Sr. Team Lead in Avani Cimcon Technologies Ltd.
 
You can read some good stuff about Technologies, Project Management, My Personal Experiences, My Travel Experiences, Funny Incidence of my life, etc. in my blog entries.
 
Feel free to provide comments on my all posts.
Cya soon…. 

Posted in Technology | 2 Comments »