Skip to content

Instantly share code, notes, and snippets.

Working from home

Jason Karns jasonkarns

Working from home
View GitHub Profile
jasonkarns /
Last active Aug 7, 2020
Git send-email using Gmail
  1. Configure git.
# ~/.config/git/config
  confirm = auto
  smtpServer =
  smtpServerPort = 587
  smtpEncryption = tls
  smtpUser = <gmail email address>

Why choose nodenv?

Because nodenv was forked from rbenv, many of the reasons to choose nodenv over others are similar to why one would choose rbenv over rvm. (Nodenv also inherits a much longer battle-tested history than others.)

Auto switching

One of the biggest reasons to choose nodenv over the others is that nodenv can automatically select the appropriate node version for a given project. Neither nvm nor n have auto-switching capabilities out of the box. They both require some form of 'use' command to activate a given version; which lasts for the lifetime of the shell (or until another version is activated).

jasonkarns / npx.bash
Created Jan 4, 2019
nodenv exec hook to make npx happy
View npx.bash
[ "$NODENV_COMMAND" = npx ] || return 0
remove_from_path() {
local path_to_remove="$1"
local path_before
local result=":${PATH//\~/$HOME}:"
while [ "$path_before" != "$result" ]; do
jasonkarns /
Last active Jun 2, 2017 — forked from chrmoritz/
3 undocumented breaking changes we encountered while upgarding npm to v5.0.1 in homebrew

I'm opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

supporting information:

  • npm -v prints: 5.0.1
View maxJSDate.js
module.exports = function findMaxValidDate(min, max) {
var next = Math.floor((min+max)/2);
if(min == next) return min;
if(new Date(next) == "Invalid Date") {
return findMaxValidDate(min, next);
} else {
return findMaxValidDate(next, max);
View finds_page.rb
require 'axe/configuration'
module Axe
class FindsPage
WEBDRIVER_NAMES = [ :page, :browser, :driver, :webdriver ]
class << self
alias :in :new
jasonkarns / singleton_yaml.rb
Created Mar 8, 2016
Deserialize YAML config file into a singleton instance
View singleton_yaml.rb
require 'singleton'
class Configuration
include Singleton
def init_with(attributes) do |k,v|
self.class.instance.instance_variable_set(:"@#{k}", v)
jasonkarns /
Created Jan 26, 2014
subclass array in CoffeeScript
class SubArray
@:: = new Array
constructor: (args...) ->
args.__proto__ = SubArray::
return args
# we have an event aggregator that is treated as an adapter to hide
# whatever eventing lib/framework/utility we decide to use
# originally, it was backed by Backbone.Events. Now it's Angular's $rootScope
# `on` accepts a callback that expects to be given event args. (as does)
# Angular's $on, on the other hand, accepts a callback that expects
# $scope as the first param, followed by event args.
jasonkarns /
Created Nov 16, 2013
What if _.tap could set the context of the interceptor? I would imagine that it would set the context to the tapped object by default. I can't think of a use case for setting it to another arbitrary object.
# the thought came to me when dealing with angular
myModule = angular.module('myModule', [])
myModule.value 'X', X
myModule.factory 'F', F
myModule.service 'S', S
# with tap, but without setting context
_(angular.module('myModule', [])).tap (myModule) ->
myModule.value 'X', X
You can’t perform that action at this time.