Skip to content

Instantly share code, notes, and snippets.

# app/something/parent.rb
class Parent
def path
__FILE__
end
end
# app/something/child.rb
class Child < Parent; end
@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 +
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 / 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
@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 / 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', -&gt;
@mikepack
mikepack / gist:8809257
Created February 4, 2014 18:17
The Old Reader Fluid badge and Growl notifications
setInterval(updateDockBadge, 5000);
setTimeout(notifyUnread, 5000);
var currentCount = '0';
function updateDockBadge() {
currentCount = jQuery('#unread_count .badge-info').text();
window.fluid.dockBadge = currentCount;
}
var oldCount = '0';
@mikepack
mikepack / setup_component.coffee
Created February 28, 2014 16:38
Ember Component Test Helper
AppTest.setupComponent = (name, content, options, setupCallback=null)->
beforeEach ->
Ember.$('<div id="test-container"><div id="test"></div></div>').appendTo('body');
Ember.run ->
AppTest.App = Ember.Application.create
rootElement: '#test'
var DNA = function(sequence){
this.sequence = sequence;
this.nucleotideCounts = this._countNucleotides();
};
DNA.prototype = {
count: function(marker){
this._checkMarker(marker);
return this.sequence.split(marker).length - 1;
},
# High-Low Testing
## Seeking a better workflow
## Dependencies are a necessary evil
## Getting started
### Testing high
### Testing low
## Isolating the framework
### Example refactor to isolate the framework
## Feedback, feedback, feedback