Skip to content

Instantly share code, notes, and snippets.

View derickfay's full-sized avatar

Derick Fay derickfay

View GitHub Profile
-- 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 / 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
@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 / fix_notes.applescript
Created April 16, 2015 16:55
Change Keynote Presenter Notes Font and Size for All Slides
tell application "Keynote"
tell document 1
set theSlides to slides
repeat with s in the slides
tell presenter notes of s
set font to "Helvetica"
set size to 24
end tell
end repeat
end tell
@derickfay
derickfay / TE recipient
Last active December 9, 2017 06:39
TextExpander snippet to add recipient's name to email
-- TextExpander snippet to add recipient's name to email
-- based on http://macsparky.com/blog/2015/6/automatically-add-recipients-name-to-email-with-textexapnder [sic]
-- updated to handle hyphenated first names properly
-- ( Original version would return Young for Young-Hee . This version returns Young-Hee. )
set theResult to ""
tell application "System Events"
tell process "Mail"
tell text field "To:" of window 1
# !/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"
set theDate to do shell script "date '+%Y-%m-%d'"
set outputPath to "~/Dropbox/mytemp/"
set format to "txt"
set counter to 1
set theFolder to "Notes"
-- uses a counter to avoid duplicate filenames if notes have the same title
tell application "Notes"
tell folder theFolder
set theNotes to every note
@derickfay
derickfay / lstag.sh
Last active April 29, 2018 23:10
Search for files with a given tag in the current working directory only
if [ "$#" -ne 1 ]
then
echo "Usage: lstag <tag>"
exit 1
fi
mdfind "kMDItemUserTags == '*$1*'" -onlyin . | sort --ignore-case | grep $PWD | grep -v ^$PWD/.*/.*$ | sed 's!.*/!!'
@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 "$@"
(* EXPORT ALL SKIM NOTES TO THE CLIPBOARD WITH MARKDOWN REFERENCE LINKS
(no longer) requires hackademic URL handler from github user smargh
entirely rewritten to take advantage of Skim's built-in templating
2016-06-26 by derickfay
*)