JavaScript Dates with Moment.js

One of the biggest frustrations developers deal with is working with dates. For an excellent overview of why dates are so complicated, check out JavaScript dates, trains, Passover, and Henry VIII by Curtis Autery.

When it comes to working with dates, JavaScript will make you want to hit your head against your desk. Even for simple tasks, working with JavaScript’s Date object can be a major hassle. It lacks a lot of basic functionality that you’d expect like being able to format a date/time a certain way, adding or subtracting from dates, working with locales, and a lot more.

There are hacky ways to accomplish these things as the thousands of StackOverflow posts about JavaScript dates can attest, but save yourself the trouble and check out moment.js.

Moment.js is an awesome library that makes working with dates in JavaScript a lot less painful. Dare I say it, maybe even enjoyable. Rather than give an incomplete introduction to its features here, scroll through the Moment.js docs page to see everything that you can do with it.

And next time you find yourself writing new Date in your code, take 30 seconds to download moment.js and save yourself hours of frustration.

Tracking Blog Post Ideas

My friend Adam asked me how I’ve been keeping track of ideas for blog posts. For that and pretty much anything else that involves lists or notes, I use Workflowy:

Screen Shot 2015-12-19 at 12.52.35 PM.png

When I started this little daily blogging challenge I would have laughed at the idea that I could write every day for more than a few days. I just didn’t feel like I had that much to write about.

But when you force yourself to do a daily blogging challenge, you have to set the bar much lower in your mind for what’s worthy of writing about. If you restrict yourself to only one or two topics or only publish long, insightful posts then you probably won’t be able to blog daily for very long.

When I committed mentally to doing this, I suddenly had a lot of ideas for things that I could write about. They’re kind of scattered and some posts won’t be interesting to many people (and some to none at all), but that’s fine. It gives me enough to write about to keep it up and that’s what the challenge is all about.

On that note, I’ll hit a 30 day streak on Christmas Eve at which point I’ll take a break and start up again in January. I probably won’t try to do it daily again, but will try to keep posting once or twice a week going forward.

Thanks all for reading.

How I Use TextExpander

One of my favorite Mac apps is TextExpander, a toolthat saves you time by enabling you to create shortcuts for things you type frequently.

For example, here are the shortcuts I use on a regular basis:

  • Typing mm@ expands to my email address,

  • Typing vcc expands to my Visa credit card number.

  • Typing stcc expands to a Stripe test credit card number, 4242424242424242.

  • Typing jscc expands into a JSDoc template:

 * Description
 * @param {Object} var - Description
 * @returns {Boolean} Description
  • Typing wpcc expands into a PHPDoc template:
 * Description
 * @param int|string $var Description
 * @return bool Description
  • And last but not least, ---> expands into because using ASCII arrows makes you look like a badass hacker, obviously.

Give it a shot if you’re not already using it. There’s a free trial and you can purchase the full version for $44.95.

If you have any recommendations for other useful productivity tools like TextExpander, I’d love to check them out. Thanks!

How I Follow Twitter

Here’s my setup:

Screen Shot 2015-12-10 at 11.37.57 AM.png

I use the Tweetbot Mac app and have it configured to display two columns: one for mentions and one for tweets of folks in a private list of ~120 folks whose tweets I want to ensure I read.

I keep a list simply because I don’t have the time to read all of the tweets from the 1K+ people I follow. I keep it private simply because there’s no need for it to be public. I could unfollow folks so that I only follow the folks whose tweets I really want to read, but I’ve found keeping a list is simpler.

I’ve learned that my Twitter usage tends to follow a regular pattern: I follow a certain number of people and don’t have a problem reading all of their tweets, so I start to follow more people, get overwhelmed, then stop reading tweets all together. After a week or two I remove folks from the list so that it becomes manageable, start reading tweets again, then repeat the cycle.

After going through this several times, I’ve learned that for me it’s really important to limit the number of people I follow. If check Tweetbot and see that I have 500+ unread tweets, that’s typically when I stop following tweets entirely. With only ~120 people in the list and those folks typically producing a reasonable amount of tweets/retweets, I can usually miss a day or two and only have to catch up on 100-200 tweets which is usually no problem.

You’re probably on the list if we’ve ever chatted on Twitter, we’re friends at Automattic or in Orlando, or you’re a thought leader in the growth/startup/tech/science/AI space.

I wish I could follow more folks, but given the choice between following a limited amount and reading most of their tweets vs following a lot of folks and reading no tweets, I go with the first option. YMMV.

If you have any suggestions on how to improve this setup or have a workflow that works really well for you, I’d love to hear about it.