Skip to content

Instantly share code, notes, and snippets.

View mitcdh's full-sized avatar

Mitchell Hewes mitcdh

View GitHub Profile
@mitcdh
mitcdh / gist:d5b8591717abde3fe7e59e340f64af1f
Last active September 19, 2016 00:39
Route53 Automated DNS Service Inline Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"route53:GetChange",
"route53:ListHostedZones",
"route53:ListHostedZonesByName",
"route53:GetHostedZoneCount"
@mitcdh
mitcdh / gist:e2af3f537a9c82df76bf5bfad7c12977
Last active June 6, 2017 01:33
Bash function to generate Junos address book entries
# e.g. host2j google.com [..] TRUST
# e.g. jhostset google.com [..] google-servers TRUST
function host2j()
{
ZONENAME="${@: -1}"
for HOSTNAME in "$@"
do
if [ "$HOSTNAME" != "$ZONENAME" ]
then
@mitcdh
mitcdh / Set Name to kMDItemTitle.applescript
Last active April 3, 2017 00:42
Devonthink script to set the name of any selected records to their kMDItemTitle metadata property
tell application id "DNtp"
try
set this_selection to the selection
set this_count to count of this_selection
if this_count > 0 then
show progress indicator "Renaming" steps this_count
repeat with this_item in this_selection
set this_metadata to meta data of this_item
try
set this_title to |kMDItemTitle| of this_metadata
@mitcdh
mitcdh / OopsieFocus.applescript
Last active April 3, 2017 00:42
Modified version of OopsieFocus.scpt that finished with the quick entry dialog in focus
(*
OopsieFocus
A script to launch OmniFocus and activate the Quick Entry Panel
By Shawn Blanc (http://shawnblanc.net)
May 20, 2011
With code used from the Toggle Twitter script by Red Sweater Software:
http://www.red-sweater.com/blog/1646/toggle-twitter
@mitcdh
mitcdh / Remove URL.applescript
Last active April 3, 2017 00:42
Removes URLs from the selected Devonthink record
tell application id "DNtp"
try
set this_selection to the selection
set this_count to count of this_selection
if this_count > 0 then
show progress indicator "Removing URL" steps this_count
repeat with this_item in this_selection
set the URL of this_item to ""
end repeat
hide progress indicator
@mitcdh
mitcdh / Pinboard (archive).applescript
Last active April 26, 2019 14:26
Pinboard archive script for Devonthink Pro that archives bookmarks as web documents rather than just links
-- Import Pinboard bookmarks
-- Created by Christian Grunenberg on Mon Jan 23 2006.
-- Modified by Rafael Bugajewski to support Pinboard instead of Delicious on Sun Dec 19 2010.
-- Modified by Andreas Zeitler on Sun Mar 03 2011 to display user feedback when finished
-- Modified by Mitchell Hewes on 2017-04-03 to archive bookmarks as PDF documents
-- Copyright (c) 2006-2014. All rights reserved.
-- If the properties pUser and pPassword are undefined then a dialog pops up asking for these properties
property pUser : ""
property pPassword : ""
@mitcdh
mitcdh / New Tab (Chrome).applescript
Last active May 11, 2021 10:19
Applescripts for new blank tabs with address bar focused
tell application "Google Chrome"
tell front window
activate
if URL of active tab is not equal to "chrome://newtab/" then
make new tab at end of tabs
end if
end tell
end tell
@mitcdh
mitcdh / New Terminal (iTerm2).applescript
Created April 3, 2017 00:49
New Terminal window (assuming new window is created on app start)
on iTermIsRunning()
tell application "System Events"
return (count of (application processes whose name is "iTerm2")) is not 0
end tell
end iTermIsRunning
if iTermIsRunning() then
tell application "iTerm"
activate
create window with default profile
@mitcdh
mitcdh / mac-printer.sh
Created June 28, 2017 03:19
Add new smb shared network printer in macOS (including drivers)
#!/bin/bash
# printer options
PRINTER_NAME=${PRINTER_NAME:=}
PRINT_SERVER=${PRINT_SERVER:=}
# driver options
# DRIVER_PKG it will be silently installed and inform DRIVER_PATH
DRIVER_PKG=${DRIVER_PKG:=}
DRIVER_PATH=${DRIVER_PATH:=}
@mitcdh
mitcdh / config.gateway.json
Created February 28, 2018 07:12
USG IPv6 over PPPoE gateway config for Unifi versions 5.7.x
{
"interfaces":{
"ethernet":{
"eth0":{
"pppoe":{
"0":{
"ipv6":{
"address":{
"autoconf":"''"
},