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
| #!/usr/bin/env ruby -Ku | |
| # encoding: utf-8 | |
| require 'rubygems' | |
| require 'dm-core' | |
| require 'graphviz' | |
| def recursive_require(dir) | |
| Dir.glob("#{dir}/**/*.rb").sort.each { |file| require file } |
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
| #!/usr/bin/env ruby -Ku | |
| # encoding: utf-8 | |
| require 'pp' | |
| require 'rubygems' | |
| require 'dm-core' | |
| DataMapper::Logger.new($stdout, :debug) | |
| DataMapper.setup(:default, 'sqlite3::memory:') |
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
| #!/usr/bin/env ruby -Ku | |
| # encoding: utf-8 | |
| require 'rubygems' | |
| require 'dm-core' | |
| require 'dm-migrations' | |
| DataMapper::Logger.new($stdout, :debug) | |
| DataMapper.setup(:default, 'sqlite3::memory:') |
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
| #!/usr/bin/env ruby -Ku | |
| require 'rubygems' | |
| require 'dm-core' | |
| require 'dm-sweatshop' | |
| require 'bacon' | |
| #DataMapper::Logger.new($stdout, :debug) | |
| DataMapper.setup(:default, 'sqlite3::memory:') |
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
| include 'dm-is-list' | |
| class Node | |
| include DataMapper::Resource | |
| property :id, Serial | |
| # other properties... | |
| has n, :parts | |
| 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
| class AppBuilder < Rails::AppBuilder | |
| #include Thor::Actions | |
| #include Thor::Shell | |
| @@versions = %w( 1.4.2 1.4.1 1.4.0 1.3.2 1.3.1 1.3.0 1.2.6 ) | |
| def test | |
| append_test_gems | |
| 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
| require 'pathname' | |
| require 'fileutils' | |
| require 'set' | |
| base = Pathname('/newdir/obsolete') | |
| old_dirs = Set.new | |
| Pathname.glob('dir/*/obsolete/*').each do |pn| | |
| dir, file = pn.split | |
| customer = dir.parent.basename |
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
| def async_fetch(url) | |
| f = Fiber.current | |
| http = EventMachine::HttpRequest.new(url).get :timeout => 10 | |
| http.callback { f.resume(http) } | |
| http.errback { f.resume(http) } | |
| return Fiber.yield | |
| 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
| def my_open(filename) | |
| filename = filename.to_path if filename.respond_to?(:to_path) | |
| filename = filename.to_str | |
| # ... | |
| 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
| module Functional | |
| module_function | |
| def unary | |
| ->(a,*b){ a} | |
| end | |
| def binary | |
| ->(a,b,*c){ [a,b]} |
OlderNewer