Skip to content

Instantly share code, notes, and snippets.

View mitcdh's full-sized avatar

Mitchell Hewes mitcdh

View GitHub Profile
@mitcdh
mitcdh / pms-util-env
Created July 6, 2018 03:44
pms-docker environment variables for local operation
export LD_LIBRARY_PATH="/usr/lib/plexmediaserver"
export LANG="en_US.UTF-8"
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6"
export PLEX_MEDIA_SERVER_TMPDIR="/tmp"
export PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver"
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support"
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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