Skip to content

Instantly share code, notes, and snippets.

Wiring Websites

David Newhall davidnewhall

Wiring Websites
View GitHub Profile
davidnewhall / delete_conversations.applescript
Created Nov 29, 2018
Delete every conversation in on Sierra using AppleScript
View delete_conversations.applescript
tell application "Messages"
repeat (count of (get every chat)) times
delete item 1 of (get every chat)
tell application "System Events" to tell process "Messages" to keystroke return
end repeat
end try
close every window
end tell
davidnewhall / pidfile_snippet.go
Last active Feb 3, 2021
How to write a PID file in Golang.
View pidfile_snippet.go
// Write a pid file, but first make sure it doesn't exist with a running pid.
func writePidFile(pidFile string) error {
// Read in the pid file as a slice of bytes.
if piddata, err := ioutil.ReadFile(pidFile); err == nil {
// Convert the file contents to an integer.
if pid, err := strconv.Atoi(string(piddata)); err == nil {
// Look for the pid in the process list.
if process, err := os.FindProcess(pid); err == nil {
// Send the process a signal zero kill.
if err := process.Signal(syscall.Signal(0)); err == nil {
davidnewhall /
Created Sep 21, 2017
Simple Nagios Notification Handler to Send Pretty Slack Notifications
# Send Nagios alert to a Slack Channel.
# Add something like this to Nagios commands.cfg:
#define command {
# command_name notify-host-by-slack
# register 1
#define command {
# command_name notify-service-by-slack
davidnewhall /
Last active Jul 31, 2016 — forked from mzupan/
Nagios check for monit services going unmonitored
#!/usr/bin/env python
# This script will connect to a remove monit instance and report
# CRITICAL if any of the services are currently 'unmonitored'.
import pynagios
import urllib2
import base64
from xml.dom.minidom import parseString
from pynagios import Plugin, make_option, Response