Skip to content

Instantly share code, notes, and snippets.

View derickfay's full-sized avatar

Derick Fay derickfay

View GitHub Profile
@derickfay
derickfay / export skim notes to markdown on clipboard sorting by color.applescript
Last active June 21, 2019 17:19
export skim notes to markdown on clipboard sorting by color.applescript
(* EXPORT ALL SKIM NOTES TO THE CLIPBOARD
(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
2019-02-09 updated to group notes by color
*)
property LF : (ASCII character 10)
@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 / Dates.js
Last active March 2, 2019 04:50
Date text formatter for Copied
// there are two parts to this text formatter. Both draw heavily from
// the date calculation snippets created by Brett Terpstra - see
// https://brettterpstra.com/2015/06/01/textexpander-5-javascript-snippets/
// part 1 - the date library
// strftime for JS <http://hacks.bluesmoon.info/strftime/>
Date.prototype.locale = 'en-GB';
Date.ext = {};
Date.ext.util = {};
@derickfay
derickfay / day.less
Last active October 23, 2018 21:41
daytime TaskPaper 3 theme
// UI Scale
@base-font-size: 16;
@user-font-size: $USER_FONT_SIZE;
@ui-scale: @user-font-size / @base-font-size;
// UI Colors
@tint-color: darkblue;
@handle-color: white;
@collapsed-color: red;
@derickfay
derickfay / bttGlobal.json
Created July 17, 2018 10:23
Global toggle button for BTT
{
"BTTTouchBarButtonName" : "Global",
"BTTTriggerType" : 629,
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : 190,
"BTTPredefinedActionName" : "Force Show\/Hide Global BTT Touch Bar Actions",
"BTTEnabled2" : 1,
"BTTUUID" : "937923F9-24F3-4AD7-883F-7DE9E2D3FA30",
"BTTEnabled" : 1,
"BTTOrder" : 5,
@derickfay
derickfay / clean.js
Created May 11, 2018 16:58
Clean scraped results from the National Archives of South Africa
// scraper for http://www.national.archsrch.gov.za/sm300cv/smws/sm300dl
//
// usage: select results in search results, enter multiple documents view, then copy contents of the results frame to a text file called archives.txt
const fieldnames = ["Document","DEPOT","SOURCE","TYPE","VOLUME_NO","SYSTEM","REFERENCE","PART","DESCRIPTION","STARTING","ENDING","REMARKS.*"]
const replacements = ["",",",",",",",",",",",",",",",",",",",",",""]
var fs = require('fs');
var path = process.cwd();
let d = fs.readFileSync(path + "/archives.txt").toString().replace(/\,/g," ");
@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 / Broke.js
Created April 23, 2018 21:18
Broken prompt
// See online documentation for examples
// http://getdrafts.com/scripting
var p = Prompt.create();
p.title = "";
p.message = "";
p.addButton("Add to draft");
p.addTextField("Enter text", "t","");
var con = p.show();
@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