Skip to content

Instantly share code, notes, and snippets.

@tjluoma
tjluoma / com.tjluoma.ntpdate.plist
Created February 27, 2014 06:38
Save this file as /Library/LaunchDaemons/com.tjluoma.ntpdate.plist
<?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.tjluoma.ntpdate</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/ntpdate</string>
<string>-b</string>
# These are the required fields
INSTALLED_NAME=""
INSTALL_DIR=""
DL_URL=""
LATEST_VERSION=""
VERSION_TYPE=""
# This is the actual filename that will be installed once the app is installed
# note that the '.app' suffix _is_ included because we might be
# installing preference panes so we don't want to assume.
INSTALLED_NAME="VLC.app"
# this is the directory where the 'INSTALLED_NAME' program will go
# when it is installed. Could be anywhere as long as user can write to it
# such as "$HOME/Applications" or "$HOME/Library/PreferencePanes"
# or even something weird like '/var/mac/apps' if you have a truly
# odd configuration for some reason.
INSTALLED_NAME="VLC.app"
INSTALL_DIR="/Applications"
DL_URL=$(curl -sL 'http://update.videolan.org/vlc/sparkle/vlc.xml' | awk -F'"' '/http:\/\/.*\.dmg/{print $2}'| tail -1)
LATEST_VERSION=$(curl -sL 'http://update.videolan.org/vlc/sparkle/vlc.xml' | awk -F'"' '/sparkle:version/{print $2}'| tail -1)
VERSION_TYPE="CFBundleVersion"
tell application "Microsoft Word"
if it is running then
save active document
end if
end tell
@tjluoma
tjluoma / com.tjluoma.unhide-users.plist
Last active August 29, 2015 14:01
Save this to /Library/LaunchDaemons/com.tjluoma.unhide-users.plist and make it owned by root:wheel. Or use http://files.luo.ma/installers/unhide-users/Unhide-Users.pkg Full story at: http://www.tuaw.com/2014/05/16/automatically-unhide-the-users-folder-after-10-9-3-update/
<?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.tjluoma.unhide-users</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/chflags</string>
<string>nohidden</string>
@tjluoma
tjluoma / Toggle-Caffeine.scpt
Created May 23, 2014 18:52
If Caffeine is off: launch it, and tell user how long Caffeine will run for. If Caffeine is on, quit it.
tell application "System Events"
if exists (process "Caffeine") then
tell application "Caffeine"
if active is false then
turn on
do shell script "DURATION=`defaults read com.lightheadsw.caffeine.plist DefaultDuration`
if [ \"$DURATION\" = \"0\" ]
then
DURATION='Will run until quit'
else
@tjluoma
tjluoma / caffeine-report-duration-on-launch.sh
Created May 23, 2014 19:04
when Caffeine is launched, is it active or not? if active, report the default duration.
#!/bin/zsh -f
# Check Caffeine’s Status on Launch
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: 2014-05-23
NAME="$0:t:r"
# 1 = yes
@tjluoma
tjluoma / sundays.sh
Created June 9, 2014 21:14
Show all Sundays between now and the end of a given year
#!/bin/zsh -f
## Note: requires `gdate` --> brew install coreutils
# What year do you want to stop at?
# i.e. "2015" = print all Sundays from now until the end of 2015
STOP='2015'
# We need to figure out when the next Sunday is…
# Step 1) This is today (will be number 0-7)
TODAY=`gdate '+%u'`
while [ "$YEAR" -le "${STOP}" ]
do
# calculate and print the date
# Note that you can control the format of the date here too
DATE=`gdate --date "+${COUNT} day" '+%B %d, %Y'`
cat <<EOINPUT
* ${DATE}
* []()
*