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; | |
import javax.mail.*; | |
import javax.mail.internet.*; |
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 |
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; |
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 |
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 |
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 |
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 |
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]] |
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 } |
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 |
NewerOlder