This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.rails.allowAction = (element) -> | |
# The message is something like "Are you sure?" | |
message = element.data('confirm') | |
# If there's no message, there's no data-confirm attribute, | |
# which means there's nothing to confirm | |
return true unless message | |
# Clone the clicked element (probably a delete link) so we can use it in the dialog box. | |
$link = element.clone() | |
# We don't necessarily want the same styling as the original link/button. | |
.removeAttr('class') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chsh -s /bin/zsh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MongoMapper.connection = | |
Mongo::Connection.new('localhost', 27017) | |
MongoMapper.database = "#expense-#{Rails.env}" | |
if defined?(PhusionPassenger) | |
PhusionPassenger.on_event(:starting_worker_process) do |forked| | |
MongoMapper.connection.connect if forked | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.before(:suite) do | |
DatabaseCleaner.strategy = :truncation | |
DatabaseCleaner.orm = "mongoid" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install zsh tree | |
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh | |
mv ~/.zshrc ~/.zshrc.bkp | |
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc | |
chsh -s $(which zsh) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Best use case is to create a file "update_local_db.sh" in your project folder and then call the command with bash update_local_db | |
# Follow me: @jackkinsella | |
function LastBackupName () { | |
heroku pgbackups | tail -n 1 | cut -d"|" -f 1 | |
} | |
# This part assumes you have a low limit on no. of backups allowed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-testing-with-rspec/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#RSpec gives you a way to encapsulate what you’re testing via the describe block, and it’s friend context. | |
#In a general unit testing sense, we use describe to describe the behavior of a class: | |
describe Hash do | |
end | |
#Tests are written using the it block. Here’s an example of how you might write a spec for the Hash class: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Mocks and stubs way | |
#The other option is to use mocks and stubs. Although there is a lot of information in the web about it, to help our discussion, I will #describe it very shortly. From my experience & research, I understand that the main difference between those two is the following: | |
#Stubbing a method is all about replacing the method with code that returns a specified result (or perhaps raises a specified exception). #Mocking a method is all about asserting that a method has been called (perhaps with particular parameters). | |
#As you can see, stubbing lets you define methods that are not currently implemented or we decided not to depend on. On the other hand, as we #mock objects we specify the behavior that we would expect on the mocked object, making our test more Behavior Driven Development. | |
#This is the recommended way of using Rspec as it defines the way the objects must collaborate to accomplish a certain task. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe EventsHelper do | |
describe "#link_to_event" do | |
it "displays the title, and formatted date" do | |
event = Event.new("Ruby Kaigi", Date.new(2010, 8, 27)) | |
# helper is an instance of ActionView::Base configured with the | |
# EventsHelper and all of Rails' built-in helpers | |
helper.link_to_event.should =~ /Ruby Kaigi, 27 Aug, 2010/ | |
end | |
end | |
end |