Created
January 29, 2017 10:22
-
-
Save kennyng/02f259bcb10c407c4e626522da42d6f9 to your computer and use it in GitHub Desktop.
today-scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#----------------- | |
echo "Calendar: " | |
#----------------- | |
cal | grep --before-context 6 --after-context 6 --color -e " $(date +%e)" -e "^$(date +%e)" | |
#------------------- | |
echo "Time Zones: " | |
#------------------- | |
echo "San Francisco > `export TZ='US/Pacific';date +'%Y-%m-%d | %-l:%M %p';unset TZ`" | |
echo "Houston > `export TZ='US/Central';date +'%Y-%m-%d | %-l:%M %p';unset TZ`" | |
echo "Hong Kong > `export TZ='Asia/Hong_Kong';date +'%Y-%m-%d | %-l:%M %p';unset TZ`" | |
#---------------------- | |
echo "Top RAM Usage: " | |
#---------------------- | |
ps xmo rss=,pmem=,comm= | while read rss pmem comm; ((n++<5)); do | |
size="$[rss/1024]"; | |
short=$[4-${#size}]; | |
size="(${size}M)"; | |
i=0; | |
while ((i++ < short)); do size=" $size"; done; | |
pmem="${pmem%%.*}" | |
if (($pmem >= 20)); then color=$'\e[31m'; | |
elif (($pmem >= 10)); then color=$'\e[33m'; | |
else color=$'\e[32m '; | |
fi; | |
echo "$color$pmem% $size $(basename "$comm")"$'\e[0m'""; | |
done | |
#---------------------- | |
echo "System Status: " | |
#---------------------- | |
iStats | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`require "json" | |
require 'net/http' | |
url = "http://api.openweathermap.org/data/2.5/weather?q=Houston,USA" | |
resp = Net::HTTP.get_response(URI.parse(url)) | |
data = resp.body | |
hash = JSON.parse(data) | |
weather = hash['weather'][0]['description'] | |
weather2 = hash['weather'][0]['main'] | |
puts "Weather: #{weather2}; #{weather}" | |
puts "" | |
base = hash['main']['temp'] | |
temp = (base-273.15)*1.8000+32 | |
temp = (temp*10).ceil/10.0 | |
lowBase = hash['main']['temp_min'] | |
low = (lowBase-273.15)*1.8000+32 | |
low = (low*10).ceil/10.0 | |
highBase = hash['main']['temp_max'] | |
high = (highBase-273.15)*1.8000+32 | |
high = (high*10).ceil/10.0 | |
puts "Temperature: #{temp} Fahrenheit, Low: #{low}, High: #{high}"` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment