Skip to content

Instantly share code, notes, and snippets.

View dorward's full-sized avatar

David Dorward dorward

View GitHub Profile
@dorward
dorward / purepaste.js
Created November 14, 2023 12:06
Script for Pure Paste that rewrites Twitter URLs to a proxy that adds a preview
// https://sindresorhus.com/pure-paste
if ($.text.match(/https:\/\/twitter.com\/\S+$/)) {
return $.text.replaceAll('https://twitter.com/', 'https://vxtwitter.com/');
}
return $.text;
@dorward
dorward / ReplaceSlashes.gs
Created May 21, 2021 06:55
Replaces / with \ in Google Sheets
function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu('Extras')
.addItem('Replace / with \\ in selection', 'replaceSlashes')
.addToUi();
}
function replaceSlashes() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const range = SpreadsheetApp.getActive().getActiveRange();
@dorward
dorward / Patrizia's Diary.gs
Last active June 5, 2020 08:00
Patrizia's Diary
const discordUrl = "...";
// 1: Get a webhook URL from discord and put it in the constant above
// 2: In Google Sheets go to the tools menu and open the script editor
// 3: Paste this there and save it
// 4: In the Edit menu select the Current Project's Triggers
// 5: Click addTrigger and make the onEdit function an onEdit trigger
function onEdit(e) {
// Debounce
@dorward
dorward / metalsmith-calendar.js
Last active February 19, 2018 15:07
Plugin for Metalsmith that formats iCal URLs into useful data for pumping into a template
module.exports = metalcalendar;
const multimatch = require('multimatch');
const debug = require('debug')('metalsmith-calendar');
const fetch = require("node-fetch");
const ical = require("ical");
const moment = require("moment");
const marked = require('marked');
@dorward
dorward / spamassassin-rule-maker.pl
Created December 2, 2017 18:19
Generate spam assassin files from STDIN
#!/usr/bin/env perl
# Generate spam assassin files from STDIN
use strict;
use warnings;
use v5.10;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
@dorward
dorward / dashboard.atml
Last active April 12, 2017 15:02
Template Toolkit blocks
[% INCLUDE db_header.atml %]
@dorward
dorward / extract.js
Created September 29, 2016 12:36
Pull a WordPress export apart into separate files.
/***********
*
* You'll need Node JS, you can get it from https://nodejs.org/en/
*
* This uses a third party libraries, install them with:
*
* npm install libxmljs
*
* Change the filename below, then run with:
*
/**
* alertifyjs 1.6.0 http://alertifyjs.com
* AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
* Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
* Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
.alertify .ajs-dimmer {
position: fixed;
z-index: 1981;
top: 0;
right: 0;
@dorward
dorward / module_loader.hb
Created November 28, 2015 16:40
I wish ES6 supported dynamic module loading. Then I might not feel the need to do this.
// Load all the modules.
// ES6 doesn't support dynamic module loading, so we can't just pull these from files. They have to be hard coded.
{{#modules}}
import * as {{name}} from "./seq/{{name}}.js";
{{/modules}}
import {List} from 'immutable';
export function loadModules() {
return new List([
@dorward
dorward / STDOUT
Created June 28, 2015 08:14
Template toolkit won't copy files
[ david@raston ] % ttree -s src -d dist -r --accept='.tt2$' -v -v --copy='\.css$'
Do you want me to create a sample '.ttreerc' file for you?
(file: /Users/david/.ttreerc) [y/n]: n
ttree 2.9 (Template Toolkit version 2.26)
Source: src
Destination: dist
Include Path: [ ]
Ignore: [ ]
Copy: [ \.css$ ]