Skip to content

Instantly share code, notes, and snippets.

@danielharan
Created October 10, 2008 14:04
Show Gist options
  • Save danielharan/16048 to your computer and use it in GitHub Desktop.
Save danielharan/16048 to your computer and use it in GitHub Desktop.
class String
def starts_with?(str)
self =~ /#{str}/
end
end
names_to_edid = File.open(File.dirname(__FILE__) + '/edid_names').read.split("\n").
collect {|line| edid, pruid, edname = line.split("|"); [edname.strip, edid.strip]}.
inject({}) {|hash,e| hash[e.first] = e.last; hash }
lines = File.open(ARGV[0]).read.split("\n").inject({}) {|hash,e| pc, rest = e.split(','); hash[pc] = rest; hash}
lines.reject! {|k,v| v.nil?}
lines.each do |k,v|
if v =~ /^[^a-z]*$/
puts "#{k},#{v}"
else
begin
edid = names_to_edid.detect {|name,edid| name.starts_with?(v)}.last
puts k + "," + edid
rescue
puts "oops on [#{k},#{v}]"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment