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
# MF: Handle 'last method of class' case | |
FileName = ARGV[0] | |
MethodName = ARGV[1] | |
def numbered_lines(file_name) | |
lines = [] | |
File.open(file_name).each_line {|line| lines << 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
#!/usr/bin/env ruby | |
# Print the vaportrail of a ruby file in a git repo, i.e., | |
# the complexity level at each commit. | |
# | |
# Requires: >= bash ?.? | |
# >= git 1.7.1 | |
# >= ruby 1.9.2 | |
# >= flog 2.5.0 | |
# |
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
#!/usr/bin/env ruby | |
# Print the complexity over time for a Ruby method in a | |
# git repository. | |
# | |
# Requires: >= bash ?.? | |
# >= git 1.7.1 | |
# >= ruby 1.9.2 | |
# >= flog 2.5.0 | |
# |
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
#!/usr/bin/env ruby | |
# Print the complexity over time for a Ruby method in a | |
# git repository. | |
# | |
# Requires: >= bash ?.? | |
# >= git 1.7.1 | |
# >= ruby 1.9.2 | |
# >= flog 2.5.0 | |
# |
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
#!/usr/bin/env ruby | |
# Print the complexities of all methods over time | |
# for a class in a git repo. | |
# | |
# Requires: bash | |
# >= git 1.7.1 | |
# >= ruby 1.9.2 | |
# >= flog 2.5.0 |
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
# gccmock - generate exploding link stubs from linker error messages | |
# | |
# Usage: gcc [files] 2>&1 ruby gccmock.rb > [filename].c | |
LINK_SYMBOL = /.*"_([_a-z0-9]*)",/ | |
puts "#include <assert.h>\n" | |
puts "#define EXPLODE(name) void name() { assert(!\"unexpected call\"); }" | |
puts ARGF.select { |line| LINK_SYMBOL =~ line } \ | |
.map { |line| LINK_SYMBOL.match(line)[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
sys = require('sys'); | |
function Cell(x,y) { | |
this.x = x; | |
this.y = y; | |
this.state = (((x - 10) * (x - 10) + (y - 10) * (y - 10)) % 5) == 0 | |
} | |
Cell.prototype.run = function() { | |
if (this.state == true) |
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 perform | |
@results ||= {} | |
puts "Looking up query" | |
query = Query.find_by_id(options["query_id"]) | |
engine = Quote::Engine.create(query) | |
puts "Finding quotes" | |
quotes = engine.find_quotes(options["options"]) | |
puts "Found quotes" | |
# NOTE: | |
# This is here so that sorting and filtering can take advantage |
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] -> [month,int] | |
def avg_lines_per_commit_by_month events | |
cls_by_month = lines_added_per_commit(events).group_by {|date,_| month_from_date(date) } | |
cls_by_month.map {|_,cls| cls.map {|cl| cl[1]}.mean }.flatten | |
end | |
# :: [event] -> Float | |
def percent_reduction method_events | |
non_deleted = method_events.select {|e| e.status != :deleted } | |
return 0.0 if non_deleted.count == 0 |
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
-- Modeled on the behavior of https://github.com/burkhartt/Tim.SentenceParser/blob/master/Tim.SentenceParser/Tim.SentenceParser/SentenceParser.cs | |
import Char | |
withoutLastWord :: String -> String | |
withoutLastWord = unwords . init . words | |
sentenceBefore :: String -> Int -> String | |
sentenceBefore "" _ = "" | |
sentenceBefore _ 0 = "" |
OlderNewer