Skip to content

Instantly share code, notes, and snippets.

@antipole2
antipole2 / pending-submission-notifications.php
Created October 16, 2018 06:27
Version of WordPress plugin 'Pending Submission Notifications' that handles bbPress topics and replies as well as posts.
<?php
/**
* Plugin Name: Ovni Pending Submission Notifications
*
* Description: Send email notifications to the admin whenever a new post, topic or reply is submitted for review by a contributor.
* Also notifies subscribers when a pending post or topic is published
* Author: Tony Voss
* Text Domain: Ovni-pending-submission-notifications
* Version: 1.0
* Credits: Basically a clone of the plugin pending-submission-notifcations by Razvan Horeanga
@antipole2
antipole2 / Ovni_chop_up_emails
Created March 2, 2019 12:56
Chops up WordPress out-going emails so that number of bcc addressees stays below a configured limit
<?php
/*
Plugin Name: Ovni chop up emails
Description: Prevents number of Bcc addresees exceeding defined limit by breaking it up into multiple emails.
Author: Tony Voss
Version: 1.0 1 Mar 2019
History
Version: 1.0 1 Mar 2019 Initial version
@antipole2
antipole2 / sendActiveRoute.js
Last active July 23, 2020 10:03
Position constructor
// This script sends any active route out as WPT and RTE sentences so that iNavX shows the up-to-date active route.
// If the route or its waypoints are updated, iNavX will update to reflect this
Position = require("Position); // load position constructor
// here we define stuff we need outside the functions
const repeatInterval = 20; // repeat after this number of seconds
var activeWaypointName = “”; // to hold the active waypoint name, else “”
var activeRouteName = ""; // the name of the active route
var lastRoutePoint; // these two are needed to fix up RMB sentences and synthesise a BOD sentence…
routeGUID = "48cf3bc5-3abb-4f73-8ad2-994e796289eb";
OCPNonMessageName(handleRT, "OCPN_ROUTE_RESPONSE");
OCPNsendMessage("OCPN_ROUTE_REQUEST",JSON.stringify({"GUID":routeGUID}));
function handleRT(routeJS){
route = JSON.parse(routeJS);
try {print("RouteGUID ", routeGUID, " has the name ",
route.name, "\n");}
catch(err){print("No such route\n");}
};
APRgpx = OCPNgetARPgpx(); // get Active Route Point as GPX
if (APRgpx.length > 0){
waypointPart = /<name>.*<\/name>/.exec(APRgpx);
waypointName = waypointPart[0].slice(6, -7);
print("Active waypoint is ", waypointName, "\n");
}
else print("No active waypoint\n");
myWaypoint = OCPNgetSingleWaypoint("137eecdd-e3e0-4eea-9d72-6cec0e500dbe");
if (!myWaypoint){
print("No waypoint with that GUID\n");
}
else{
print("Waypoint name is ", myWaypoint.markName, "\n");
}
Waypoint = require("Waypoint");
newWaypoint = new Waypoint(50.33, -1.3);
newWaypoint.markName = "Demo Waypoint";
newWaypoint.iconName = "anchor";
newWaypoint.isVisible = true;
newWaypoint.description = "Good pub close by ashore";
newWaypoint.hyperlinkList.push({description:"Pub website", link:
"https://coachandhorses.co.uk"});
GUID = OCPNaddSingleWaypoint(newWaypoint);
newWaypoint.GUID = GUID;
function fibonacci(n) {
function fib(n) {
if (n == 0) return 0;
if (n == 1) return 1;
return fib(n-1) + fib(n-2);
};
var res = [];
for (i = 0; i < n; i++) res.push(fib(i));
return(res.join(' '));
};
@antipole2
antipole2 / gist:a6d3475c8a34d7072988a4b844e238b8
Last active August 28, 2020 10:48
Plugin to handle email notifications and subscriptions from front and backends and also after moderation approval
<?php
/**
* Plugin Name: Ovni Submission Notifications
*
* Description: Sends email notifications when topics or replies are published. Also deals with moderation.
* Author: Tony Voss
 * Text Domain: Ovni-submission-notifications
* Version: 2.1
* Credits: Started by cloning the plugin pending-submission-notifcations by Razvan Horeanga
* Notes: This plugin handles all notifications except for publication of WP posts and comments, which are handled by WP.
// constructs route from NMEA WPL & RTE sentences
// optional simulator to synthesis NMEA data
// Updated v0.2.1 2 Sep 2020 to fix bugs when no routes and be consistent with NMEA message as object
// Updated v0.2.2 7 Sep 2020 several changes to correct when waypoints updated and to include Danish similation data
// Updated v0.2.3 9 Sep 2020 to fix when loading existing routes and there are none
// options
replaceExitingRoutes = true; // if true, any exiting OpenCPN route with the same name will be updated
testMode = true; // if true, uses simulated data rather than listening for real NMEA sentences