Skip to content

Instantly share code, notes, and snippets.

@jordan-brough
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordan-brough/9141456 to your computer and use it in GitHub Desktop.
Save jordan-brough/9141456 to your computer and use it in GitHub Desktop.
Bash compliments when you clear your screen. You deserve it. ;)
# from https://gist.github.com/jordan-brough/fc085fa50f520ef022c9
# inspired by http://emergencycompliment.com/
function emergency_compliment {
ruby <<RUBY
require "rubygems"
require "json"
today = Time.now.strftime('%Y-%m-%d')
today_filename = "/tmp/compliments-#{today}.json"
latest_filename = "/tmp/compliments-latest.json"
json = if File.exist?(today_filename)
File.read(today_filename)
else
begin
require "net/http"
json = Net::HTTP.get("p-static.animoto.com", "/fun/compliments.js")
File.open(today_filename, 'w') { |f| f.puts json }
File.open(latest_filename, 'w') { |f| f.puts json }
json
rescue Exception
if File.exist?(latest_filename)
File.read(latest_filename)
end
end
end
if json
parsed = JSON.parse(json)
if RUBY_VERSION <= "1.8.7"
puts parsed.choice["phrase"]
else
puts parsed.sample["phrase"]
end
else
puts "YOU LOOK GOOD TODAY"
end
RUBY
}
function cls {
clear
echo " _"
echo " .-~ ) HI JORDAN! `emergency_compliment`"
echo " ..--~~~~,' ,-/ _"
echo " .-'. . . .' ,-',' ,' )"
echo " ,'. . . ,--~,-'__..-' ,'"
echo " ,'. . . (@)' ---~~~~ ,'"
echo " /. . . . '~~ ,-'"
echo " /. . . . . ,-'"
echo " ; . . . . - . ,'"
echo " : . . . . _ /"
echo " . . . . . \`-.:"
echo " . . . ./ - . )"
echo " . . . | _____..---.._/ _____"
echo "~---~~~~----~~~~ ~~"
echo ""
echo ""
echo ""
echo ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment