View c11r.rb
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
# Written by Michael Feathers July 10th, 2020 | |
class Command | |
def run line, session | |
return unless matches? line | |
process line, session | |
end | |
end | |
class FixView < Command |
View Server.java
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
package server; | |
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.util.Date; | |
import java.util.Properties; | |
import java.util.Vector; |
View c11r.rb
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 Command | |
def run line, session | |
return unless matches? line | |
process line, session | |
end | |
end | |
class FixView < Command | |
def matches? line |
View churn.sh
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
find . -name "*.rb" |xargs -n1 -I file sh -c 'echo `git log --oneline file | wc -l`: file'|sort -nr |
View zom.rb
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 'set' | |
require 'find' | |
class Array | |
def to_h; Hash[self]; end | |
def to_set; Set.new(self); end | |
def freq; group_by {|e| e }.map {|k,v| [k,v.count] }.to_h; end | |
end |
View wardish.rb
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
# http://c2.com/doc/SignatureSurvey/ | |
require 'find' | |
def file_text file_name | |
IO.read(file_name).scan(/[{};]/).join | |
rescue | |
"error in file" | |
end |
View linebreak.hs
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
-- code from https://www.infoq.com/presentations/Type-Functional-Design with bug related to | |
-- assumption of trailing spaces after words | |
import Data.List; | |
lineBreak :: String -> String | |
lineBreak = joinedLines . wordJoinedLines . brokenLines . words | |
brokenLines :: [String] -> [[String]] |
View words.rb
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 prefixes | |
result = [] | |
(0..size).each {|n| result << take(n) } | |
result | |
end | |
def indices value | |
map {|v| v == value ? 0 : 1 } |
View gist:47183550dd10914e147b
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 span_count ary | |
([0] + ary).lazy | |
.each_cons(2) | |
.count {|c,n| c == 0 && n != 0 } | |
end |
View gist:1e2934ebb95560cddc3b
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
# :: [event] -> String -> String | |
def method_delta_line es, method_name | |
es.select {|e| e.method_name == method_name } | |
.map(&:method_length) | |
.each_cons(2) | |
.map {|c,n| ["^","v","-"][(c <=> n) + 1] } | |
.join | |
end |
NewerOlder