Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Finding the longest names in Cocoa
#!/usr/bin/ruby
# find /Developer /System/Library/Frameworks/ -name '*.h' | ruby find_long_names.rb > names.txt
names = []
STDIN.each_line do |line|
path = line.strip
begin
File.open(path, "r") do |file|
file.each_line do |fline|
fline.strip.scan(/\w{40,}/) do |name|
names << [name, path]
end
end
end
rescue Exception
# ignore
end
end
names.sort_by { |n| n.first.length }.reverse.each do |name, path|
puts "#{name.length}\t#{name}\t\t#{path}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment