Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Jason Karns jasonkarns

🏠
Working from home
Block or report user

Report or block jasonkarns

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jasonkarns
jasonkarns / gist:4354421
Last active May 23, 2019
Git send-email using Gmail
View gist:4354421
  1. Configure Gmail in you gitconfig:
[sendemail]
  smtpserver = smtp.gmail.com
  smtpserverport = 587
  smtpencryption = tls
  smtpuser = <gmail email address>
  from = <email address for From: field>
View nodenv.md

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
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
path_before="$result"
result="${result//:$path_to_remove:/:}"
done
@jasonkarns
jasonkarns / issue.md
Last active Jun 2, 2017 — forked from chrmoritz/issue.md
3 undocumented breaking changes we encountered while upgarding npm to v5.0.1 in homebrew
View issue.md

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
end
@jasonkarns
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)
attributes.map.each do |k,v|
self.class.instance.instance_variable_set(:"@#{k}", v)
end
end
@jasonkarns
jasonkarns / subarray.coffee
Created Jan 26, 2014
subclass array in CoffeeScript
View subarray.coffee
class SubArray
@:: = new Array
constructor: (args...) ->
args.__proto__ = SubArray::
return args
View dispatcher.coffee
# 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 backbone.events does)
#
# Angular's $on, on the other hand, accepts a callback that expects
# $scope as the first param, followed by event args.
@jasonkarns
jasonkarns / tap.coffee
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.
View tap.coffee
# 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.