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
| END { p "This is the end, my only friend, the end." } | |
| p "Feeling very sleepy..." | |
| sleep 1 |
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
| # I've looked at the case at hand which is: | |
| # foo.bar -> foo: foo.bar | |
| # foo.bar -> foo: foo, format: bar | |
| # This roughly translates to: | |
| # For each part (foo, format), match as many possible subexpressions consisting of multiple word characters or one non-word characters | |
| # (we might say \. explicitly, in this specific case). Do this lazily, except for the last part, since that one needs to gobble up the rest. | |
| # And: If we have two or more parts, join them by a lazy match of a dot (\.?), which is not included in the named group. |
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 'yajl' | |
| class MasterChild | |
| def initialize | |
| @child, @parent = IO.pipe | |
| start_master_process_thread | |
| end | |
| # This runs a thread that listens to child processes. |
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 Book < ActiveRecord::Base; end | |
| Book.establish_connection YAML.load(File.open('db.yml')) |
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
| string_io = StringIO.new(...) | |
| class << string_io | |
| def overridden_method | |
| # ... | |
| 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
| # Runs with Picky 3.3.1. | |
| # | |
| # Note: You need some example html files in | |
| # the same directory. | |
| # | |
| # Index data and start: | |
| # 1. rake index | |
| # 2. ruby app.rb | |
| # | |
| # Then, search on it using: |
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 '/Users/admin/temp/picky/server/lib/picky' | |
| t0 = Time.now | |
| class Tweet | |
| attr_reader :id, :user, :text | |
| def initialize id, user, text | |
| @id, @user, @text = id, user, text | |
| 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
| # Available from Picky 3.2.1. | |
| # | |
| require 'picky' | |
| index = Picky::Index.new :dump_test do | |
| category :name | |
| end | |
| Thing = Struct.new :id, :name | |
| index.replace Thing.new(1, 'Picky') |
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
| # Possible since Picky 3.2.0. | |
| # | |
| require 'picky' | |
| include Picky | |
| Thing = Struct.new :id, :name | |
| index = Index.new :test do | |
| category :name, similarity: Similarity::DoubleMetaphone.new(3) |
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 Decoration | |
| def something | |
| p :in_decoration_calling_super | |
| super | |
| p :after_super | |
| end | |
| end |