Skip to content

Instantly share code, notes, and snippets.

View dansheffler's full-sized avatar

Dan Sheffler dansheffler

View GitHub Profile
tell application "Skim"
# Get current dimensions and font size of the currently
# selected note.
set theDocument to the front document
set filePath to the file of theDocument
set theNote to the active note of theDocument
set theBounds to the bounds of theNote
set noteWidth to the (third item of theBounds) - the (first item of theBounds)
set noteHeight to the (second item of theBounds) - the (fourth item of theBounds)
set theView to the view settings of theDocument
let s:spc = g:airline_symbols.space
function! airline#extensions#pandoc#word_count()
if mode() == "s"
return 0
else
let s:old_status = v:statusmsg
let position = getpos(".")
let s:word_count = 0
exe ":silent normal g\<c-g>"
# This gets
# (i) the file displayed in the front window
# (ii) the page number or index of the page displayed. The first page of a
# PDF is always 1.
tell application "Skim"
set skimFile to the file of the front document
set skimPage to the index of the current page of the front document
end tell
# This gets the citekey for the first reference in Bibdesk whose linked file
@dansheffler
dansheffler / MyDirectoryNav.vim
Last active August 29, 2015 14:03
Vim script for walking up or down a Scrivener drafts directory (or any directory really).
function! MyDirectoryNav(direction)
let theDirectory = fnamemodify(expand('%'),':p:h') " Should be the /drafts/ directory of a Scrivener project, but will work for anything.
let thisFile = fnamemodify(expand('%'),':p') " Path to the current file.
let theFiles = split(globpath(theDirectory,'*.md'),'\n') " A list of all the .md files in the directory.
let thisIndex = index(theFiles, thisFile) " the index of the current file in this list.
if a:direction == 'j'
let nextFile = get(theFiles, thisIndex + 1, theFiles[0]) " If the direction is down, get the next file or loop to the beginning if the current file is last.
else
let nextFile = get(theFiles, thisIndex - 1, theFiles[-1]) " Likewise for going up.
endif
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>Skimmer</string>
<key>CFBundleURLSchemes</key>
<array>
<string>sk</string>
</array>
</dict>
@dansheffler
dansheffler / skimmer.scpt
Last active June 26, 2019 20:44
Applescript for system-wide URL integrating Skim and Bibdesk
on open location skimmerURL
set oldDelims to AppleScript's text item delimiters
set newDelims to {"sk://", "#"}
set AppleScript's text item delimiters to newDelims
set bibKey to item 2 of the text items of skimmerURL
set pdfPage to item -1 of the text items of skimmerURL as integer
set AppleScript's text item delimiters to oldDelims
GET /packages/archive/00-index.tar.gz HTTP/1.1
Host: hackage.haskell.org
User-Agent: cabal-install/1.16.0.2
Creating new connection to hackage.haskell.org
Warning: http error: Network.Browser.request: Error raised ErrorParse "Invalid
cabal: Char.intToDigit: not a digit -1