Blog

  • Deleting an element from an array in PHP

    There are multiple ways to delete an element from array with PHP: unset, array_splice, and array_diff. The splice method is very similar to my article on removing a specific element with JavaScript article.

    (more…)

  • Validate an email address in JavaScript

    This is my least favorite topic; validating email addresses. There are hundreds of examples using regular expressions that are all slightly different and all have there own quirks with them.

    If validation must be done, I suggest only doing this on the client-side. Ideally the server-side performs email validation by sending an actual email that includes a unique link to validate the email is valid.

    But if JavaScript is a must, here is the best one I’ve found.

    (more…)

  • Perform UPDATE statement from a SELECT with SQL

    It’s quite common where I need to perform an UPDATE statement with SQL but it is not a garden variety single table update statement. Instead I need to join data from another table, whether it is to get data from the second table or use it in my WHERE clause.

    (more…)

  • Deep clone an object with C#

    Cloning is a common thing I need to do in my C# project. The most common case I use this is with my Entity Framework projects. I first fetch my object using a standard Linq query.

    Once I have this object, EF is now tracking any changes to the object. I want a duplicate object of this so I can track a before and after state, so I want to clone the fetched object. To do this I use JSON.Net nuget package.

    (more…)

  • Why you should use strict with JavaScript

    Many people “dislike” JavaScript for reasons that I cannot understand. I like it and it serves a purpose. JavaScript can be a very forgiving language. By that I mean it let’s you get a way with things that other languages, that are a little stricter, would not. This is where the “use strict” comes into play.

    (more…)