Skip to content

Instantly share code, notes, and snippets.

View derickfay's full-sized avatar

Derick Fay derickfay

View GitHub Profile
@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
@derickfay
derickfay / cleanKindle.applescript
Last active June 3, 2019 00:32
Remove citation info. from text copied from Kindle for Mac
on alfred_script(q)
set quote to first paragraph of q
set otd to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"(Kindle Locations ", ")"}
set bits to every text item of q
set pageNumber to item 3 of bits
set quote to first paragraph of q
return quoted form of quote & " (" & pageNumber & ")"
set AppleScript's text item delimiters to otd
end alfred_script
-- 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 / tp2fantastical
Last active August 20, 2016 13:57
Sends the input text to Fantastical, converting TaskPaper @Due(YYYY-MM-DD) tags to plain text for Fantastical to parse as a Reminder. Designed for use with Drafts and Pythonista.
# tp2fantastical
#
# by Derick Fay, 2014-04-06
#
# an adaptation of the Selection to Fantastical Editorial workflow
# (http://editorial-app.appspot.com/workflow/6172238982152192/Y3VYajI3Hzc )
# for use with Drafts and Pythonista (both required)
#
# works on iPhone and iPad
# I have also written an equivalent script for TaskPaper for the Mac
@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=""
@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
@derickfay
derickfay / MergeAllFinderWindows
Last active February 18, 2021 01:39
Merge all Finder windows - uses UI Applescript to execute the Finder menu command. There's a more error-proof version (not mine) in an Alfred workflow here: http://www.alfredforum.com/topic/3363-mavericks-merge-all-finder-windows/
tell application "System Events"
click menu item "Merge All Windows" of menu "Window" of menu bar item "Window" of menu bar 1 of application process "Finder" of application "System Events"
end tell
@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 / 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