This file contains 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
Dear Git experts, | |
The other day I had made a change to my code and committed it then realized I was in an unrelated branch; I had intended to commit the change to master. | |
I switched to master and attempted to merge just the errant commit (by the long hash key) from the branch but that ended up merging the entire branch into master. | |
I blame this faux pas on my still-ingrained Subversion mentality. | |
Where did I go wrong? How should I have handled correcting the mistake? | |
This file contains 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
$ port list | grep ruby | |
ruby @1.8.7-p72 lang/ruby | |
$ sudo port install ruby @1.8.7-p72 | |
---> Installing ruby @1.8.6-p114_0+darwin_9+thread_hooks | |
WTF!? |
This file contains 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
= link_to_remote(image_tag(video.thumbnail_url, :alt => h(video.title)), :update => 'main', :url => { :action => 'wtf', :id => video.id }) | |
# produces "/videos/wtf/77" | |
= link_to_remote(image_tag(video.thumbnail_url, :alt => h(video.title)), :update => 'main', :url => { :action => 'show', :id => video.id }) | |
# produces "/videos/77" | |
# notice how it *removed* the 'show' action from the url!? |
This file contains 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
# 1) Point *.example.com in your DNS setup to your server. | |
# | |
# 2) Setup an Apache vhost to catch the star pointer: | |
# | |
# <VirtualHost *:80> | |
# ServerName *.example.com | |
# </VirtualHost> | |
# | |
# 3) Set the current account from the subdomain | |
class ApplicationController < ActionController::Base |
This file contains 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
def has_role?(role) | |
# if list isn't already assigned to something, create an array of the names of my roles | |
list ||= self.roles.map(&:name) | |
# if list includes the string representation of the passed-in role [assumed to be the name] or if the list includes the string 'admin' [assumed to be the administrative role] return true | |
list.include?(role.to_s) || list.include?('admin') | |
end |
This file contains 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
# from: http://pivotallabs.com/users/alex/blog/articles/865-monkey-patch-du-jour | |
module ActiveRecord | |
module ConnectionAdapters | |
class AbstractAdapter | |
def log_info(sql, name, ms) | |
if @logger && @logger.debug? | |
@logger.debug("#{sql}, #{name}, #{ms}") | |
c = caller.detect{|line| line !~ /(activerecord|active_support|__DELEGATION__|\/lib\/|\/vendor\/plugins|\/vendor\/gems)/i} | |
c.gsub!("#{File.expand_path(File.dirname(RAILS_ROOT))}/", '') if defined?(RAILS_ROOT) | |
name = '%s (%.1fms) %s' % [name || 'SQL', ms, c] |
This file contains 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
def self.included(receiver) | |
receiver.class_eval <<-RUBY | |
named_scope :latest_before, lambda {|time| {:conditions => ['created_at < ?', time]}} | |
RUBY | |
end |
This file contains 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
def assert_close_enough(target, actual, message = nil) | |
lower = (0.9 * target.to_f).floor | |
upper = (1.1 * target.to_f).ceil | |
full_message = build_message(message, | |
"<?-?> expected but was\n<?>.\n", lower, upper, actual) | |
assert_block(full_message) { actual >= lower and actual <= upper } | |
end |
This file contains 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 gem install ZenTest actionmailer actionpack activerecord activeresource activesupport autotest-fsevent autotest-rails beanstalk-client capistrano capistrano-ext columnize ctran-annotate curb engineyard-eycap fastercsv fastthread highline hoe httpclient libxml-ruby linecache mysql net-scp net-sftp net-ssh net-ssh-gateway nokogiri passenger plist rack rails rake redgreen rspec rspec-rails ruby-debug ruby-debug-base rubyforge rubyist-aasm sevenwire-forgery soap4r sys-uname taf2-curb taf2-rmem thoughtbot-factory_girl |
This file contains 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
lrwxr-xr-x 1 root wheel 76 May 21 05:31 /usr/bin/ruby -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby |
OlderNewer