Skip to content

Instantly share code, notes, and snippets.

@henryroe
henryroe / Access NSScreen.scpt
Last active March 7, 2021 21:54
Demonstration of how to use an AppleScript Bundle to enable access to NSScreen in AppleScriptObjC
(*
Copy and paste this script into a new document in AppleScript Editor.
When saving, select "Script Bundle" as File Type.
Save the file to: "~/Library/Script Libraries/Access NSScreen.scptd"
Note: you may need to create the directory: "~/Library/Script Libraries"
Note: while this gist has the file ending "scpt", by selecting the
"Script Bundle" file type, the file extension "scptd" should be added.
@henryroe
henryroe / traitsui_matplotlib_playground.py
Last active August 26, 2020 13:02
The demo of traitsui, matplotlib, including a pop-up menu, I wish I'd found.
import wx
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.image import AxesImage
from matplotlib.axes import Axes
from matplotlib.widgets import AxesWidget
import matplotlib.pyplot as plt
@henryroe
henryroe / ocr_all_pdf_in_dir_recursive.scpt
Last active March 9, 2020 16:13
OCR all documents in a user selected folder using PDFpenPro 6 on OS X recursively descending through the directory tree
--
-- OCR all documents in a folder and all sub-folders
--
set theFolder to (choose folder with prompt "Choose Folder to OCR every PDF in recursively descending")
ocr_this_folder(theFolder)
on ocr_pdf(PDFfilename)
tell application "PDFpenPro 6"
open PDFfilename
set theDoc to document 1
@henryroe
henryroe / ocr_all_pdf_in_dir.scpt
Created December 6, 2013 16:46
OCR all documents in a user selected folder using PDFpenPro 6 on OS X Note: No recursion into other folders. For a recursive version, see: https://gist.github.com/henryroe/7828092
--
-- OCR all documents in a folder
--
set theFolder to (choose folder with prompt "Choose Folder to OCR every PDF in")
ocr_this_folder(theFolder)
on ocr_pdf(PDFfilename)
tell application "PDFpenPro 6"
open PDFfilename
set theDoc to document 1
@henryroe
henryroe / Save mail attachments with pre-pended YYYY-MM-DD_.kmmacros
Created February 16, 2015 01:50
Keyboard Maestro macro to take Mail.app attachments, pre-pend YYYY-MM-DD_..., and save to user-selected dir
<?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">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>IsActive</key>
<true/>
<key>Macros</key>
@henryroe
henryroe / list_displays.sh
Created February 4, 2014 18:37
List all display sizes and origins in /Library/Preferences/com.apple.windowserver.plist
#!/bin/bash
output=""
numDisplaySets=`/usr/libexec/PlistBuddy -c "Print DisplaySets" /Library/Preferences/com.apple.windowserver.plist | grep -E '^ Array' | wc -l`
for (( curDisplaySetNum=0; curDisplaySetNum<$numDisplaySets; curDisplaySetNum++ ))
do
echo "DisplaySet "$curDisplaySetNum
curDisplayNum=0
notdone=1
while [[ "$notdone" -ne 0 ]]
@henryroe
henryroe / grepfits
Last active July 26, 2016 04:11
grepfits: Command line script for summarizing selected keywords from headers of one or more FITS files
#!/usr/bin/env python
# This script is released under an "MIT License"; see https://opensource.org/licenses/MIT
# The MIT License (MIT)
# Copyright (c) 2016 Henry Roe (hroe@hroe.me)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
@henryroe
henryroe / lessfits
Created July 26, 2016 03:55
lessfits: Command line script for paging through a FITS file's headers
#!/bin/bash
# This script is released under an "MIT License"; see https://opensource.org/licenses/MIT
# The MIT License (MIT)
# Copyright (c) 2016 Henry Roe (hroe@hroe.me)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
@henryroe
henryroe / Rotate portrait pages by 90
Created January 6, 2014 22:20
Rotate portrait pages by +90degrees in current document in PDFpenPro 6
# Install this file in:
# ~/Library/Application Scripts/com.smileonmymac.PDFpenPro6.MacAppStore/
# and it will then be accessible from the Applescript menu in PDFpenPro 6
tell application "PDFpenPro 6"
if (count documents) > 0 then
set myDoc to document 1
set pageCount to count pages of myDoc
repeat with pageNumber from 1 to pageCount
if (height of page pageNumber of myDoc) > (width of page pageNumber of myDoc) then
@henryroe
henryroe / scene_scroll_test.py
Created September 27, 2013 04:24
scene_scroll_test
from scene import *
from math import exp
from threading import Thread
import datetime
# example scrolling scene with inertial scrolling
# basic scrolling example was by Dalorbi on the forums at:
# http://omz-software.com/pythonista/forums/discussion/213/scrolling-in-scene-module/p1
# inertial scrolling added on by hroe