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 'tire' | |
# Tire.configure { logger STDERR, level: 'debug' } | |
Tire.index('movie-titles') do | |
delete | |
create \ | |
settings: { | |
index: { | |
analysis: { |
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
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Returns the result of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |
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
Sequel.migration do | |
up do | |
run 'CREATE EXTENSION "uuid-ossp"' | |
create_table :products do | |
column :id, :uuid, :default => Sequel.function(:uuid_generate_v4), :primary_key => true | |
end | |
end | |
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
## | |
# This is rake task of padrino-framework | |
# Display lists of all stacked rack middleware for your padrino app. | |
# distributed under the MIT License(http://tyabe.mit-license.org/) | |
# | |
def stacked_middlewares(app, args) | |
require Padrino.root('config/boot.rb') | |
app_obj = app.app_obj | |
instance = app_obj.new! | |
build = app_obj.build(instance) |
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
class Array | |
# Returns a proc which calls [] with the array's contents as arguments | |
# | |
# ====Usage | |
# [[1, 2], [3, 4], [5, 6]].map(&[0]) | |
# # => [1, 3, 5] | |
# | |
# [{ hello: 'world' }, { hello: 'sun', goodbye: 'moon' }].map(&[:hello]) | |
# # => ['world', 'sun'] |
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 Ova | |
# autovivifying map from [class][method][signature] to Method | |
@@Ova = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) } | |
# Wrap #respond_to? for parity with Class#===. | |
Responder = Struct.new(:method) do | |
def === obj | |
obj.respond_to?(method) | |
end | |
end |
NewerOlder