Using window.confirm as a Promise

When writing a modern JavaScript application that uses Promises or async/await, it is sometimes useful to wrap other things in promises so they can more easily be used in a standard way throughout your codebase or in promise chains.

This is especially true if a built-in feature has the same properties of a promise, but is not one. The window.confirm API is one that I wrap a lot in my applications:

function confirmDialog(msg) {
  return new Promise(function (resolve, reject) {
    let confirmed = window.confirm(msg);

    return confirmed ? resolve(true) : reject(false);
  });
 }

And now we can use it just like a normal promise:

confirmDialog('Do you really want to delete this?')
  .then(() => doYourDeleteAction(task.id))
  .catch(err => alert('Unable to delete!'))

Now if you ever want to replace that confirm dialog with some custom version with a fancy UI like a modal window, you can do so much easier – just by updating the confirmDialog function itself.

Chromeless: Switching to Firefox

I have been a long-time Google Chrome user, but have been wanting to switch to Firefox for the past several months, but could not get myself to do it full-time. The interface was a bit dated, and the browser in general didn’t feel faster. I used Firefox Developer Edition for a while which had the newer UI now available in Quantum, but the lack of plugin/add-on support killed my web surfing experience, and I ultimately went back to Chrome.

Then everything changed when the Firefox team announced Firefox Quantum.  I downloaded it to try it out, and was off to the add-on site. The team did a good job ensuring most of the popular add-ons were up-to-date and working with the new changes in Quantum. I was able to quickly find and install the add-ons I needed, and have been using Firefox full-time ever since. It’s a joy to use, and consistently uses significantly less memory than Chrome. It’s my new go-to. Congrats, Firefox team – thanks for the hard work and the great release!

My Biggest Regret of 2017

Now that 2017 has come to a close, I can safely say that my single biggest regret of 2017 was selling my Bitcoin in mid-January.

For those not following Bitcoin, it means that I missed out on the huge upside – over 1,000% increase in price. D’oh!

 

My $202.84 worth of BTC would now be worth nearly $4,000. Oof.

ThunderPlains 2017

ThunderPlains is coming up fast – just two days away! This is the fifth year of co-organizing the conference, and we always have a great time with the local community.

Grab some tickets to ThunderPlains 2017 if you have not done so already – it will be a lot of fun to meet everyone else in tech working along side you in your own community. There is a lot more tech activity than you think – right under your nose here in Oklahoma!

Social Media Is Bad For Your Health

Over the past few months, my own outlook on the wide use of social media has grown dim. I have gotten to the point where I believe the saturation and over-use of social media is actually bad for your mental health. It’s impossible to have a real conversation. People automatically assume the worse intentions and read meaning into your text that isn’t there. Jealousy and bitterness of fake picture-perfect lives takes root in innocent hearts. There are still some upsides, but the list of downsides keeps growing longer.

Social Media Is The New Smoking

This Is How Your Fear and Outrage Are Being Sold for Profit

 

Effective Browser JavaScript Debugging

How to effectively debug your web application is increasingly becoming a critical skill for any web developer, especially with the rise of ever-more complicated JavaScript applications with code transpiling and obfuscation. I wanted to teach the other developers at my company how to do this to be more effective at work, and developed it into a full talk that I have given at many conferences all across the world. My local user group OKC.js was the first time this talk was recorded and made available online. Please check it out: