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
# You will need the pygments and xclip packages | |
# This example highlights some Bash source code | |
# '-O noclasses=true' tells pygments to embed colors inline in the source | |
# the '-t text/html' option tells xclip what "target" to specify for the selection | |
pygmentize -l bash -f html -O noclasses=true mysource.sh | xclip -selection clipboard -t text/html |
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 'matrix' | |
module LLR | |
def self.calculate(m) | |
2 * (m.to_a.flatten.h - m.row_vectors.map(&:sum).h - m.column_vectors.map(&:sum).h) | |
end | |
def sum | |
to_a.inject(nil) { |sum, x| x = yield(x) if block_given?; sum ? sum + x : x } | |
end |