Skip to content

Instantly share code, notes, and snippets.

@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
@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
@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 / 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 / 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
info: Extracting ruby-enterprise-1.8.7-2010.02 ...
++ [[ -n '' ]]
+++ dirname /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02/extract.log
++ mkdir -p /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02
++ touch /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02/extract.log /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02/extract.error.log
++ tee /Users/thomasmpack/.rvm/log/ree-1.8.7-2010.02/extract.log
+++ date '+%Y-%m-%d %H:%M:%S'
++ echo '[2010-08-10 10:22:28] cat /Users/thomasmpack/.rvm/archives/ruby-enterprise-1.8.7-2010.02.tar.gz | gunzip | tar xf - -C /Users/thomasmpack/.rvm/src'
++ [[ -z '' ]]
++ eval 'cat /Users/thomasmpack/.rvm/archives/ruby-enterprise-1.8.7-2010.02.tar.gz | gunzip | tar xf - -C /Users/thomasmpack/.rvm/src'
describe "POST create" do
describe "with valid params" do
it "assigns a newly created attending as @attending" do
Attending.stub(:new).with({'event_id' => 1}) { mock_attending(:save => true) }
post :create, :event_id => 1
assigns(:attending).should be(mock_attending)
end
end
end