Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mikepack on github.
  • I am mikepack (https://keybase.io/mikepack) on keybase.
  • I have a public key ASAoHHutu5Q4xJx7dLfSuriZV7fgxkmWw1XRRm2JTcGM9go

To claim this, I am signing this object:

@mikepack
mikepack / gist:7900448
Last active December 30, 2015 23:28
Removing Ember.run from all (Jasmine) tests

When testing Ember code, without putting expectations in a Ember.run callback, you'll get this error:

Failure/Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in an Ember.run

The error recommends wrapping expectations in Ember.run:

describe 'something', ->
@mikepack
mikepack / simple_paperclip.rb
Created July 26, 2013 19:36 — forked from basgys/simple_paperclip.rb
Convert to mixin
# == Paperclip without ActiveRecord
#
# Original: https://gist.github.com/basgys/5712426
require 'active_model/naming'
require 'active_model/callbacks'
require 'active_model/validations'
require 'paperclip'
require 'paperclip/glue'
@mikepack
mikepack / capybara-notification.txt
Created March 20, 2013 20:04
This is a comparision of handling JavaScript alert/confirm/prompt notifications with Capybara.
This is a comparision of handling JavaScript alert/confirm/prompt notifications with Capybara.
Proposed consolidated API in Capybara:
There are two styles of notification handling: proactive or reactive.
- Proactive is used in headless environments to queue up responses.
- Reactive is used in environments with actual notifications that mandate a response (eg selenium).
alert - # Reactive
page.driver.accept_alert
0 enumerator.so
1 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/enc/encdb.bundle
2 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/enc/trans/transdb.bundle
3 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/defaults.rb
4 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/rbconfig.rb
5 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb
6 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/exceptions.rb
7 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
8 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb
9 /Users/Mike/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/version.rb
@mikepack
mikepack / gist:3808771
Created September 30, 2012 23:55
Binary Add
class BinaryPlus
def initialize(first, second)
@first, @second = first, second
# to_s accepts a base to convert to. In this case, base 2.
@first_bin = @first.to_s(2)
@second_bin = @second.to_s(2)
normalize
end
def +
# app/something/parent.rb
class Parent
def path
__FILE__
end
end
# app/something/child.rb
class Child < Parent; end
@mikepack
mikepack / gist:3244024
Created August 3, 2012 03:18
Testing blocks

How do you test this?

I want to test that something receives #var from inside the block.

I realize this might be a code smell.

something = Struct.new(:var).new
some_method do
 something.var
@mikepack
mikepack / decorate.js
Created April 25, 2012 06:07
Decorators in JS
function SomeClass() {}
SomeClass.prototype.do_it = function() { alert('doin it!'); }
s = new SomeClass();
function Decorator(klass) { this.__proto__ = klass.__proto__; }
d = new Decorator(s)
d.do_it()
@mikepack
mikepack / gist:2417873
Created April 19, 2012 02:08
Exhibits and renderers
class RailsTextPostRenderer
def initialize(context)
@context = context
end
def render(model)
@context.render(partial: "/posts/text_body", locals: {post: model})
end
end