Every couple of weeks, I hear someone complaining about some difficulties with Bundler. Yesterday, it happened twice. But somehow I just never have those difficulties. I'm not saying Bundler is perfect; certainly in its early days it wasn't even close. But for the past two years it's been incredibly solid and trouble-free for me, and I think a large part of the reason is the way I use it. Bundler arguably does too much, and just as with Git, a big part of it is knowing what not to do, and configuring things to avoid the trouble spots.
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
(spit (nth *command-line-args* 2) | |
(clojure.string/join "\n" | |
(sort (clojure.string/split-lines (slurp (nth *command-line-args* 1)))))) |
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
# I source this from ~/.bash_profile | |
# I think I got them from @JEG2 | |
BUNDLED_COMMANDS="foreman rackup rails rake rspec ruby shotgun spec watchr nesta cap" | |
## Functions | |
bundler-installed() | |
{ | |
which bundle > /dev/null 2>&1 |
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
#!/bin/sh | |
exec "$GIT_EXEC_PATH/git" "$@" |
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
require 'active_record' | |
module ActiveRecord | |
module Associations | |
# This fix allows the association extension methods to work when used in combination | |
# with built-in Arel scoping methods (where, joins, etc.) and *also* with named scopes | |
# defined on the target class. | |
class AssociationProxy | |
def with_scope_with_extensions(*args, &block) |
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 evolve(generation) | |
live_neighbor_stats = generation_stats(generation) | |
live_neighbor_stats[3] + (live_neighbor_stats[2] & generation) | |
end | |
def generation_stats(live_cells) | |
live_cells.each_with_object(Hash.new(0)) {|live_cell, counter| | |
neighbors(*live_cell).each {|neighbor| counter[neighbor] += 1 } | |
}.each_with_object(Hash.new {|h,k| h[k] = []}) {|(cell, count), collector| collector[count] << cell} | |
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
# for background, see http://m.onkey.org/use-index-with-active-record-finders | |
# and http://twitter.com/#!/dougalcorn/status/4963159878139904 | |
from = "#{quoted_table_name} USE INDEX(index_activities_on_created_at_and_country_id)" | |
Activity.from(from).where('created_at >= ? AND country_id = ?', 10.days.ago, 79).all |
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
# Put this in your .irbrc, and then type | |
# "some_object.my_methods" in an IRB session | |
# for less noisy exploration of what objects | |
# can do. | |
class Object | |
def my_methods | |
base_object = case self | |
when Class then Class.new | |
when Module then Module.new |
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
entries.map(&:job).sort_by(&:number).map(&:project).compact.uniq |
NewerOlder