Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Dzombak cdzombak

View GitHub Profile
@cdzombak
cdzombak / listening
Created May 31, 2019
simple cross-platform wrapper for lsof/netstat to tell what processes are listening for network connections
View listening
#!/usr/bin/env python3
import argparse
import platform
import subprocess
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
@cdzombak
cdzombak / CDZTableViewSplitDelegate.h
Created Jan 4, 2013
Separate concerns. `UIScrollViewDelegate` deals with a container, while `UITableViewDelegate` deals with content. It's often useful to have two different objects manage these concerns, but Cocoa Touch makes it difficult since `UITableViewDelegate` conforms to `UIScrollViewDelegate` and `UITableView` has only one delegate property. `CDZTableViewS…
View CDZTableViewSplitDelegate.h
#import <Foundation/Foundation.h>
@interface CDZTableViewSplitDelegate : NSObject <UIScrollViewDelegate, UITableViewDelegate>
@property (nonatomic, weak) id<UITableViewDelegate> tvDelegate;
@property (nonatomic, weak) id<UIScrollViewDelegate> svDelegate;
- (id)initWithScrollViewDelegate:(id<UIScrollViewDelegate>)scrollViewDelegate tableViewDelegate:(id<UITableViewDelegate>)tableViewDelegate;
@end
View things-to-of.applescript
--------------------------------------------------
--------------------------------------------------
-- Import tasks from Things to OmniFocus
--------------------------------------------------
--------------------------------------------------
--
-- Script taken from: http://forums.omnigroup.com/showthread.php?t=14846&page=2
-- Added: creation date, due date, start date functionality
-- Empty your Things Trash first.
-- Note that this won't move over scheduled recurring tasks.
View install-restic-pi.sh
#!/usr/bin/env bash
RESTIC_TAG_LATEST=$(curl --silent "https://api.github.com/repos/restic/restic/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")')
echo "Downloading and installing restic v$RESTIC_TAG_LATEST ..."
RESTIC_URL=https://github.com/restic/restic/releases/download/v${RESTIC_TAG_LATEST}/restic_${RESTIC_TAG_LATEST}_linux_arm.bz2
curl -L --silent ${RESTIC_URL} | bunzip2 > /usr/local/bin/restic
chmod +x /usr/local/bin/restic
@cdzombak
cdzombak / youtube-dl-wrapper.sh
Last active Oct 9, 2019
youtube-dl wrapper for downloading videos direct to the correct Plex collection on my plex Mac Mini
View youtube-dl-wrapper.sh
#!/bin/bash
# all sorts of more advanced features are available, but this is a start:
# https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template-examples
if [ -z $1 ]; then
echo "Syntax: $0 VIDEO_URL"
exit 1
fi
VIDEO_URL="$1"
@cdzombak
cdzombak / bookmarklet.js
Last active Sep 26, 2019
Bookmarklet which builds a Markdown link to the current page
View bookmarklet.js
javascript:!function(){var%20e=window.getSelection().toString(),t=document.title.replace(%22%20-%20Jira%22,%22%22),n=e%3Fe:t,o=%22[%22+n+%22](%22+location.href+%22)%22;(function(e){var%20t=document.createElement(%22textarea%22),n=document.getSelection();t.textContent=e,document.body.appendChild(t),n.removeAllRanges(),t.select(),document.execCommand(%22copy%22),n.removeAllRanges(),document.body.removeChild(t)})(o)}();
@cdzombak
cdzombak / 10-banner
Last active Sep 26, 2019
automatic figlet based banner
View 10-banner
#!/bin/sh
figlet -f big "$(hostname --fqdn)" | grep -v "^ *$"
View rewrite.md

collected links on rewriting software (or not)

View lightweight-healthcheck.sh
#!/usr/bin/env bash
set -u
THING_DESC="dzombak.com"
EMAIL_SUBJECT="[dzombak.com] Website"
LASTSTATUS_FILE="$HOME/.website-healthcheck-status"
EMAIL_TO="chris@example.com"
SMS_TO="+1xxxxxxxxxx"
TWILIO_NUMBER="+1xxxxxxxxxx"
@cdzombak
cdzombak / mastodon-streaming-healthcheck.sh
Created Jun 11, 2019
Mastodon health checks, run every minute via cron on a separate server
View mastodon-streaming-healthcheck.sh
#!/usr/bin/env bash
set -u
NOW=$(date +"%F %T %Z")
OK=
if curl -s https://a2mi.social/api/v1/streaming/health | grep -c OK > /dev/null ; then
OK="1"
else
OK="0"
You can’t perform that action at this time.