Last active
August 10, 2016 15:27
-
-
Save davidbalbert/34038f06b8c632931e6c8b4acc7b9248 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| require 'nokogiri' | |
| unless ARGV.size > 0 | |
| STDERR.puts "usage: #{$0} html-file" | |
| exit 1 | |
| end | |
| doc = File.open(ARGV[0]) { |f| Nokogiri::HTML(f) } | |
| puts doc.css('a').map { |a| a.attr('href') } |
This file contains hidden or 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 | |
| if ARGV.size < 2 | |
| STDERR.puts "usage: #{$0} previous-jobs.txt current-jobs.txt" | |
| exit 1 | |
| end | |
| def readfile(path) | |
| File.read(path).split("\n").reject { |line| line.strip == "" } | |
| end | |
| previous = ARGV[0] | |
| current = ARGV[1] | |
| prev = readfile(previous) | |
| curr = readfile(current) | |
| added = curr - prev | |
| removed = prev - curr | |
| puts "# Added" | |
| puts added | |
| puts | |
| puts "# Removed" | |
| puts removed | |
| puts | |
| puts "# Run this line to remove" | |
| puts "JobPosting.where(url: [#{removed.map(&:inspect).join(", ")}]).update_all(inactive: true)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment