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
As the domain logic gets more complicated and you begin moving toward a | |
rich Domain Model (116), the simple approach of an Active Record (160) | |
starts to break down. The one-to-one match of domain classes to tables | |
starts to fail as you factor domain logic into smaller classes. | |
Relational databases don't handle inheritance, so it becomes difficult | |
to use strategies [Gang of Four] and other neat OO patterns. As the | |
domain logic gets feisty, you want to be able to test it without having | |
to talk to the database all the time. | |
Fowler, Martin (2002-11-05). Patterns of Enterprise Application |
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
Coloured fox fur production, HOPEDALE, Labrador, 1834-1842 | |
#Source: C. Elton (1942) "Voles, Mice and Lemmings", Oxford Univ. Press | |
#Table 17, p.265--266 | |
29 | |
22 | |
2 | |
16 | |
12 | |
35 | |
8 |
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
(fn [coll x] | |
(apply concat | |
(map | |
(fn [item] | |
(map | |
(fn [_] identity item) | |
(range x))) | |
coll))) |
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
(fn [x coll] | |
(keep #(if (= (count %) x) % nil) | |
(map #(map last %) | |
(vals | |
(group-by | |
#(quot (first %) x) | |
(map-indexed #(vector % %2) coll))))) | |
) |
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
module Car | |
def vroom | |
'<car noise>' | |
end | |
end | |
module Boat | |
def vroom | |
'<boat noise>' | |
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
# converted to stand-alone script | |
require 'minitest/autorun' | |
require 'minitest/unit' | |
require 'stringio' | |
# fake out the logger | |
class Rails | |
@@logger = StringIO.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
If file exists in both places: | |
git diff target_branch source_branch relative_path_to_file | git apply | |
If file is new on other branch: | |
git checkout source_branch relative_path_to_file | |
The checkout will work even if the file exists, and will stomp it, |
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
Open git history for the file. | |
In annotate view, find the line of code and the sha. | |
Select history view and start typing the sha until it's selected. | |
Type 'esc', then down arrow. | |
Right-click and select "Annotate" - this will open the prior rev in the editor in annotate view. | |
Find that line of code and repeat. |
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
child = fork do | |
at_exit { $stderr.puts "Child one is done." } | |
exit # superfluous | |
end | |
Process.wait | |
$stderr.puts "Parent is done waiting for child one #{child}." | |
child = fork do | |
at_exit { $stderr.puts "This won't get hit." } | |
exit! |
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
18930: Parent | |
18933: Child A | |
18934: Child B | |
18933: END in child if only exit called | |
18933: at_exit in child if only exit called | |
18933: parent END (only one) | |
18933: parent at_exit (2 times) | |
18933: parent at_exit (2 times) | |
18930: parent: child died | |
18930: parent trap(0) |
OlderNewer