Skip to content

Instantly share code, notes, and snippets.

View januz's full-sized avatar

Janosch Linkersdörfer januz

View GitHub Profile
#!/usr/bin/env python
# -*- encoding:utf-8 -*-
from PyPDF2 import PdfFileReader
import re
import sys
pdf_file = sys.argv[1]
doi_re = re.compile("10.(\d)+/([^(\s\>\"\<)])+")
input = PdfFileReader(file(pdf_file, "rb"))
# path to python which has pypdf(2) installed
set pythonExecutable to "/usr/bin/python"
# path to python script that extracts DOI
set doiExtract to "/Users/XXX/path/to/pypdf_doi.py"
# the PDF file that is going to be processed
set pdfPath to quoted form of (POSIX path of theFile)
set newPDF to theFile
tell application "Finder" to set pdfName to name of theFile
# start BibDesk if it is not running
on run argv
# fill in your working hours here
set start_time_morning to convert_minutes(8.0)
set finish_time_morning to convert_minutes(12.3)
set start_time_afternoon to convert_minutes(14.0)
set finish_time_afternoon to convert_minutes(18.0)
# -----------------------------------------
set start_time_morning_secs to start_time_morning * 3600
set finish_time_morning_secs to finish_time_morning * 3600
set start_time_afternoon_secs to start_time_afternoon * 3600
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.YOURNAME.SelfControl</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/PATH/TO/THE/SCRIPT/selfcontrol.applescript</string>