Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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