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 / null_object.rb
Created February 11, 2015 05:02
Polymorphic Null Object
class User
def name
'Mike Pack'
end
end
class GuestUser
def name
'Guest User'
end
@mikepack
mikepack / cars.rb
Created February 11, 2015 05:02
Polymorphic Cars
class Car
def drive
# get_in
start_engine
accelerate
# park
end
end
class Ford < Car
@mikepack
mikepack / .irbrc
Created October 15, 2014 21:59
My .irbrc
require 'irb/completion'
require 'brice'
Brice.init do |config|
config.exclude 'libs'
end
IRB.conf[:AUTO_INDENT] = true
@mikepack
mikepack / 1_inheritance.rb
Last active August 29, 2015 14:07
5 Composition Techniques
class Animal
def run
puts 'running'
end
end
Animal.new.run #=> running
class Wolf < Animal
def follow_pack
# 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
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;
},
@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'
@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 / 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;