Skip to content

Instantly share code, notes, and snippets.

@mackuba
Last active December 11, 2019 18:00
Show Gist options
  • Save mackuba/656718 to your computer and use it in GitHub Desktop.
Save mackuba/656718 to your computer and use it in GitHub Desktop.
Finding the longest names in Cocoa
#!/usr/bin/ruby
# find /Applications/Xcode.app/Contents/Developer/Platforms -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, n.last] }.uniq.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