Skip to content

Instantly share code, notes, and snippets.

View nattaylor's full-sized avatar

Nat Taylor nattaylor

View GitHub Profile
@nattaylor
nattaylor / afd.py
Last active February 18, 2024 06:31
Area Forecast Discussion Parser
#!/usr/bin/env python3
"""Parse AFD and output formatted HTML
Design:
1. Retrieve AFD
2. Parse topics via regex
3. Light post-processing
4. Format HTML template
@nattaylor
nattaylor / ndbc.py
Created January 10, 2024 02:23
NDBC historical stdmet buoy data loader
"""Work with NDBC historical data"""
import io
import csv
import datetime
import gzip
import requests
import re
from typing import Iterable, Optional
@nattaylor
nattaylor / afd.php
Last active August 23, 2021 00:44
Area Forecast Discussion parser
<?php
/**
* Parse the NWS Area Forecast Discussion (AFD)
*
* Adds casing and formating to the AFD, which is published as an
* all uppercase `<pre>` block with hard line breaks and no formatting.
*
* Usage: <?php $afd = new AreaForecastDiscussion("BOX"); echo $afd->generateHTML(); ?>
*/
class AreaForecastDiscussion {
@nattaylor
nattaylor / apache2ga.php
Created November 5, 2019 02:30
Server-side Google Analytics
<?php
/**
* Send Apache Logs to Google Analytics
*/
// URL to send logs to
const GA = 'https://www.google-analytics.com/batch';
// Path to log to process
const LOG = '/var/log/httpd/access_log';
// Path to file storing byte offset of already processed
@nattaylor
nattaylor / out.php
Last active July 20, 2018 11:53
Zoning Board of Appeal Decisions - City of Boston
<!DOCTYPE html>
<html>
<head>
<title>Zoning Board of Appeal Decisions - City of Boston</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: sans-serif;
}
table {
@nattaylor
nattaylor / owa-notifications.user.js
Last active January 20, 2017 04:38
Outlook for Web Desktop Notifications Userscript
// ==UserScript==
// @name Outlook Web App Notifications
// @author nattaylor@gmail.com
// @namespace Notifications
// @include https://*/owa/*
// @exclude https://*/manifests/appCacheManifestHandler.ashx*
// @version 1
// @grant none
// @description Display WebAPI Desktop notifications for new messages
// ==/UserScript==
{
"491289025" : "ijinshan-kappmarket://",
"301521403" : "fb103361823069955://",
"492178411" : "ils492178411://",
"346142396" : "fb234434003713://",
"310633997" : "whatsapp://",
"370614765" : "com.condenet.newyorker://",
"325058491" : "rnmddisco://",
"382952264" : "epichttp://",
"477048487" : "predictwind://",
@nattaylor
nattaylor / quora.js
Created August 19, 2014 16:35
JavaScript snippets for parsing sites
//Sort open Quora questions by most recent
//Go through each item and give it a timestamp
jQuery(".pagedlist_item").each(function(i,e){
//Find the timestamp for each item
var ts = jQuery(e).find(".timestamp").text();
//Timestamps from the current year don't have a year
if (ts.indexOf(",")<0) {
ts += ", 2014";
ts = Date.parse(ts);