Skip to content

Instantly share code, notes, and snippets.

@samgiles
Created June 5, 2013 13:39
Show Gist options
  • Save samgiles/5713917 to your computer and use it in GitHub Desktop.
Save samgiles/5713917 to your computer and use it in GitHub Desktop.
Weather command line app
#!/bin/sh
curl "http://forecast.io/forecast?q=51.4957,-0.2149&satellites" -H "If-None-Match: \"-852332961\"" -H "Accept-Encoding: application/json" -H "Host: forecast.io" -H "Accept-Language: en-US,en;q=0.8" -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36" -H "Accept: */*" -H "Referer: http://forecast.io/" -H "X-Requested-With: XMLHttpRequest" -H "Cookie: _gauges_unique_hour=1; _gauges_unique_day=1; _gauges_unique_month=1; _gauges_unique_year=1; _gauges_unique=1; __utma=188038335.1999350163.1370437973.1370437973.1370437973.1; __utmb=188038335.2.10.1370437973; __utmc=188038335; __utmz=188038335.1370437973.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)" -H "Connection: keep-alive" -H "Cache-Control: max-age=0" | awk -F"[,:]" '{for(i=1;i<=NF;i++){if($i~/time\042/){ print system("date -j -r" $(i+1) " +%d/%m:%H:%M")} if ($i~/summary\042/){print $(i+1)}} }' | egrep -v '^0$' | less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment