Skip to content

Instantly share code, notes, and snippets.

View derickfay's full-sized avatar

Derick Fay derickfay

View GitHub Profile
@derickfay
derickfay / tpsort.py
Created February 8, 2014 22:10
Python script to sort text by the dates in @Due(YYYY-MM-DD) tags. Made for use with TaskPaper files.
#!/usr/bin/env python
import re
import sys
# first & only argument is the text to be parsed
theText = sys.argv[1]
theList=[]
j=""
-- creates notes on every page in the lower L and lower R for those occasions where the scanner cut off the page numbers
set firstPage to (text returned of (display dialog "Enter Starting Page" default answer "")) as number
set currentPage to firstPage
tell application "Skim"
set pp to pages of document 1
repeat with p in items of pp
tell p
@derickfay
derickfay / switchTheme.applescript
Created April 15, 2015 20:06
Change Keynote theme and preserve image dimensions
set themeName to "Black"
tell application "Keynote"
set theSlides to slides of document 1
set theImages to {}
repeat with s in theSlides
set theImages to theImages & (images of s)
end repeat
set theDimensions to {}
repeat with i in theImages
# !/bin/sh
#
# adds @XXX Taskpaper style tags to a single file as Finder tags,
# converting hyphens to spaces in the process
#
# requires https://github.com/jdberry/tag
#
TAGS=$(grep "@[a-zA-Z\-]*" --only-matching "$1" | sort | uniq | sed 's/@//g;s/-/ /g' | tr '\n' ', ')
tag -a "$TAGS" "$1"
-- original by Stephen Margheim
-- edited to write the clipboard by Derick Fay, 29 Aug 2013
-- edited to change link format to Cite Key Title
--establish a variable for the line feed (aka LF key)
set LF to ASCII character 10
--insert the MetaData for export to Evernote
set theText to "# BibDesk Sources Index w/ biblio links" & LF & "= !nbox" & LF & "@ BibDesk, Source List" & LF & LF & LF & "**List of Sources in BibDesk Group**" & LF & LF & LF
@derickfay
derickfay / Export All Skim Notes with Markdown Reference Links to Clipboard
Last active December 22, 2015 00:08 — forked from fractaledmind/Export All Skim Notes with Markdown Reference Links
Avoids editor-specific dependency by copying notes to the clipboard rather than adding to a file.
@derickfay
derickfay / stripHomeDir.applescript
Last active December 22, 2015 08:29
Strip the user home directory from a filename in Applescript
tell application "Skim"
set theFile to file of document 1 as string
set theHome to path to home folder as string
set theFilePath to my replaceText(theHome, "", theFile)
end tell
on replaceText(find, replace, someText)
set prevTIDs to text item delimiters of AppleScript
@derickfay
derickfay / BibDesk-MavericksTags.scpt
Last active January 26, 2016 17:13
Adds the Keywords from the current selection in BibDesk to all linked files as Mavericks tags.
set plistFront to "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"><plist version=\"1.0\"><array>"
set plistEnd to "</array></plist>"
(* By Derick Fay, 2013-10-28 *)
(* Thanks to http://mosx.tumblr.com/post/54049528297/convert-openmeta-to-os-x-mavericks-tags-with-this for getting me started *)
tell application "BibDesk"
-- without document, there is no selection, so nothing to do
if (count of documents) = 0 then
@derickfay
derickfay / jstorPDFtoBibTeX.sh
Last active June 2, 2016 04:54
Extract bibliographic information in BibTeX format from PDF from jstor.org
#!/bin/sh
# jstorPDFtoBibTeX
# requires pdftotext, tag
# has about a 85% success rate in my experience
header="@article{"
footer="}\n\n"
biblio=""
for filename in "$@"
@derickfay
derickfay / New rtfs with citations.scpt
Created January 31, 2014 19:10
Export BibDesk citations as individual rtf files
set theFolder to POSIX path of (choose folder with prompt "Choose target folder for new documents:")
tell application "BibDesk"
set thePubs to selection of document 1
repeat with thePub in thePubs
set filename to (theFolder as string) & (cite key of thePub as string) & ".rtf"
export document 1 using template "Template" to filename for thePub --insert your template name here
end repeat
end tell