Blog

  • No Access-Control-Allow-Origin header is present on the requested resource

    Are you confused why you are getting this error? This error is caused when you are trying to perform an AJAX call from one site to a different site. Because Javascript is a client-side application it requires additional security to help protect the users from malicious code, e.g. calling a different site without the user knowing.

    (more…)

  • Switching from App session to SQL session state

    When you have a single web server, storing the user sessions on the single server works perfect; however, when you have multiple web servers and users need to potentially round robin between servers or you need to remove servers from the pool and don’t want to affect your user’s experience enter: SQL Session State.

    (more…)

  • GitHub error: cannot lock existing info/refs fatal

    Are you trying to git pull or git push and receiving the nasty Github cannot lock existing info/refs fatal? There is a nice and quick easy fix. Run the following command:
    git remote prune origin

    (more…)

  • Merging arrays and removing duplicates with Javascript

    When you have two different JavaScript arrays and merge them into one, it’s important that you don’t have the same element in there more than once. Here are two different ways to concatenate arrays while removing duplicates.

    1. A loop and check if the element is already in the array
    2. Using the ECMA 6 function called Set

    (more…)

  • How to compare arrays in Javascript

    Let’s say you have two arrays and you want to see if all elements are identical, very importantly not just some but all elements must be the same.

    I’ll start with some pseudo code of what I think the final solution will end up doing.

    1. Null check both arrays. False if either are null
    2. Check if the length of the two arrays are the same. If they are not we can exit fast with false.
    3. Sort both arrays using the built-in JavaScript array sorter. This will help put them in the same order so it will once again exit faster.
    4. Loop one array and compare the second one at the same index. Once again, at the first instance of not a match it will exit fast with false.

    Alright, let’s now take a look at some code to compare arrays using Javascript:

    (more…)