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 Post | |
| include Mongoid::Document | |
| field :title, :type => String | |
| has_many :comments do | |
| def update(selector, params) | |
| @target.each { |t| t.update_attributes(params) if t.matches?(selector) } | |
| end | |
| end | |
| 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
| require 'eventmachine' | |
| require 'net/pop' | |
| class Popper | |
| attr_accessor :pop, :read_messages | |
| def initialize(hostname, port, user, password) | |
| @pop = Net::POP3.start(hostname, port, user, password) | |
| @read_messages = [] | |
| load_message_ids |
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 Asset | |
| include Mongoid::Document | |
| field :name | |
| field :peer_ids, :type => Array, :default => [] | |
| def link_asset(asset_id) | |
| unless self.peer_ids.include?(asset_id) || self.id == asset_id | |
| self.peer_ids << asset_id | |
| Asset.find(asset_id).link_peer(self.id) | |
| 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
| # encoding: utf-8 | |
| require "nokogiri" | |
| @doc = Nokogiri::HTML::Document.new | |
| def my_partial(parent) | |
| Nokogiri::HTML::Builder.with parent do | |
| p_ "foo" | |
| p_ "bar" | |
| 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
| # encoding: utf-8 | |
| require "Foo" | |
| class Bar | |
| def self.say_hello | |
| Foo.say_hello | |
| 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
| require 'integration_helper' | |
| require 'rack' | |
| require 'rack/handler/webrick' | |
| describe HttpClient do | |
| before :all do | |
| @server = WEBrick::HTTPServer.new( | |
| :Port => 9293, | |
| :Logger => Rails.logger, | |
| :AccessLog => Rails.logger |
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
| # this is a configurable version of an EventMachine syslogger | |
| # It was build to replace https://github.com/melito/em-syslog | |
| # | |
| # You can instantiate many of them (no global variables) as | |
| # well as configure the facility. It also quacks like a ruby | |
| # logger so it can be interchanged with a ruby logger. | |
| # | |
| # Example: | |
| # | |
| # # 11 is the facility code for an FTP daemon |
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
| ************************************ | |
| * minitest gem: minitest-4.3.1 * | |
| ************************************ | |
| Run options: --seed 65366 | |
| # Running tests: | |
| .E |
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
| curl -XPUT http://localhost:9200/users/_mapping -d '{ | |
| "user" : { | |
| "properties" : { | |
| "author" : { | |
| "type" : "string", | |
| "analyzer" : "string_lowercase" | |
| } | |
| } | |
| } | |
| }' |
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 'eventmachine' | |
| module Sample | |
| class Runner | |
| DEFAULT_INTERVAL_IN_SECS = 1 | |
| def initialize(command, interval=DEFAULT_INTERVAL_IN_SECS) | |
| @command = command | |
| @interval = interval | |
| end |
OlderNewer