Hacker Public Radio

HPR4266: What's the weather?


Listen Later

This show has been flagged as Clean by the host.

One web service that can find out the weather on the command line

is:

$ curl wttr.in

Inspired by this is the following script in PHP that uses data from

7timer.info

Available at https://gist.github.com/macsplit

"☀️ Hot Day",
'clearday' => "☀️ Clear Day",
'clearnight' => "🌙 Clear Night",
'pcloudyday' => "⛅ Partially Cloudy Day",
'pcloudynight' => "☁️ Partially Cloudy Night",
'mcloudyday' => "🌥️ Moderately Cloudy Day",
'mcloudynight' => "☁️ Moderately Cloudy Night",
'cloudyday' => "☁️ Cloudy Day",
'cloudynight' => "☁️ Cloudy Night",
'humidday' => "🌡️ Humid Day",
'humidnight' => "🌡️ Humid Night",
'lightrainday' => "🌧️ Lightly Rainy Day",
'lightrainnight' => "🌧️ Lightly Rainy Night",
'oshowerday' => "🌧️ Overcast Showery Day",
'oshowernight' => "🌧️ Overcast Showery Night",
'ishowerday' => "🌧️ Showery Day",
'ishowernight' => "🌧️ Showery Night",
'lightsnowday' => "❄️ Lightly Snowy Day",
'lightsnownight' => "❄️ Lightly Snowy Night",
'rainday' => "🌧️ Rainy Day",
'rainnight' => "🌧️ Rainy Night",
'snowday' => "❄️ Snowy Day",
'snownight' => "❄️ Snowy Night",
'rainsnowday' => "🌨️ Rainy and Snowy Day",
'rainsnownight' => "🌨️ Rainy and Snowy Night"
];
$json = file_get_contents($url);
if (!$json) exit();
$obj = json_decode($json);
$init = DateTime::createFromFormat('YmdH', $obj->init)->getTimestamp();
$series = $obj->dataseries;
$now = time();
foreach ($series as $k => $point) {
$timepoint = $point->timepoint;
$timestamp = $init + ($timepoint * 3600);
$diff = abs($timestamp - $now);
$data[$diff] = $point;
}
$key = min(array_keys($data));
$measure = $data[$key];
$temperature = $measure->{'temp2m'};
$weather_desc = $weathers[$measure->weather];
echo "$weather_desc $temperature"."°C\n";
?>

Editor's Note: Modified 2024-11-13 in line with comment #1

Provide feedback on this episode.

...more
View all episodesView all episodes
Download on the App Store

Hacker Public RadioBy Hacker Public Radio

  • 4.2
  • 4.2
  • 4.2
  • 4.2
  • 4.2

4.2

34 ratings


More shows like Hacker Public Radio

View all
The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

291 Listeners

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec by Jerry Bell and Andrew Kalat

Defensive Security Podcast - Malware, Hacking, Cyber Security & Infosec

374 Listeners

LINUX Unplugged by Jupiter Broadcasting

LINUX Unplugged

266 Listeners

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast) by Johannes B. Ullrich

SANS Internet Stormcenter Daily Cyber Security Podcast (Stormcast)

653 Listeners

Curious Cases by BBC Radio 4

Curious Cases

824 Listeners

The Strong Towns Podcast by Strong Towns

The Strong Towns Podcast

426 Listeners

Late Night Linux by The Late Night Linux Family

Late Night Linux

164 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

8,015 Listeners

Cybersecurity Today by Jim Love

Cybersecurity Today

177 Listeners

CISO Series Podcast by David Spark, Mike Johnson, and Andy Ellis

CISO Series Podcast

189 Listeners

TechCrunch Daily Crunch by TechCrunch

TechCrunch Daily Crunch

41 Listeners

Strict Scrutiny by Crooked Media

Strict Scrutiny

5,783 Listeners

2.5 Admins by The Late Night Linux Family

2.5 Admins

97 Listeners

Cyber Security Headlines by CISO Series

Cyber Security Headlines

136 Listeners

What the Hack? by DeleteMe

What the Hack?

222 Listeners