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 'mini_magick' | |
class ImageResizer | |
attr_accessor :height, :width, :padding, :stretch, :grayscale | |
def initialize(path) | |
@image = MiniMagick::Image.open(path) | |
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
require 'sinatra' | |
require 'jimson' | |
class Api | |
extend Jimson::Handler | |
def get_data | |
{'foo' => 'bar'} | |
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
%w[sinatra watir-webdriver].each { |gem| require gem } | |
class MyApp < Sinatra::Base | |
get('/') { "hello world" } | |
end | |
class AppRunner | |
def initialize |
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 | |
def diagonals | |
[self, self.map(&:reverse)].inject([]) do |all_diags, matrix| | |
((-matrix.count + 1)..matrix.first.count).each do |offet_index| | |
diagonal = [] | |
(matrix.count).times do |row_index| | |
col_index = offet_index + row_index | |
diagonal << matrix[row_index][col_index] if col_index >= 0 | |
end | |
all_diags << diagonal.compact if diagonal.compact.count > 1 |
NewerOlder