Skip to content

Instantly share code, notes, and snippets.

@tjluoma
tjluoma / get-dropbox-path.sh
Created January 14, 2020 04:29
shell commands to parse the ~/.dropbox/info.json file and determine where Dropbox is installed
# If you have a 'work' or 'business' Dropbox and a 'personal' one,
# this will only work on the 'personal' one
JSON="$HOME/.dropbox/info.json"
if [[ ! -e "$JSON" ]]
then
echo "$NAME: '$JSON' file not found." >>/dev/stderr
exit 2
@tjluoma
tjluoma / pdf-rename-by-cdate.sh
Created December 26, 2019 21:55
rename PDF files by their creation date (as determined by PDF metadata)
#!/usr/bin/env zsh -f
# Purpose: rename PDFs by their creation date
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: 2019-12-26
NAME="$0:t:r"
if [[ -e "$HOME/.path" ]]
@tjluoma
tjluoma / mdpdfpagecount.sh
Created December 24, 2019 04:23
Use `mdls` on macOS to get the number of pages in PDF files
#!/usr/bin/env zsh -f
# Purpose: count PDF pages with a variety of tools
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: 2019-12-23
NAME="$0:t:r"
if [[ -e "$HOME/.path" ]]
@tjluoma
tjluoma / rename-files-by-filetype.sh
Created October 4, 2019 04:47
use 'file' command to make sure files have the proper (expected) extension
#!/usr/bin/env zsh -f
# Purpose: use 'file' command to make sure image files have proper extension
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: 2019-10-04
NAME="$0:t:r"
if [[ -e "$HOME/.path" ]]
@tjluoma
tjluoma / seconds2readable.sh
Created September 27, 2019 03:43
Convert seconds (input) into a readable duration
#!/bin/bash
# Purpose: Convert seconds (input) into a readable duration
# SOURCE: <https://raw.github.com/livibetter/td.sh/master/td.sh>
# DATE: 2013-01-03
# Converting seconds to human readable time duration.
# Copyright (c) 2010, 2012 Yu-Jie Lin
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
@tjluoma
tjluoma / proxystate.sh
Last active July 18, 2019 18:46
Assuming you have a Mac with both wired Ethernet and Wi-Fi, this will show you whether or not the http/https proxy is set for both
#!/bin/zsh -f
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
## Note:
## ETHERNET_REGULAR / WIFI_REGULAR means http
## ETHERNET_SECURE / WIFI_SECURE means https
ETHERNET_REGULAR=$(networksetup -getwebproxy Ethernet | awk -F' ' '/^Enabled:/{print $2}')
@tjluoma
tjluoma / mas-list-apps.sh
Last active May 22, 2019 12:54
Generate an alphabetized list of all of the apps that are installed on your Mac which came from the Mac App Store, and open the list in a text file.
find /Applications -type d -user 0 -iname _MASReceipt -maxdepth 3 -print \
| sed 's#/Contents/_MASReceipt##g' \
| sort -f \
| open -f
@tjluoma
tjluoma / com.tjluoma.autolock-on-login.plist
Created January 9, 2019 21:31
A 'launchd' plist to automatically lock your Mac as soon as you log in.
<?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.autolock-on-login</string>
<key>ProgramArguments</key>
<array>
<string>/System/Library/CoreServices/Menu Extras/user.menu/Contents/Resources/CGSession</string>
<string>-suspend</string>
@tjluoma
tjluoma / com.tjluoma.lunadisplay.plist
Created January 6, 2019 23:24
This is a '.plist' file, intended to be used with `launchd` on Mac OS X. See http://luo.ma/LunaDisplay for more details
<?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>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.tjluoma.keep-lunadisplay-running</string>
<key>ProgramArguments</key>
<array>
@tjluoma
tjluoma / Dropbox-Conflicts.savedSearch
Last active July 16, 2018 02:59
A ".savedSearch" file for Mac OS X for use with Spotlight, designed to find Dropbox's "conflicted copies". It should be saved to the ~/Library/Saved Searches/ folder and named something like "Dropbox-Conflicts.savedSearch". Be sure to change "YOUR-HOMEDIR-HERE" to your actual Home directory name.
<?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>CompatibleVersion</key>
<integer>1</integer>
<key>RawQuery</key>
<string>(kMDItemDisplayName = "*s conflicted copy*"cd)</string>
<key>RawQueryDict</key>
<dict>