Skip to content

Instantly share code, notes, and snippets.

View benwaldie's full-sized avatar

Ben Waldie benwaldie

View GitHub Profile
@benwaldie
benwaldie / 2013-02-03-TUAW_Waldie-1.applescript
Last active December 12, 2015 03:08
TUAW > AppleScripting Notification Center > Scheduling Do Not Disturb > Enable Do Not Disturb
do shell script "defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean true"
set theDate to quoted form of (do shell script "date -u +\"%Y-%m-%d %H:%M:%S +0000\"")
do shell script "defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturbDate -date " & theDate
do shell script "killall NotificationCenter"
@benwaldie
benwaldie / 2013-01-27-TUAW_Waldie.plist
Created January 28, 2013 02:39
TUAW > Evernote > Scale Embedded Images Plist
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>jpg</string>
<string>jpeg</string>
<string>png</string>
<string>tif</string>
<string>tiff</string>
@benwaldie
benwaldie / 2013-01-27-TUAW_Waldie.applescript
Last active December 11, 2015 19:58
TUAW > Evernote > Scale Embedded Images
-- Receive images as input
on open theImages
-- Ask the user to specify a scaled image size
set theChoice to choose from list {"Low", "Medium", "High", "Custom"} default items {"Medium"} with title "Evernote > Scale Images Script" with prompt "Scale to what size?"
if theChoice = false then return
set theChoice to item 1 of theChoice
-- Set the maximum number of pixels accordingly, based on the specified scaled image size
if theChoice = "Low" then
@benwaldie
benwaldie / 2013-01-20-TUAW_Waldie2.applescript
Created January 21, 2013 03:22
TUAW > TextExpander Date Snippets > Current Week
set theDate to (current date)
set theStartDate to theDate
repeat until weekday of theStartDate = Sunday
set theStartDate to theStartDate - 1 * days
end repeat
set theEndDate to theDate
repeat until weekday of theEndDate = Saturday
set theEndDate to theEndDate + 1 * days
end repeat
set theDate to (short date string of theStartDate) & " - " & (short date string of theEndDate)
@benwaldie
benwaldie / 2013-01-20-TUAW_Waldie1.applescript
Last active December 11, 2015 09:58
TUAW > TextExpander Date Snippet > Next Sunday
set theDate to (current date) + 1 * days
repeat until weekday of theDate = Sunday
set theDate to theDate + 1 * days
end repeat
set theDate to year of theDate & "-" & (text -2 thru -1 of ("0" & (month of theDate as integer))) & "-" & (text -2 thru -1 of ("0" & (day of theDate as integer))) as string
@benwaldie
benwaldie / 2013-01-13-TUAW_Waldie.applescript
Created January 14, 2013 02:37
TUAW > Send OmniFocus Due Tasks to iTunes
-- Set this property to the perspective you want to process
property thePerspectiveName : "Due"
-- Set up a variable for the task list text
set theTaskList to ""
-- Target OmniFocus
tell application "OmniFocus"
activate
@benwaldie
benwaldie / 2013-01-06-TUAW_Waldie.applescript
Created January 7, 2013 01:59
TUAW > OmniFocus > Swap Selected Task Names and Notes
tell application "OmniFocus"
-- Target the content of the front window
tell content of front window
-- Retrieve every selected task
set theTasks to value of every selected tree
-- Notify the user if no tasks are selected
if theTasks = {} then
@benwaldie
benwaldie / 2012-12-23-TUAW_Waldie.applescript
Last active December 10, 2015 02:28
TUAW - AppleScript Desktop Icon Race
-- Set up some initial starting positions and offsets
property theRaceStartingLineTopPosition : 50
property theRaceStartingLineLeftPosition : 100
property theRaceStartingLineBottomOffset : 200
property theRaceFinishLineRightOffset : 200
-- Determine the screen size
tell application "Finder"
set theDesktopBounds to bounds of window of desktop
set theDesktopWidth to item 3 of theDesktopBounds
@benwaldie
benwaldie / 2012-12-09-TUAW_Waldie.applescript
Created December 9, 2012 18:34
TUAW - Send Keynote Presenter Notes to Evernote with AppleScript
-- Make sure a presentation is opened in Keynote. If not, notify the user and stop.
tell application "Keynote"
if (front slideshow exists) = false then
display alert "Unable to proceed." message "Please open a presentation in Keynote."
return
end if
set extractBody to button returned of (display alert "Would you like to extract slide content too?" buttons {"Yes", "No"}) = "Yes"
-- Target the front presentation.
@benwaldie
benwaldie / 2012-11-25-TUAW_Waldie-2.applescript
Created November 26, 2012 04:14
TUAW - Cascade Finder Windows
-- Ask the user to enter some preliminary values for positioning and sizing the windows
set theTopOffset to askForInput("How many pixels would you like between the menu bar and the first window?", 10)
set theLeftOffset to askForInput("How many pixels would you like between the left of the screen and the first window?", 10)
set theWindowHeight to askForInput("How many pixels high would you like each window?", 300)
set theWindowWidth to askForInput("How many pixels wide would you like each window?", 350)
set theWindowOffset to askForInput("How many pixels would you like the windows offset from one another?", 25)
set staggerWindows to (button returned of (display dialog "Would you like the windows to cascade to the right?" buttons {"No", "Yes"} default button "Yes")) = "Yes"
-- Compensate for the menu bar
set theTopOffset to theTopOffset + 45