Skip to content

Instantly share code, notes, and snippets.

View fractaledmind's full-sized avatar

Stephen Margheim fractaledmind

View GitHub Profile
@fractaledmind
fractaledmind / List2Record Handler
Created November 29, 2013 21:30
This handler requires Late Night Software's List & Record Tools (http://www.latenightsw.com/freeware/list-record-tools/), but it will allow you to convert a list with paired sub-lists (i.e. {{"num", 1}, {"title", "the Best"}}) to a record (i.e. {num:1, title:"the Best"}).
set theList to {{"num", 1}, {"title", "the Best"}}
list2record(theList)
on list2record(l)
--requires Late Night Software's List & Record Tools (http://www.latenightsw.com/freeware/list-record-tools/)
--takes list with paired sub-lists and converts to record
set rec to {}
repeat with i from 1 to count of l
set x to item i of l
set rec to set user property (item 1 of x) in rec to (item 2 of x)
@fractaledmind
fractaledmind / SkimPage2Evernote
Created February 4, 2014 16:09
Append PDFPen url of current Skim Page to selected Evernote note.
property theHome : path to home folder as string
set base1 to POSIX path of theHome & "Copy/"
set base2 to POSIX path of theHome & "Documents/PDFs/"
tell application "Skim"
set pdfTitle to name of document 1
set customurl to "pdfpen:///" & pdfTitle & "?pg="
set notePage to index of current page of document 1
set theURL to customurl & notePage
set filePath to path of document 1
@fractaledmind
fractaledmind / MMD-Citekey2MMDref_bibtex
Created February 4, 2014 16:17
Convert MMD cite keys (i.e. [#cite-key] or [#cite-key;]) to formatted references and citations using a BibDesk .bib database file.
property tid : AppleScript's text item delimiters
--these file types represent all of the options in BibDesk
property filetypes : {"article", "book", "booklet", "commented", "conference", "glossdef", "inbook", "incollection", "inproceedings", "jurthesis", "manual", "mastersthesis", "misc", "periodical", "phdthesis", "proceedings", "techreport", "unpublished", "url", "electronic", "webpage"}
property fieldtypes : {"address", "annotate", "author", "booktitle", "chapter", "crossref", "date-modified", "doi", "edition", "editor", "howpublished", "institution", "issn", "journal", "key", "month", "note", "number", "organization", "pages", "publisher", "school", "series", "title", "type", "url", "urldate", "volume", "year"}
set t to the clipboard
@fractaledmind
fractaledmind / File2JSON
Created February 4, 2014 16:23
Create a JSON representation of a chosen file's metadata.
(* CREATE JSON OF FILE METADATA
--Stephen Margheim
--2/4/14
--open source
REQUIREMENTS:
- Late Night Software's List & Record Tools (http://www.latenightsw.com/freeware/list-record-tools/)
- Mousedown Software's JSON Helper (http://www.mousedown.net/mouseware/JSONHelper.html)
@fractaledmind
fractaledmind / Evernote2HTML
Created February 4, 2014 16:25
Get the HTML contents of the selected Evernote note
tell application "Evernote"
set Evernote_Selection to selection
if Evernote_Selection is {} then display dialog "Please select a note."
set noteLink to ""
repeat with i from 1 to the count of Evernote_Selection
set noteHTML to HTML content of item i of Evernote_Selection
end repeat
end tell
@fractaledmind
fractaledmind / Zotero_queries
Created February 4, 2014 17:06
A collection of SQLite queries for the Zotero database
(* ZOTERO SQLITE QUERIES
--Stephen Margheim
--2/4/14
--open source
This is a collection of SQLite queries to be used with a user's Zotero database to extract most relevant pieces of information.
Each query will return a string list of all the item keys that match the query.
*)
@fractaledmind
fractaledmind / Get_pdf_meta-data
Created February 4, 2014 17:12
Extract pdf meta-data using pdftk CLI
property zpdftk : "/usr/local/bin/pdftk"
tell application "Finder"
set pdfFile to choose file of type {"PDF ", "PDF Document"}
set pdfPath to (POSIX path of pdfFile)
end tell
set pdfmeta to do shell script zpdftk & " " & quoted form of pdfPath & " dump_data"
@fractaledmind
fractaledmind / Get_pdf_meta-data2
Created February 4, 2014 17:15
Extract pdf meta-data without pdftk
set biglist to {}
set theListCommand to {"kMDItemFSName ", "kMDItemAuthors ", "kMDItemEncodingApplications ", "kMDItemCreator ", "kMDItemTitle ", "kMDItemDescription ", "kMDItemContentCreationDate "}
set theList to {"File Name = ", "Author = ", "PDF Producer = ", "Content Creator = ", "Title = ", "Description = ", "Content Creation Date = "}
tell application "Finder"
set SiTem to selection
repeat with item_a from 1 to number of items in SiTem
set this_item to item item_a of SiTem as string
set this_item to POSIX path of this_item
repeat with item_b from 1 to number of items in theListCommand
set this_kMDItem to item item_b of theListCommand as string
@fractaledmind
fractaledmind / MMDLink
Created February 5, 2014 00:53
Bookmarklet to send webpage title, url, and selected text to Drafts in MMD format
@fractaledmind
fractaledmind / MMDLink_no-post
Created February 5, 2014 01:03
Bookmarklet to send webpage title, url, and selection to Drafts (without automatically posting to Postach.io)
javascript:window.location='drafts://x-callback-url/create?text='+encodeURIComponent(document.title+'\n\n')+'%5B'+encodeURIComponent(document.title)+'%5D('+encodeURIComponent(location.href)+')'+encodeURIComponent('\n\n>'+window.getSelection());