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 / 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 / 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 / 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 / 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 / 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 / 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":"''"
},
@mitcdh
mitcdh / 20-system-info
Created March 6, 2018 00:43
Script for update-motd that includes a system information snapshot
#!/bin/sh
date=$(date)
load=$(cat /proc/loadavg | awk '{print $1}')
root_usage=$(df -h / | awk '/\// {print $(NF-1)}')
memory_usage=$(free -m | awk '/Mem/{printf("%3.1f%%"), $3/$2*100}')
swap_usage=$(free -m | awk '/Swap/{printf("%3.1f%%"), $3/$2*100}')
users=$(users | wc -w)
time=$(uptime | awk -F'( |,|:)+' '{print $6,$7",",$8,"hours,",$9,"minutes"}')
processes=$(ps aux | wc -l)
@mitcdh
mitcdh / email2gcontact.txt
Last active May 24, 2018 04:04
Email To: to Google Contact Regex
# Written for use in atom :: https://atom.io/
# Regex in the format "First_Name Other_Names (Company) <email@address>"
(\w+)\s([\w\s']+)\s\(([^\)]+)\)\s<([^>]+)>,\s
# CSV Header
Name,Given Name,Additional Name,Family Name,Yomi Name,Given Name Yomi,Additional Name Yomi,Family Name Yomi,Name Prefix,Name Suffix,Initials,Nickname,Short Name,Maiden Name,Birthday,Gender,Location,Billing Information,Directory Server,Mileage,Occupation,Hobby,Sensitivity,Priority,Subject,Notes,Group Membership,E-mail 1 - Type,E-mail 1 - Value,Organization 1 - Type,Organization 1 - Name,Organization 1 - Yomi Name,Organization 1 - Title,Organization 1 - Department,Organization 1 - Symbol,Organization 1 - Location,Organization 1 - Job Description
# Replacement
"$1 $2","$1",,"$2",,,,,,,,,,,,,,,,,,,,,,,"* My Contacts ::: Cyber","* Work","$4",,"$3",,,,,,\n