Jarrett Widman's Occasional Thoughts

Jarrett Widman is a Chicago based front and back end web developer and designer for small businesses through his company, 24m2 LLC. He loves coding for ASP.NET and Javascript and designing with Illustrator. Jarrett is Director of Marketing at Sports Made Personal and Lacrosse America.
Ask me anything

Agent Ransack - Free File Searching Utility 

Really don’t know what I’d do without this sometimes

Meet daterange.js

For whatever reason, I find date-time comparisons to be really difficult. I find timezones issues to be confusing. Worst of all, I find comparing ranges of time to be beyond my capacity for visualization. Its because of this that I have repeatedly needed a library in multiple languages to tell me if date-time ranges are equal, overlap, or contain each other.

And so, I wrote the Javascript library daterange

Daterange supports the adding and subtracting of date-time ranges in addition to the comparison operators equals, overlaps, and contains. Each daterange is made up of a start and end time. The underlying dates are simple Javascript Date objects.

The output of adding dateranges together is an array of dateranges with a length of 1 to the length of the input array. This is because any overlapping dateranges create a single range in the add operations.

The output of subtracting one daterange from another is an array of dateranges with a length of 0 to 2. This is because the difference could remove none of the original, all of the original, the head of the original, the tail of the original, or it could remove the middle of the original creating two different ranges.

Daterange is not meant to compete with something like moment, its a simple standalone library that is fast, small, and easy to use.

Daterange is available on npm and bower, seeĀ GitHub for details.

Your High Resolution Assets

Do you have a logo? Do you have a head shot? Press kit? What do you do when someone needs that stuff from you, do you send it to them in an email? Get that stuff on your website.

I can’t tell you how often this is a pain point for designers and developers.

And if someone really needs your logo or head shot, and they can’t get a good one, they are going to get a crummy pixelated jpg from the top left corner of your website or your Facebook page.

You’ve been warned. Upload it now.

ECMAScript compatibility table 

ES6 is here, sort of.

Readable before Optimized, Tested before Refactored

There are a couple basic things about authoring maintainable code that I think are said a lot, but not often said clearly enough.

Worry more about whether you code is readable and maintainable than whether it is fully optimized.
Code that is easy to read and maintain is fundamentally easier to optimize. Trying to start out by writing highly optimized code that is obscure leads to trouble.

Get code working with test coverage before refactoring.
I’m not a strict TDD practitioner, but its a practice that forces you into this mindset. Seriously, stop messing with it until the tests pass, and refactoring will be safer, faster, and even show you gaps in your test coverage.

More Information