Combining multiple json fetch requests into one array

Have been working on a project where I need to combine multiple JSON files into one array. The code below will take an array of URLs and combine them into one array.

Once all the fetch requests have been completed and converted to json you’ll have an equal number of arrays. Using Array.prototype.flat() combines all the arrays into a single array.

let finalResult;
const urls = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
Promise.all(
urls.map(url =>
    fetch('json/' + url + '.json')
        .then(e => e.json())
    )
).then(data => {
    finalResult = data.flat();
});

read more

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