Skip to content

Instantly share code, notes, and snippets.

View edcottrell's full-sized avatar

Ed Cottrell edcottrell

View GitHub Profile
@edcottrell
edcottrell / textexpander-snippet-to-search-the-internet-archive.js
Created July 5, 2023 02:06
TextExpander Snippet to Search the Internet Archive
// Get the URL for the Internet Archive history (if any) for the
// URL currently on the system clipboard
// Start with the clipboard content
var result = TextExpander.pasteboardText;
result = 'https://web.archive.org/web/*/' + result;
// Return the result
TextExpander.appendOutput(result);
@edcottrell
edcottrell / textexpander-snippet-for-cleaning-ocr-output.js
Created July 5, 2023 02:05
TextExpander Snippet for Cleaning OCR Output
// Attempt to clean up messy OCR output (in English) from the clipboard by fixing broken paragraphs,
// removing clutter from page headers and footers, and correcting a few other common glitches.
// It's always a good idea to read over whatever OCRed content you're pasting, but this helps me often.
// Start with the clipboard content
var text = TextExpander.pasteboardText;
// helper function to escape special characters modified from https://stackoverflow.com/questions/3115150/how-to-escape-regular-expression-special-characters-using-javascript
@edcottrell
edcottrell / textexpander-snippet-slug-to-title-case.js
Created July 5, 2023 01:56
TextExpander Snippet: Slug to Title Case
function toTitleCase(text) {
var wordsToLeaveInLowerCase = [
        'a',
        'about',
        'above',
        'after',
        'again',
        'against',
        'an',
        'and',
@edcottrell
edcottrell / textexpander-snippet-for-creating-and-formatting-telephone-number-links.js
Created July 5, 2023 01:51
TextExpander Snippet for Creating and Formatting Telephone Number Links
@edcottrell
edcottrell / textexpander-snippet-clean-excel-quotation-marks.js
Created July 5, 2023 01:36
TextExpander Snippet to Paste Excel Values without Excess Quotation Marks (Leading, Trailing, or Doubled)
// Start with the clipboard content
var result = TextExpander.pasteboardText;
// If the result is wrapped in quotation marks...
if (result.match(/^"[\s\S]+"$/)) {
result = result.replace(/^"|"$/g, '') // Strip the leading and trailing quotation marks
.replace(/""/g, '"'); // And replace any doubled quotation marks ('""') with just one ('"')
}
// Return the result
@edcottrell
edcottrell / Birthday Snippet for Obsidian Using Dataview and Frontmatter.md
Created July 5, 2023 01:27
Birthday Snippet for Obsidian Using Dataview and Frontmatter

Birthday: $= '[[' + dv.current().birthday.toString().slice(0,10) + ']]' ($= moment().diff(moment(dv.current().birthday.toString()), 'years') years old)

@edcottrell
edcottrell / textexpander-snippet-yesterday-julian-day.js
Last active July 5, 2023 01:53
TextExpander Snippet for Yesterday's Julian Day Number
// This is useful for Google searches with date limitations.
// Based on the calculations at https://stackoverflow.com/a/11760121
Date.prototype.getJulian = function() {
return Math.floor((this / 86400000) - (this.getTimezoneOffset() / 1440) + 2440588);
}
var yesterday = new Date(); //set any date
yesterday.setDate(yesterday.getDate() - 1);
@edcottrell
edcottrell / obsidian-placeholder-template.md
Created July 5, 2023 01:12
Obsidian Placeholder Template
tags
#placeholder #todo

[!INFO] This note is a placeholder. It needs to be fleshed out.

Notes that Link to this Note

// ==UserScript==
// @name Stack Overflow Badge Info for Moderator Election Candidates
// @namespace https://github.com/edcottrell/
// @version 0.2.0
// @description Shows a prettier breakdown of the candidate's badges that contribute to candidate score
// @author Ed Cottrell
// @license MIT
// @match *://*.askubuntu.com/election*
// @match *://*.mathoverflow.net/election*
// @match *://*.serverfault.com/election*