jQuery Validate unique email addresses

jQuery Validate offers a lot of great features out of the box, but one feature it’s lacking is validating if something is not found is a list. Fortunately, it’s super easy to add your own validators. In my case I want to find if something doesn’t exist in a list.

jQuery.validator.addMethod('uniqueEmail', function(value) {
    var currentEmails = 'an array from somewhere with emails lower cased';
    //NOTE: this check is case sensitive, so make sure you lower case both values being compared
    return $.inArray(value.toLowerCase(), currentEmails) === -1;
}, 'Email has already been added.')

$('#ccEmail').validate({
    errorElement: 'div',
    rules: {
        CCEmail_Address: {
            email: true,
            uniqueEmail: true //use the custom validator
        }
    }
});

read more

I'm speaking at MidwestJS 2019!

I’m happy to announce I’ll be speaking at MidwestJS on August 7-9, 2019! The conference will be held at Schulze Hall at the University of St Thomas in beautiful downtown Minneapolis.

I’ll be speaking on two topics - Secure by Design and how you can ensure security throughout development of your application. I’ll cover some of the OWASP top 10, best practices, and things my team has implemented at work. I’ll also be giving a new full length talk on “Web Performance - Where do I start?” where you can learn about quick hit ways to improve your website performance.

Registration is open now, so don’t delay in getting your tickets!

read more

I'm speaking at DevOpsDays Portland 2019!

I’m happy to announce I’ll be speaking at DevOpsDays Portland on September 12, 2019! The conference will be held at the Oregon Convention Center.

I’ll be giving a lightning talk on how you can quickly assess web performance in an application. I gave a similar version at DevOpsDays Des Moines, but this will be an improved version with actual working charts, lol

Registration is open now, so don’t delay in getting your tickets!

read more

I'm speaking at Prairie.Code() 2019!

I’m happy to announce I’ll be speaking at Prairie.Code() on September 13, 2019! The conference will be held at the Holiday Inn Conference Center near the Des Moines airport.

I’ll be speaking on Secure by Design and how you can ensure security throughout development of your application. I’ll cover some of the OWASP top 10, best practices, and things my team has implemented at work. I’ve given a version of this talk at Iowa Technology Summit, DevOpsDays Des Moines, and Connectaha, but this will be the best version yet.

Registration is open now, so don’t delay in getting your tickets. Once they’re gone, they’re gone!

read more

VS Code hide open editors pane

If you’d like to hide the open editors tab in VS Code, especially useful if you’re trying to open multiple files in a folder at once and it keeps pushing the list down, you can open up settings Ctrl + , and search for openeditors and set the number of editors shown in the open editors pane to 0.

read more

ColdFusion Removing duplicate values from a list

To get the number unique values from a list you can create a Java set, which does not allow duplicate values

createObject("java", "java.util.HashSet").init(listToArray(valueList(eventsQuery.event_id))).size();

The init values requires a list, so if you already have a list, you can just pass that in to return a Java set object. You will need to convert the set back to a list to make it easy to work with in ColdFusion although you could iterate over it if you’d like. Here’s the easiest version.

listWithDupes = [1,2,3,1,3];
noDupes = createObject("java", "java.util.HashSet").init(listWithDupes);
noDupesArray = createObject("java", "java.util.ArrayList").init(noDupes);
writeDump(noDupesArray); //returns 1,2,3

read more

Detecting a Credit Card number in a field using JavaScript

Given a field such as <input id="notes" type="text" names="notes"> You can detect a Credit Card number using the following in jQuery. This will detect 15 or 16 digit credit card numbers because of the d{3,4}. To only detect 15 or 16 change that to be only d{3} for 15 or d{4} for 16.

$('#notes').on('input', function() {
    const ccDetected = $('#notes').val().match(/\b(?:\d{4}[ -]?){3}(?=\d{3,4}\b)/gm);
    if (ccDetected) {
        alert('don''t use credit cards!');
    }
});

read more

Update LibreELEC to version 9 for Kodi 18

Kodi version 18 has been released as has LibreELEC version 9.

If you’ve checked for updates on your Raspberry Pi and nothing is showing here’s the solution.

  1. Go to the LibreELEC Add-On
  2. Change Automatic Updates from Auto to Manual
  3. Enable Show Custom Channels and then disable it
  4. From the Update Channelmenu chooseLibreELEC-9.0
  5. Go to Available Versions
  6. Install 9.0.0 (or the latest)
  7. Turn Automatic Updates back on
  8. Repeat when LibreELEC version 10 comes out

read more

SurveyMonkey CX API call

SurveyMonkey has a great new API available that allows you to easily send someone an email programmatically. I ran into some hiccups while setting it up and there’s almost zero documentation out there.

Endpoint: This is provided at the end of setting up a survey. Should look like

https://cx.surveymonkey.com/api/v1/surveys/${fromSurvey}/replies

Headers

name="Content-Type" value="application/json"
name="Authorization" value="Token token=#apiToken#"

Body

{
    "person": {
        "email": "emailAddress",
        "first_name": "first name",
        "last_name": "last name",
        "fields": {
            "Custom Field": ["custom field value"]
        }
    },
    "delay": 0
}

The custom fields must match exactly what you put in your admin and you must pass it in as a list. If you don’t pass a list it won’t register. The delay is the number of days to delay sending the survey.

My full postman request is below with sensitive information redacted.

  "info": {
    "_postman_id": "d16018c3-53d9-4ebd-a47f-61a84505a04d",
    "name": "SurveyMonkey",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Survey Monkey",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Token token=${apiToken}",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\r\n  \"person\": {\r\n    \"email\": \"email@gmail.com\",\r\n    \"first_name\": \"First\",\r\n    \"last_name\": \"Last\",\r\n    \"fields\": {\r\n      \"Products\": [\"Acme M500\", \"Acme B7500\"]},\r\n  \"facets\": {\r\n    \"Job ID\": \"1234\"\r\n  },\r\n  \"delay\": 24\r\n}"
        },
        "url": {
          "raw": "https://cx.surveymonkey.com/api/v1/surveys/${fromSurvey}/replies",
          "protocol": "https",
          "host": ["cx", "surveymonkey", "com"],
          "path": ["api", "v1", "surveys", "${fromSurvey}", "replies"]
        }
      },
      "response": []
    }
  ]
}

read more

Updating all sub modules in a git project

This command will find all the submodules in your current git projects and pull down changes from master for each submodule.

git submodule -q foreach git pull -q origin master

Once you pull down changes make sure you push the changes back to your project to see the changes.

What is this actually doing?

git submodule basically gets all the submodules in your project

-q means quiet which means it doesn’t output the name of the submodule as it loops through them. This parameter is not required.

foreach um, it loops through each submodule

git pull -q origin master this pulls down the changes from master on the submodule and doesn’t output the changes. Again, the -q is not required, but will reduce the conole output.

read more