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
// Given an interface (IFactory<> in this example), find everything that | |
// implements the interface and put it in a map. | |
// | |
// Usage: | |
// public interface IFactory<T> { ... } | |
// public class AppleFactory : IFactory<Apple> { ... } | |
// public class BananaFactory : IFactory<Banana> { ... } | |
// public class ChocolateFactory : IFactory<Chocolate> { ... } | |
// | |
// var m = new FactoryManager(); // Automatically scans this assembly for suitable implementations |
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 'tempfile' | |
t = Tempfile.new('test-data') | |
t.open | |
t.sync = true | |
t << "apples" | |
t.puts "bananas" | |
# prints "contents are [] (14 bytes)" | |
puts "contents are [#{t.read}] (#{t.size} bytes) |
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
[johnf@genesis][2010/06/12|17:53:00] | |
[/tmp]> mkdir foo | |
[johnf@genesis][2010/06/12|17:53:36] | |
[/tmp]> cd foo | |
[johnf@genesis][2010/06/12|17:53:39] | |
[/tmp/foo]> git init | |
Initialized empty Git repository in /tmp/foo/.git/ | |
[johnf@genesis][2010/06/12|17:53:40] |
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
diff --git a/scripts/cli b/scripts/cli | |
index b4cd70e..496d322 100644 | |
--- a/scripts/cli | |
+++ b/scripts/cli | |
@@ -280,6 +280,7 @@ __rvm_parse_args() { | |
;; | |
system|default) | |
+ echo "Reverting to predefined interpreter '${rvm_token}'." | |
rvm_action=${rvm_action:-use} |
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
b = lambda { |e| e.kind_of?(Array) ? e.map(&b) : (e.nil? ? "" : e) } | |
# => #<Proc:0x0000000104d908@(irb):1 (lambda)> | |
arr = [5, 6, 7, nil, [nil], [6, 8, nil], [[194, 48, nil], [nil]]] | |
# => [5, 6, 7, nil, [nil], [6, 8, nil], [[194, 48, nil], [nil]]] | |
arr.map(&b) | |
# => [5, 6, 7, "", [""], [6, 8, ""], [[194, 48, ""], [""]]] |
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
#RSpec 1.3.0, #Ruby 1.9.1 | |
describe "Simple class" do | |
before :each do | |
@c = Class.new do | |
attr_accessor :apple | |
end.new | |
@c.apple = [] | |
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
# in <project_root>/bin/magicwand | |
MagicWand::Configuration::Initializer.new(...) | |
# in <project_root>/data/root.yaml | |
--- | |
apple: 100 | |
banana: 200 | |
coconut: 300 | |
# ---------------------------------- |
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
(master)[johnf@dev-dzb-genesis-lambda][2010/07/06|16:00:24] | |
[~/dev/project-194/www]> gem install resque | |
Building native extensions. This could take a while... | |
Successfully installed redis-2.0.3 | |
Successfully installed redis-namespace-0.5.1 | |
Successfully installed vegas-0.1.7 | |
Successfully installed sinatra-1.0 | |
Successfully installed json-1.4.3 | |
Successfully installed resque-1.9.5 | |
6 gems installed |
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
"Everyone thinks they’re writing the most performance-critical code | |
in the world, but in reality maybe one in twenty programmers are | |
writing code where anything short of the most egregious bloat and | |
carelessness will affect the performance of the system overall. | |
Unfortunately, egregious bloat and carelessness are quite common." | |
-- Jeff Darcy writing at http://pl.atyp.us/wordpress/?p=2947 |
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
lib = File.expand_path('../lib/', __FILE__) | |
$:.unshift lib unless $:.include?(lib) | |
require 'constructify/version' | |
Gem::Specification.new do |s| | |
s.name = "constructify" | |
s.version = Constructify::VERSION | |
s.platform = Gem::Platform::RUBY | |
s.authors = ["John Feminella"] |