Skip to content

Instantly share code, notes, and snippets.

Info about the API:
https://www.weather.gov/documentation/services-web-api#/
Get Temp and Barometric Pressure:
$ curl -s https://api.weather.gov/stations/KORF/observations?limit=1 |jq .features[].properties.temperature.value,.features[].properties.barometricPressure.value |cut -b-5
List Stations
$ for X in `curl https://api.weather.gov/offices/AKQ |jq .approvedObservationStations[] -r`; do echo $X; curl $X |jq .properties.name; echo "---"; sleep 1; done > temp
Find the closest Forecast Office to lat/long:
@thejml
thejml / epoch.php
Created November 16, 2016 15:15
Takes a timestamp, gives you a Date.
#!/usr/bin/php
<?php
if (!isset($argv[1])) { echo "Give me a timestamp!"; }
$num = $argv[1];
// Autoconvert from JS timestamp
if ($num>9999999999) {
$num = $num/1000;
}
@thejml
thejml / t2d
Created September 24, 2015 14:16
t2d: Takes timestamps from a pipe and makes them useful date stamps.
#!/usr/bin/php
<?php
$fd = fopen("php://stdin", "r");
while ($line=fgets($fd)) {
$lx=explode(" ",$line);
echo date("Y-m-d H:i:s",trim($lx[0],"\t ;,.][{})(^&%$#@!=-\"':<>+/"));
unset($lx[0]);
$l=implode(" ",$lx);
echo " ".$l;
@thejml
thejml / ISO to USB
Created December 10, 2014 16:21
Create USB Boot Disk from ISO in Ubuntu
This is what worked for me:
If you have Startup Disk Creator, Disk Utility, or GParted open, close them, then:
1. Safely remove your USB flash drive and reinsert it
2. If it isn't already installed, install GParted through the Software Center or:
3. sudo apt-get -y install gparted
4. Open GParted (in Xubuntu/Xfce it's in Settings) and select the USB drive from the dropdown near the top right
5. If there are any partitions on the drive, right-click them → Unmount
6. Device → Create Partition Table → Select new partition table type → msdos → Apply
@thejml
thejml / httperfImport
Created March 28, 2014 21:20
Json Access Log to HTTPerf
#!/usr/bin/php
<?php
// Read in a json formatted access log, grab the 'request' portion, and output just that, line by line.
// Together with a '|tr "\n" "\0" ' will all you to convert those logs to a wlog you can replay with httperf
$f=fopen($argv[1],"r");
while ($line=fgets($f)){
$urij=json_decode($line,TRUE);
@thejml
thejml / OSX Hints
Created December 1, 2013 04:45
Random hints about OSX
To make an image in OSX Mountable as -o loop would in Linux, run:
hdiutil attach -imagekey diskimage-class=CRawDiskImage -nomount ImageName.iso
it will then say something like "/dev/disk1" and you can mount that where you want it.