Skip to content

Instantly share code, notes, and snippets.

@davidbalbert
Last active August 10, 2016 15:27
Show Gist options
  • Select an option

  • Save davidbalbert/34038f06b8c632931e6c8b4acc7b9248 to your computer and use it in GitHub Desktop.

Select an option

Save davidbalbert/34038f06b8c632931e6c8b4acc7b9248 to your computer and use it in GitHub Desktop.
#!/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') }
#!/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