Skip to content

Instantly share code, notes, and snippets.

@williamho
Created June 19, 2014 00:02
Show Gist options
  • Save williamho/6e5c2d1b1b192e2b4ac8 to your computer and use it in GitHub Desktop.
Save williamho/6e5c2d1b1b192e2b4ac8 to your computer and use it in GitHub Desktop.
extract unique referer
require 'json'
file = File.read 'ads_merg_conf.json'
json = JSON.parse file
ir = json.flat_map do |placement, values|
next unless values.is_a? Hash
values['flights'].to_a.map do |f|
f['include'].to_a.map do |i|
i.to_h['where'].to_h['referer']
end
end
end.flatten.uniq.compact
puts ir.join(', ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment