Skip to content

Instantly share code, notes, and snippets.

View keybase.md

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 Feb 11, 2015
Polymorphic Null Object
View null_object.rb
class User
def name
'Mike Pack'
end
end
class GuestUser
def name
'Guest User'
end
@mikepack
mikepack / cars.rb
Created Feb 11, 2015
Polymorphic Cars
View cars.rb
class Car
def drive
# get_in
start_engine
accelerate
# park
end
end
class Ford < Car
View .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 Aug 29, 2015
5 Composition Techniques
View 1_inheritance.rb
class Animal
def run
puts 'running'
end
end
Animal.new.run #=> running
class Wolf < Animal
def follow_pack
View gist:a54cc3bbcc70e63e46c2
# 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
View nucleotide-count.js
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 Feb 28, 2014
Ember Component Test Helper
View setup_component.coffee
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 Feb 4, 2014
The Old Reader Fluid badge and Growl notifications
View gist:8809257
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 Dec 30, 2015
Removing Ember.run from all (Jasmine) tests
View gist:7900448

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;