Skip to content

Instantly share code, notes, and snippets.

View cmittendorf's full-sized avatar

Christian Mittendorf cmittendorf

View GitHub Profile
@cmittendorf
cmittendorf / ServiceLocator.swift
Last active July 13, 2016 12:45
A simple ServiceLocator written in Swift.
protocol ServiceLocatorType {
func getService<T>(type: T.Type) -> T
}
public final class ServiceLocator: ServiceLocatorType {
public static let instance = ServiceLocator()
private var serviceRegistry: [String:Any] = [:]
@cmittendorf
cmittendorf / ViewTextOfSafariInPages.scpt
Created January 10, 2017 07:51
Creates a new Pages document from the text of the frontmost Safari document.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set content to missing value
tell application "Safari"
try
set content to text of first document
end try
end tell
@cmittendorf
cmittendorf / copyCreatedDateFromFile.sh
Created May 13, 2017 08:18
A script for macOS which copies the created date from one file to another.
#!/usr/bin/env bash
if [ $# != 2 ]; then
echo `basename $0`" <src file> <dst file>"
exit
fi
SetFile -d '$(GetFileInfo -m "$1")' "$2"
@cmittendorf
cmittendorf / copyLocationFromFile.sh
Created May 13, 2017 10:12
Copies the location information on macOS from one file to another.
#!/usr/bin/env bash
if [ $# != 2 ]; then
echo `basename $0`" <src file> <dst file>"
exit
fi
xattr -w "com.apple.metadata:kMDItemLatitude" $(mdls -name kMDItemLatitude "$1" | awk '{print $3}' | sed s/\"//g) "$2"
xattr -w "com.apple.metadata:kMDItemLongitude" $(mdls -name kMDItemLongitude "$1" | awk '{print $3}' | sed s/\"//g) "$2"
@cmittendorf
cmittendorf / add_safari_url_to_omni_outliner.applescript
Last active February 27, 2018 14:01
An AppleScript for adding the URL from the current tab to an OmniOutliner document.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set document_name to "Safari Links"
set row_topic to "Links"
set browser_url to missing value
tell application "Safari"
set browser_url to URL of first document