Skip to content

Instantly share code, notes, and snippets.

View johndyer's full-sized avatar

John Dyer johndyer

View GitHub Profile
@johndyer
johndyer / ConvertInTextEndnotesToFootnote.vb
Created December 8, 2020 15:26
Moves citations from Endnote X that are in the main text (Dyer, 2018) of a Word document to a Footnote
' adapted from https://community.endnote.com/t5/EndNote-How-To/Converting-in-text-citations-to-footnotes-endnotes/td-p/4438/page/2
Public Sub ConvertInTextEndnotesToFootnote()
Dim oField As Field
Dim sCode As String
Dim sSuffix As String
Dim sSuffixLeft As String
Dim sSuffixRight As String
Dim pos1 As Long
@johndyer
johndyer / MoveFootnoteCitationInline.vb
Last active July 3, 2020 16:21
Visual Basic Macro for moving EndNote citations from footnotes inline
Sub MoveFootnoteCitationInline()
' declare variable
Dim oFeets As Footnotes
Dim oFoot As Footnote
Dim oRange As Range
Dim szFootNoteText As String
Dim index As Long
Dim oFootRefRange1 As Range
Dim oFootRefRange2 As Range
@johndyer
johndyer / gist:4051055da5a3bbde220259f4150377b0
Last active June 6, 2019 13:57
BetterTouchTool - Verse of the Day
-- makes the verse two lines (use font: 11 to fit)
on splitLines(theText)
set middleChar to ((length of theText) / 2)
set templine2 to text middleChar through (length of theText) of theText
set nextSpace to offset of " " in templine2
set splitSpace to middleChar + nextSpace - 1
set line1 to text 1 through splitSpace of theText
set line2 to text (splitSpace + 1) through (length of theText) of theText
@johndyer
johndyer / index.php
Last active October 13, 2020 12:25
Gutenberg Shortcode Block with Live Preview
<?php
/**
* Plugin Name: JD Gutenberg Shortcode Preview
* Description: Live shortcode previews in Gutenberg
* Author: johndyer
* Version: 1.0.0
*
*/
// Exit if accessed directly.
@johndyer
johndyer / easter.js
Last active April 9, 2024 16:28
Calculate Easter in JavaScript
/**
* Calculates Easter in the Gregorian/Western (Catholic and Protestant) calendar
* based on the algorithm by Oudin (1940) from http://www.tondering.dk/claus/cal/easter.php
* @returns {array} [int month, int day]
*/
function getEaster(year) {
var f = Math.floor,
// Golden Number - 1
G = year % 19,
C = f(year / 100),
@johndyer
johndyer / dts-export-markers.jsx
Last active November 9, 2018 11:19
Export still from Adobe Premiere Pro CC based on markers
/*
name: DTS Export Markers
description: exports markers into JPGs and creates XML in a format DTS's video player can read
author: John Dyer
created: 2017-04-07
updated: 2017-04-11
version 1.0.1
references:
http://cssdk.s3-website-us-east-1.amazonaws.com/sdk/2.1/docs/WebHelp/references/csawlib/com/adobe/premiere/package-detail.html
https://github.com/Adobe-CEP/Samples/blob/master/PProPanel/jsx/Premiere.jsx
@johndyer
johndyer / gist:5178734
Created March 16, 2013 23:11
Why RegExp.lastIndex is really, really important
var r = /love/gi,
s = 'i love you',
a = [s,s,s];
for (var i=0,il=a.length; i<il; i++) {
console.log(r.test(a[i]));
}
/*
RESULTS:
@johndyer
johndyer / .htaccess
Created July 13, 2011 13:06
Google+ redirect .htaccess
#simple version (http://mysite.com/+ goes to your Google+ account)
Redirect /+ https://plus.google.com/[yourid]
Redirect /@ https://twitter.com/[twitterusername]
#powerhouse (http://mysite.com/+/about goes to your Google+ about page)
RedirectMatch ^/\+(.*)$ http://plus.google.com/[yourid]$1
RedirectMatch ^/@(.*)$ http://twitter.com/[twitterusername]$1
@johndyer
johndyer / check_all.js
Created June 1, 2011 21:24 — forked from nathansmith/check_all.js
Used to check all checkboxes in a page.
(function(d) {
var input = d.getElementsByTagName('input'),
i = input.length;
while (i--) {
if (input[i].type === 'checkbox') {
input[i].setAttribute('checked', 'checked');
}
}
})(this.document);
@johndyer
johndyer / cache.php
Created February 9, 2011 03:06
Simple PHP Object Caching
<?php
// Super simple caching class
class PhpCache {
protected $path = null;
protected $duration = null;
function __construct ( $path, $duration = 60) {
$this->path = $path;
$this->duration = $duration;
}