Skip to content

Instantly share code, notes, and snippets.

View jasonkarns's full-sized avatar
🏠
Working from home

Jason Karns jasonkarns

🏠
Working from home
View GitHub Profile
def matches?(page)
@audit = @a11y_check.call Page.new page
::RSpec::Expectations::FailureAggregator.new(@audit.invocation, nil).aggregate do
@audit.results.violations.each {|v| ::RSpec::Expectations.fail_with v.failure_message }
end
@audit.passed?
end
@jasonkarns
jasonkarns / capturing_matcher.rb
Created July 29, 2015 15:26
Custom Matcher that extends RSpec::Matchers::BuiltIn::Match to also enable specifying capture groups.
module CustomMatchers
class Match < RSpec::Matchers::BuiltIn::Match
def matches?(actual)
# first ensure the regex matched
return false unless result = super
# only continue if specifying captures
return result unless expected_captures = @captures
actual_captures = to_hash result
@jasonkarns
jasonkarns / kill-domcontentloaded.js
Created May 8, 2015 14:30
Kills DOMContentLoaded in Opera when executed prior to jquery
var DOMContentLoaded = function() {
document.removeEventListener('DOMContentLoaded', DOMContentLoaded);
document.body.appendChild(document.createElement('iframe'));
};
document.addEventListener('DOMContentLoaded', DOMContentLoaded);
@jasonkarns
jasonkarns / index.js
Created May 7, 2015 18:31
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var d = require('domready');
d(function(){
alert("boo")
});
@jasonkarns
jasonkarns / broken.sh
Last active August 29, 2015 14:18
debug log for rbenv-update
$ RBENV_DEBUG=1 rbenv update | pbcopy
+ [rbenv:15] enable -f /Users/David/.rbenv/bin/../libexec/rbenv-realpath.dylib realpath
+ [rbenv:21] '[' -n '' ']'
++ [rbenv:25] type -p greadlink readlink
++ [rbenv:25] head -1
+ [rbenv:25] READLINK=/usr/bin/readlink
+ [rbenv:26] '[' -z /usr/bin/readlink ']'
+ [rbenv:50] '[' -z '' ']'
+ [rbenv:51] RBENV_ROOT=/Users/David/.rbenv
+ [rbenv:55] export RBENV_ROOT
@jasonkarns
jasonkarns / .projections.json
Created March 13, 2014 03:48
vim-projectile file for Lineman projects
{
"README.md": {
"command": "readme"
},
"package.json": {
"command": "package"
},
"bower.json": {
"command": "bower"
},

Keybase proof

I hereby claim:

  • I am jasonkarns on github.
  • I am jasonkarns (https://keybase.io/jasonkarns) on keybase.
  • I have a public key whose fingerprint is A0E8 D7D1 099F 66C3 7347 3D66 E87D 122A A9B1 B726

To claim this, I am signing this object:

@jasonkarns
jasonkarns / npm-commands
Created February 28, 2014 16:51
Npm commands, with aliases grouped and organized by primary command
adduser add-user login
bin
bugs issues
cache
completion
config c
dedupe ddp find-dupes
deprecate
docs home
edit
@jasonkarns
jasonkarns / munge.coffee
Created January 29, 2014 14:04
Demonstrate Jasmine spies' odd behavior of verifying against argument references
munge = (operator) ->
data = x: 1
data.y = operator(data)
@jasonkarns
jasonkarns / subarray.coffee
Created January 26, 2014 19:59
subclass array in CoffeeScript
class SubArray
@:: = new Array
constructor: (args...) ->
args.__proto__ = SubArray::
return args