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 'rexml/parsers/baseparser' | |
module Kramdown | |
module Converter | |
# Converts a Kramdown::Document to Terminal | |
class Terminal < Html | |
def convert_blank(el, indent) |
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 'minitest/autorun' | |
class UsTaxCode | |
def generate(id) | |
"US-#{id}" | |
end | |
end | |
class BrazilTaxCode | |
def generate(id) |
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 Object | |
def when(matcher) | |
if matcher === self then yield(self) else self end | |
end | |
end | |
# I read it like this : if "when" lambda/proc is true execute block, otherwise return self | |
#deeply confused | |
#Proc#=== is equivalent to Proc#call |
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 'guerrilla_patch' | |
SPECIAL_ITEMS = { | |
legendary: [ 'Sulfuras, Hand of Ragnaros' ], | |
one_time_event: [ 'Backstage passes to a TAFKAL80ETC concert'], | |
better_with_age: ['Aged Brie'], | |
conjured: ['Conjured Mana Cake'] | |
} | |
QUALITY_AMOUNT_RULES = [ |
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 MaterialConsumption | |
include MultidimensionalTable | |
dimensions :year => [:year_1994, :year_1995], | |
:city => [:buenos_aires], | |
:material => [:coal, :potassium] | |
table_data do | |
year_1994 do | |
buenos_aires do |
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 MultidimensionalTable | |
@context = [] | |
@table_rules = {} | |
@attributes ||= {} | |
@index_level = 0 | |
def dimensions=(map) | |
@dimensions = map | |
@dimensions.each do |key, value| | |
value.each do |possible_value| |
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 MultidimensionalTable | |
def initialize | |
set_dimensions(dimensions) | |
data | |
end | |
def set_dimensions(map) | |
@dimensions = map | |
@dimensions.each do |key, value| |
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
@@ -590,7 +590,7 @@ class SpritesTest < Test::Unit::TestCase | |
it "should generate a sprite from nested folders" do | |
css = render <<-SCSS | |
- @import "nested/*.png"; | |
+ @import "nested/**/*.png"; | |
@include all-nested-sprites; | |
SCSS | |
assert_correct css, <<-CSS |
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
def self.evenly(amount, number_of_slices) | |
- allocator = Allocate.new | |
- allocator.amount = amount | |
- allocator.ratios = (1..number_of_slices).map { |rata| 1.to_d/number_of_slices } | |
- allocator.divided | |
+ Allocate.new.tap do |a| | |
+ a.amount = amount | |
+ a.ratios = (1..number_of_slices).map { 1.to_d/number_of_slices } | |
+ end.divided | |
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
def subseq(list) | |
list.drop(1).each_with_object([[list.first]]) do |number, sequences| | |
(number == sequences.last[-1] + 1) ? sequences.last << number : sequences << [number] | |
end.max_by(&:count).tap { |sequence| sequence.clear if sequence.count == 1 } | |
end | |
puts 'error 1' if subseq([1,0,1,2,3,0,4,5]) != [0,1,2,3] | |
puts 'error 2' if subseq([5,6,1,3,2,7]) != [5,6] | |
puts 'error 3' if subseq([2,3,3,4,5]) != [3,4,5] | |
puts 'error 4' if subseq([7,6,5,4]) != [] |
OlderNewer