Skip to content

Instantly share code, notes, and snippets.

@shayelkin
Last active December 26, 2015 00:39
Show Gist options
  • Save shayelkin/7066142 to your computer and use it in GitHub Desktop.
Save shayelkin/7066142 to your computer and use it in GitHub Desktop.
Prints 10Bis pending orders
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
TENBIS_ID = 'xxx' # Get this value by inspecting the AJAX request
NOTIFY_EXPIRE = '30000'
require 'open-uri'
require 'json'
TENBIS_URL = "http://www.10bis.co.il/Restaurants/SearchRestaurants?deliveryMethod=Delivery&id=#{TENBIS_ID}&OrderBy=pool_sum"
begin
data = open TENBIS_URL
parsed = JSON.load data
rescue => e
$stderr.puts "#{e}\n"
ensure
data.close unless data.nil?
end
# PoolSum used to be float, now it's "₪ {float}"
orders = parsed.find_all do |i|
i['PoolSum'].split.map{|s| s.to_f}.reduce(:+) > 0
end
if orders.length > 0
msg = orders.map {|i| "#{i['RestaurantName']} — #{i['PoolSum']}"}.join "\n"
`notify-send -t #{NOTIFY_EXPIRE} --urgency=low \"#{msg}\"`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment