Skip to content

Instantly share code, notes, and snippets.

@corwin-of-amber
Last active March 3, 2026 12:51
Show Gist options
  • Select an option

  • Save corwin-of-amber/898c86a34b4db85127fb8cd9d9028723 to your computer and use it in GitHub Desktop.

Select an option

Save corwin-of-amber/898c86a34b4db85127fb8cd9d9028723 to your computer and use it in GitHub Desktop.
oref.org.il alters
#!/usr/bin/env zx
const LOC = "תל אביב - עבר הירקון";
function head(s, n=10) {
if (typeof s === 'object') s = JSON.stringify(s, null, 2);
return s.split('\n').slice(0, n).join('\n');
}
let a = await (await fetch('https://www.oref.org.il/warningMessages/alert/Alerts.json')).json().catch(() => ({}));
let b = await (await fetch('https://www.oref.org.il/warningMessages/alert/History/AlertsHistory.json')).json().catch(() => ([]));
let c = await (await fetch(`https://alerts-history.oref.org.il/Shared/Ajax/GetAlarmsHistory.aspx?lang=he&mode=1&city_0=${LOC}`)).json().catch(() => ([]));
let old = await fs.readFile('/tmp/a.json', 'utf-8')
.then(JSON.parse).catch(() => ({}));
console.log(head(a))
console.log(head(b.filter(r => r.data == LOC), 15))
console.log(head(c.filter(r => r.data == LOC), 20))
if (a?.id && old?.id !== a.id && a.data.some(r => r == LOC))
$`alerter --message ${`${a.data}`} --title ${a.title} --timeout 3`
fs.writeFile('/tmp/a.json', JSON.stringify(a))
@corwin-of-amber
Copy link
Author

Mac users: use Homebrew.

brew install zx alerter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment