Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Duly stolen from a Python version by nicolasH/apple system status.py https://gist.github.com/nicolasH/6102105 I think one can see that Ruby can be quite concise if you need to
#!/usr/bin/env ruby
# encoding: UTF-8
# ----------------------------------------------------------------------------
require 'nokogiri'
require 'open-uri'
require 'colorize'
doc = Nokogiri.HTML(open('https://developer.apple.com/support/system-status/'))
y = n = 0
puts '# ----------------------------------------------------'.white
doc.xpath('//td').each do |link|
print link.content
print ' '
if link[:class] == 'online'
puts "#{link[:class]}".green
y += 1
else
puts "#{link[:class]}".red
n += 1
end
end
puts '# ----------------------------------------------------'.white
puts "#{y + n} total, #{y} online, #{n} offline".white
@ghost

This comment has been minimized.

Copy link

commented Aug 30, 2014

Hey,
Is it possible for this to be done in PHP?
Thanks,
Felipe C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.