Last active
August 29, 2015 14:08
-
-
Save gmodarelli/4c2804d72be07263b02d to your computer and use it in GitHub Desktop.
Revisions
-
gmodarelli revised this gist
Nov 13, 2014 . 1 changed file with 19 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,20 @@ module MyModule chars = %w(A B C) words = chars.permutation.to_a words.each do |word| method_name = word.join module_eval(<<-PERMUTATION, __FILE__, __LINE__) def #{method_name} puts "#{word}" end PERMUTATION end end include MyModule abc # => nil # >> a # >> b # >> c -
gmodarelli revised this gist
Nov 6, 2014 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ module_eval(<<-YMD, __FILE__, __LINE__) def #{name}(date = nil) #{set[0]} << #{set[1]} << #{set[2]}(date) end YMD -
gmodarelli revised this gist
Nov 6, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ chars = %w(A B C) words = chars.permutation(2).to_a # => [["A", "B"], ["A", "C"], ["B", "A"], ["B", "C"], ["C", "A"], ["C", "B"]] -
gmodarelli revised this gist
Nov 6, 2014 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ chars = %w(A B C) words = chars.permutation.to_a # => [["A", "B", "C"], # ["A", "C", "B"], # ["B", "A", "C"], # ["B", "C", "A"], # ["C", "A", "B"], # ["C", "B", "A"]] -
gmodarelli revised this gist
Nov 6, 2014 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ names = [ 'Giuseppe', 'Giulia', 'Luca', 'Andrea', 'Roberto' ] grouped_by_first_letter = names.group_by { |name| name[0] } puts grouped_by_first_letter # >> {"G"=>["Giuseppe", "Giulia"], "L"=>["Luca"], "A"=>["Andrea"], "R"=>["Roberto"]} -
gmodarelli created this gist
Nov 6, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ define_method(abbr) { |date = nil| DatePart.new(abbr, date) }