explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

Leave a comment

Quickly Sync Mac OS’s Time via Script

I’ve noticed lately that my computer’s time is off by over a minute, sometimes several.  This happens as after I have put my computer in standby by closing the lid.  The problem it causes is that with the time out of sync, I cannot use my auth tokens to log into my work’s VPN.  So instead of opening the Time & Date preferences, I use this one line command to quickly update.

Open Terminal and type:

sudo ntpdate -u time.apple.com

You can even create an alias in your .bash_profile to make it simpler:

alias synctime="sudo ntpdate -u time.apple.com"



Leave a comment

Permissions-Based UXs in Angular Using Directives

the problem

A UI may want to present some content in a read-only state, only allowing the user to interact with said content if they are permitted to do so.  I won’t argue the merits/demerits of this particular UX, only how to solve this requirement.

the solution

.directive( 'permissions', [
     function( popupService, sessionService ){

          return {
              restrict: 'A',
              priority: -1,
              link: function( $scope, elem, attrs ){

                   elem.on( 'click', function( evt ){
                        if ( !sessionService.user.isPremium )

                             $scope.$apply( function(){
                                  popupService.show( ... )

You can see the original question/answer here – http://stackoverflow.com/a/38439845/1121919

Leave a comment

nvm/node: an easy way to use different versions for different projects


I need to have different versions of node/npm for different projects.  I’d prefer to have each project “know” which version of node/npm it needs to use.



Before we get started, there are a few prerequisites:

  • understand that this is a Mac solution.  While I’m sure a similar solution exists for Windows, I am neither knowledgeable enough nor inclined to write a compatible shell script for Windows at this time.
  • have/install nvm.  I installed mine with Brew.
  • have at least one version of node installed via nvm
  • have a basic understanding of terminal.
  • have a willingness to edit your .bash_profile.


leveraging .nvmrc

Much like Ruby has a shortcut for setting the current version of Ruby to use, nvm has a similar feature.  When you enter the following command…

nvm use

… then nvm will look for a .nvmrc file and get the correct version number to use from there.  So first navigate to a project folder that uses node and create a new file called .nvmrc.  Inside just write 4.2.  If you’re a command-line geek then do the following:

cd <project folder>
touch .nvmrc # creates the file
echo \4.2 >> .nvmrc # appends the version to the file
cat .nvmrc # prints the file's contents

editing your .bash_profile

So the easiest way to make nvm read your .nvmrc file is to do a check when you change directories.  We need to make a function we can call when we cd into a directory:

All this is doing is

  • checking to see if the current directory matches the previous directory
  • if it doesn’t , then it stores the current directory to the previous’ variable
  • then it checks to see if a .nvmrc file exists
  • if so, then tell nvm to use it
  • lastly we tell the OS to call this command any time we do something in Terminal/Bash

Leave a comment

Personal: Tap Cancer Out

This isn’t anything to do with javascript or development.  Children and BJJ are 2 of my life’s loves and so I see it fitting to post things that I am passionate about here as well as development (not to say I’m not passionate about my work, I am).

Many of you know me as just a father, some of you know me just from BJJ. Children and BJJ are 2 of my passions in life. Both have changed my life forever. To know that we can put men on the moon, that we can land on an asteroid, that we have peered into the inner workings of our universe, but that we can’t save children suffering from cancer is heartbreaking.

On August 15th I’ll be competing in a Brazilian Jiu-Jitsu tournament. However, this is no ordinary fight. I am taking part in the 2015 Tap Cancer Out Summer BJJ Open and along with my competitors, I’ll be fighting for those who are in the fight of their lives – children with cancer.