Skip to content

Instantly share code, notes, and snippets.

View cmittendorf's full-sized avatar

Christian Mittendorf cmittendorf

View GitHub Profile
@cmittendorf
cmittendorf / AppleScriptProgressbar.applescript
Created October 26, 2014 09:25
As a new feature of OS X Yosemite, you now can display a progress bar from your AppleScript.
set progress total steps to 100
repeat with i from 1 to 100
set progress description to "Item " & i & " of " & 100
set progress additional description to "foobar"
delay 1
set progress completed steps to i
end repeat
@cmittendorf
cmittendorf / OpenSafariSourceInBBEdit.js
Created October 18, 2014 11:30
open Safari HTML source in BBEdit using new Yosemite JavaScript automation
var Safari = Application ("Safari")
if (Safari.documents().length > 0) {
var source = Safari.documents()[0].source()
Application("BBEdit").Document({"contents":source, "source language":"HTML"}).make()
}
@cmittendorf
cmittendorf / iTunes2Elastic.js
Created September 15, 2014 21:06
A little script for exporting you iTunes library into an ElasticSearch database with an index named 'itunes' (requires Yosemite). You may then search for all your Beatles songs using the following command: curl --silent -XGET "localhost:9200/itunes/_search?pretty&size=10000" -d '{"query":{"match":{"artist":"beatles"}}}'|jq '[.hits.hits[]._source]'
var app = Application.currentApplication()
app.includeStandardAdditions = true
var itunes = Application("iTunes")
var url = "http://localhost:9200/itunes/track/"
var lib = itunes.sources["Library"]
var tracks = lib.tracks()
@cmittendorf
cmittendorf / OpenTerminalWithPath.applescript
Created August 31, 2014 10:37
Open a Terminal window with the front Finder window as path.
on run
tell application "Finder"
activate
try
set this_folder to (the target of the front window) as alias
on error
set this_folder to startup disk
end try
my open_terminal_window(this_folder)
end tell
@cmittendorf
cmittendorf / CodeSign Information.applescript
Last active August 29, 2015 14:04
Show codesign information for an application. You may download a signed (of course) version here: http://h1152756.serverkompetenz.net/SharedStuff/Show%20CodeSign%20Information.zip
on open theFiles
repeat with aFile in theFiles
set appPath to POSIX path of aFile
set codeSignInformation to do shell script "codesign -vd '" & appPath & "' 2>&1"
display dialog codeSignInformation with title ("codesign -vd " & appPath) buttons {"Ok"} default button 1
end repeat
end open
on run
open (choose file with multiple selections allowed)
@cmittendorf
cmittendorf / display-notification.sh
Last active August 29, 2015 14:04
A little snippet showing how to create a log function in bash that displays its log message in the Mac OS X notification center as well as on the console.
#!/usr/bin/env bash
function log()
{
echo `date +"[%d.%m.%Y %H:%M:%S] "`$1
# Available Sounds:
# Basso, Blow, Bottle, Frog, Funk, Glass, Hero,
# Morse, Ping, Pop, Purr, Sosumi, Submarine, Tink
osascript << EOF
@cmittendorf
cmittendorf / MakeNewFileOrFolder.applescript
Last active August 29, 2015 14:04
Create new files or folders with a keystroke and by using the Tool FastScripts (http://www.red-sweater.com/fastscripts/) you can overwrite the default Finder Shift-Command-N shortcut to create a new folder for invoking our new script.
(**
Create new files or folders with a keystroke and by using the Tool
FastScripts http://www.red-sweater.com/fastscripts/
you can overwrite the default Finder Shift-Command-N shortcut
to create a new folder for invoking our new script.
**)
tell application "Finder"
-- default name for a new file following
-- the Finders convention for naming folders
set newFileName to "untitled file"
@cmittendorf
cmittendorf / safari-url.sh
Created June 20, 2014 07:10
Get the URL of the current web page from Safari
#!/usr/bin/env bash
URL=$(osascript << EOF
tell application "Safari"
tell its first document
URL
end tell
end tell
EOF)
@cmittendorf
cmittendorf / safari-text.sh
Created June 20, 2014 07:08
Retrieve the text content of the current web page from Safari
#!/usr/bin/env bash
# prepared for Yosemite (10.10)
# osascript -l JavaScript -e "Application('Safari').documents()[0].text()"
CONTENT=$(osascript -ss << EOF
tell application "Safari"
tell its first document
get its text
end tell
@cmittendorf
cmittendorf / View WWDC 2014 Videos with QT7.scpt
Last active August 29, 2015 14:02
This AppleScript will allow you to select a WWDC 2014 video and open it automatically using the QuickTime 7 player (http://support.apple.com/kb/DL923) allowing you to increase the playback speed as mentioned in BitsUndSo episode #379 (http://www.bitsundso.de/bus379/). Be aware that the script does not check if the QT7 player is already installed.
(***
Use this AppleScript to launch WWDC 2014 videos in QuickTime Player 7, where
you can adjust the playback speed to your needs (⌘ + k). Have fun!
Christian Mittendorf, 15.06.2014
cmittendorf<et>me.com
***)
set page_url to "https://developer.apple.com/videos/wwdc/2014/"
set videos to missing value