Skip to content

Instantly share code, notes, and snippets.

@rajeevriitm
Last active September 9, 2016 18:56
Show Gist options
  • Save rajeevriitm/73408228cf0500404718210850e10f87 to your computer and use it in GitHub Desktop.
Save rajeevriitm/73408228cf0500404718210850e10f87 to your computer and use it in GitHub Desktop.
Latest upwork job notification using Ruby Script

This is a Ruby script for notifying new job arrivals from your upwork feed. Notification includes a tome played using mpg321 applocation and linux desktop notification.You need to store the header file http request to "cred_file" mentioed (use your network inspector ). This output latest project name to a "project" file. Everything is self-explanotory. ( Dont forget to chmod +x )

#!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
require 'httparty'
require 'libnotify'
mp3_file="/home/raj/bin/tone.mp3"
cred_file = "/home/raj/bin/cred.yml"
project_file = "/home/raj/bin/latest"
url = "https://www.upwork.com/ab/find-work/api/feeds/search"
cred= YAML.load(File.read(cred_file))
while true
begin
# puts 2
response = HTTParty.get(url,headers: cred)
project = JSON.parse(response.body)
latest=project["results"][0]["title"]
File.open(project_file, "r+") do |f|
f.each_line do |line|
unless line == latest
pid = fork{ exec '/usr/bin/mpg321','-q', mp3_file }
File.open(project_file,"w+") {|ft| ft.write(latest)}
Libnotify.show(:summary => latest, :timeout => 2.5)
end
end
end
sleep 300
rescue =>e
puts e
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment